Skip to content

Conversation

@zdevito
Copy link
Contributor

@zdevito zdevito commented May 30, 2019

Stack from ghstack:

Summary: This adds CallMethod to complement CallFunction. Now class
method calls are first emitted using CallMethod and Inline then removes
them. This preserves intent in the IR better and will be how Interfaces
(actually dynamically dispatched methods) will appear in the IR
Test Plan: test_jit.py

Differential Revision: D15552816

Summary: This adds CallMethod to complement CallFunction. Now class
method calls are first emitted using CallMethod and Inline then removes
them. This preserves intent in the IR better and will be how Interfaces
(actually dynamically dispatched methods) will appear in the IR
Test Plan: test_jit.py
@pytorchbot pytorchbot added oncall: jit Add this issue/PR to JIT oncall triage queue module: pybind Related to our Python bindings / interactions with other Python libraries labels May 30, 2019
Add CallMethod, inline eagerly
Summary: This adds CallMethod to complement CallFunction. Now class
method calls are first emitted using CallMethod and Inline then removes
them. This preserves intent in the IR better and will be how Interfaces
(actually dynamically dispatched methods) will appear in the IR
Test Plan: test_jit.py

gh-metadata: pytorch pytorch 21116 gh/zdevito/42/head
Add CallMethod, inline eagerly
Summary: This adds CallMethod to complement CallFunction. Now class
method calls are first emitted using CallMethod and Inline then removes
them. This preserves intent in the IR better and will be how Interfaces
(actually dynamically dispatched methods) will appear in the IR
Test Plan: test_jit.py

gh-metadata: pytorch pytorch 21116 gh/zdevito/42/head
Add CallMethod, inline eagerly
Summary: This adds CallMethod to complement CallFunction. Now class
method calls are first emitted using CallMethod and Inline then removes
them. This preserves intent in the IR better and will be how Interfaces
(actually dynamically dispatched methods) will appear in the IR
Test Plan: test_jit.py

gh-metadata: pytorch pytorch 21116 gh/zdevito/42/head
loc, f, inputsWithSelf, attributes, n_binders);
auto method = self_->type()->expect<ClassType>()->getMethod(method_name_);
TORCH_INTERNAL_ASSERT(method);
method->ensure_defined();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we are frequently calling ensure_defined() before doing something with a method—I think lazy compilation should be an internal detail of Method and callers shouldn't need to know about it. Don't have to change it here though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with this, but I don't know of a great place to put it yet. It is possible that we can choose which methods on Function should just call it but I haven't figured out if that works.


TORCH_API const std::vector<Function*>& getAllBuiltinFunctionsFor(Symbol name);

TORCH_API const std::vector<std::shared_ptr<Function>>&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we change these to owning pointers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the FunctionType object captures them as such when an emitCall happens.

@zou3519 zou3519 deleted the gh/zdevito/42/head branch June 4, 2019 04:38
@facebook-github-bot
Copy link
Contributor

@zdevito merged this pull request in 6e657c5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: pybind Related to our Python bindings / interactions with other Python libraries oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants