-
Notifications
You must be signed in to change notification settings - Fork 25.6k
[JIT] Introduce BuiltinOpFunction and integrate into torchbind #34098
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
[ghstack-poisoned]
💊 CircleCI build failures summary and remediationsAs of commit 0ca0eec (more details on the Dr. CI page): Commit 0ca0eec was recently pushed. Waiting for builds... This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.Please report bugs/suggestions on the GitHub issue tracker. This comment has been revised 40 times. |
} | ||
|
||
void run(Stack& stack) override { | ||
auto handle = c10::Dispatcher::singleton().findSchemaOrThrow( |
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.
BuiltinOp should just store its Schema, and std::function<void(Stack&)> directly. It does not have to participate in dispatch (and in fact will mostly only incur overhead because of it).
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.
@zdevito - hm, are you sure about that? I'd at least want to have it go through dispatcher to get profiling working. TorchBind ops can be potentially big so it's good to capture them through the same profiling infra. Alternatively - we can just slap the same RecordFunction here too
Also I'm pretty sure someone will want tracing to work too (though it's debatable)
…bind" [ghstack-poisoned]
…bind" [ghstack-poisoned]
…bind" Differential Revision: [D20226171](https://our.internmc.facebook.com/intern/diff/D20226171) [ghstack-poisoned]
…bind" Differential Revision: [D20226171](https://our.internmc.facebook.com/intern/diff/D20226171) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
torch/custom_class.h
Outdated
classTypePtr->addAttribute("capsule", at::CapsuleType::get()); | ||
|
||
c10::getCustomClassTypeMap().insert( | ||
{typeid(c10::intrusive_ptr<CurClass>).name(), |
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.
do you need demangle here and everywhere? Also - do we need to rely on RTTI for it? you could also use c10::get_fully_qualified_type_name (not sure where exactly we use these names). Or we never use those names other than for accounting? (in which case maybe we should just use typeid directly)
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 already asked this in another PR: why do we need demangling? We're simply looking for an exact match. In fact, if demangling is a lossy process, wouldn't that create bugs?
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
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.
This looks like it is going to work. Thanks for all the revisions. I just have some minor things to resolve inline.
bool AllowDeprecatedTypes, | ||
size_t... ivalue_arg_indices> | ||
typename c10::guts::infer_function_traits_t<Functor>::return_type | ||
call_torchbind_method_from_stack( |
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.
This appears to be unused?
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.
It's used in BoxedProxy below
cu_ = std::move(cu); | ||
type_ = type; | ||
TORCH_INTERNAL_ASSERT(type_); | ||
if (type_->cast<ClassType>()) { |
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.
We can possiblly keep this assert if the class table no longer holds StrongTypePtr objects
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.
ivalue::object::create
requires a StrongTypePtr
for instantiation of any object, and if it's a custom class that's going to be nullptr, so I don't think we can remove this
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
frames.back().pc = af.pc + 1; | ||
enterFrame(code, stack.size() - inst.N); | ||
af = ActiveFrame(frames.back()); | ||
if (!function->isGraphFunction()) { |
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.
nit: maybe have runFunction be a function, since this if-statement occurs twice.
…bind" Differential Revision: [D20229166](https://our.internmc.facebook.com/intern/diff/D20229166) [ghstack-poisoned]
@jamesr66a merged this pull request in 45a504d. |
Stack from ghstack:
Differential Revision: D20229166