mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Revert D20541090: [JIT][torchbind] Namespaces for torchbind classes
Test Plan: revert-hammer Differential Revision: D20541090 Original commit changeset: ce3d9391dd3c fbshipit-source-id: acc1d660fbda611941381315507dfe594c385db1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bbec4520c6
commit
a100cf5146
@ -34,7 +34,7 @@ detail::types<void, Types...> init() {
|
||||
/// calls needed. For example, to register a class named Foo, you might
|
||||
/// create a global variable like so:
|
||||
///
|
||||
/// static auto register_foo = torch::class_<Foo>("myclasses", "Foo")
|
||||
/// static auto register_foo = torch::class_<Foo>("Foo")
|
||||
/// .def("myMethod", &Foo::myMethod)
|
||||
/// .def("lambdaMethod", [](const c10::intrusive_ptr<Foo>& self) {
|
||||
/// // Do something with `self`
|
||||
@ -51,16 +51,12 @@ class class_ {
|
||||
|
||||
public:
|
||||
/// This constructor actually registers the class type.
|
||||
/// String argument `namespaceName` is an identifier for the
|
||||
/// namespace you would like this class to appear in.
|
||||
/// String argument `className` is the name you would like to
|
||||
/// String argument `className_` is the name you would like to
|
||||
/// see this class exposed as in Python and TorchScript. For example, if
|
||||
/// you pass `foo` as the namespace name and `Bar` as the className, the
|
||||
/// class will appear as `torch.classes.foo.Bar` in Python and TorchScript
|
||||
explicit class_(const std::string& namespaceName, const std::string& className) {
|
||||
detail::checkValidIdent(namespaceName, "Namespace name");
|
||||
detail::checkValidIdent(className, "Class name");
|
||||
qualClassName = std::string("__torch__.torch.classes.") + namespaceName + "." + className;
|
||||
/// you pass in "MyStack" here, the class will appear as
|
||||
/// `torch.classes.MyStack` in both Python and TorchScript.
|
||||
explicit class_(const std::string& className) : className(std::move(className)) {
|
||||
qualClassName = topModule + "." + parentModule + "." + className;
|
||||
|
||||
classTypePtr = at::ClassType::create(
|
||||
c10::QualifiedName(qualClassName),
|
||||
@ -234,8 +230,12 @@ class class_ {
|
||||
classTypePtr->addMethod(method.get());
|
||||
}
|
||||
|
||||
std::string className;
|
||||
std::string qualClassName;
|
||||
at::ClassTypePtr classTypePtr;
|
||||
|
||||
const std::string parentModule = "classes";
|
||||
const std::string topModule = "__torch__.torch";
|
||||
};
|
||||
|
||||
/// make_custom_class() is a convenient way to create an instance of a registered
|
||||
|
Reference in New Issue
Block a user