-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] Convenience APIs for script objects #20226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The compiler should be emitting static lookups to object slots, but people using the C++ API should have some sugar for doing attribute lookup.
[jit] Convenience APIs for script objects The compiler should be emitting static lookups to object slots, but people using the C++ API should have some sugar for doing attribute lookup. gh-metadata: pytorch pytorch 20226 gh/suo/36/head
| return this->type_->qualname(); | ||
| } | ||
|
|
||
| IValue ivalue::Object::getAttr(const std::string& name) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want the same api as pybind11, which uses attr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pybind's attr returns a functor which lets you write to the object by assigning to it. I think that's probably a little overkill in this case.
I think i'll expose static getattr and setattr like the python builtins
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old API seems simpler, this makes it more like a C API. Maybe we shouldn't try to match pythons semantics here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with that. whatever is more natural for people I guess
test/cpp/jit/test_class_import.h
Outdated
| constantTable, | ||
| nullptr); | ||
|
|
||
| // Incorrect arguments for constructor should throow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throooooow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn the macbook keyboard :(
[jit] Convenience APIs for script objects The compiler should be emitting static lookups to object slots, but people using the C++ API should have some sugar for doing attribute lookup. gh-metadata: pytorch pytorch 20226 gh/suo/36/head
[jit] Convenience APIs for script objects The compiler should be emitting static lookups to object slots, but people using the C++ API should have some sugar for doing attribute lookup. gh-metadata: pytorch pytorch 20226 gh/suo/36/head
[jit] Convenience APIs for script objects The compiler should be emitting static lookups to object slots, but people using the C++ API should have some sugar for doing attribute lookup. gh-metadata: pytorch pytorch 20226 gh/suo/36/head
Summary: Pull Request resolved: pytorch/pytorch#20226 ghimport-source-id: 22937d72e35ec4eba38019284a368453089fe3eb Differential Revision: D15243625 Pulled By: suo fbshipit-source-id: 5e9fb773da244f9ef201dba524155c3b19b2b4e0
Stack from ghstack:
The compiler should be emitting static lookups to object slots, but
people using the C++ API should have some sugar for doing attribute
lookup.
Differential Revision: D15243625