Template Function torch::make_custom_class#
- Defined in File custom_class.h 
Function Documentation#
- 
template<typename CurClass, typename ...CtorArgs>
 c10::IValue torch::make_custom_class(CtorArgs&&... args)#
- make_custom_class() is a convenient way to create an instance of a registered custom class and wrap it in an IValue, for example when you want to pass the object to TorchScript. - Its syntax is equivalent to APIs like - std::make_shared<>or- c10::make_intrusive<>.- For example, if you have a custom C++ class that can be constructed from an - intand- std::string, you might use this API like so:- IValue custom_class_iv = torch::make_custom_class<MyClass>(3, "foobarbaz");