mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
avoid redundant isCustomClassRegistered() checks (#42852)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/42852 Test Plan: Imported from OSS Reviewed By: smessmer Differential Revision: D23048381 Pulled By: bhosmer fbshipit-source-id: 40b71670a84cb6f7e5a03279f58ce227d676aa03
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bee174dc3f
commit
38c7b9a168
@ -261,11 +261,6 @@ class class_ {
|
||||
/// IValue custom_class_iv = torch::make_custom_class<MyClass>(3, "foobarbaz");
|
||||
template <typename CurClass, typename... CtorArgs>
|
||||
c10::IValue make_custom_class(CtorArgs&&... args) {
|
||||
if (!c10::isCustomClassRegistered<c10::intrusive_ptr<CurClass>>()) {
|
||||
throw c10::Error(
|
||||
"Trying to instantiate a class that isn't a registered custom class.",
|
||||
"");
|
||||
}
|
||||
auto userClassInstance = c10::make_intrusive<CurClass>(std::forward<CtorArgs>(args)...);
|
||||
return c10::IValue(std::move(userClassInstance));
|
||||
}
|
||||
|
Reference in New Issue
Block a user