mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
custom class method holder should hold a unique_ptr (#35218)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/35218 We should express the ownership semantics directly here. Using `shared_ptr` makes it too easy to leak ownership by inadvertently storing a copy. Test Plan: Imported from OSS Differential Revision: D20682673 Pulled By: suo fbshipit-source-id: 32002ee515eb8bb7b37e6d0aac3c0695df4eec79
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b9adbb5002
commit
cfcb63de34
@ -223,15 +223,15 @@ class class_ {
|
||||
typename c10::guts::infer_function_traits_t<Func>::return_type;
|
||||
detail::BoxedProxy<RetType, Func>()(stack, func);
|
||||
};
|
||||
auto method = std::make_shared<jit::BuiltinOpFunction>(
|
||||
auto method = std::make_unique<jit::BuiltinOpFunction>(
|
||||
qualMethodName, std::move(schema), std::move(wrapped_func));
|
||||
|
||||
// Register the method here to keep the Method alive.
|
||||
// ClassTypes do not hold ownership of their methods (normally it
|
||||
// those are held by the CompilationUnit), so we need a proxy for
|
||||
// that behavior here.
|
||||
registerCustomClassMethod(method);
|
||||
classTypePtr->addMethod(method.get());
|
||||
registerCustomClassMethod(std::move(method));
|
||||
}
|
||||
|
||||
std::string qualClassName;
|
||||
|
Reference in New Issue
Block a user