Skip to content

Conversation

@zdevito
Copy link
Contributor

@zdevito zdevito commented Jun 19, 2019

Stack from ghstack:

Module is now a view of an ivalue object and has no other state. It no longer needs to be carried around in an std::shared_ptr and behaves more like IValue and Tensor. This PR updates the APIs to no longer return std::shared_ptr. It introduces module_list to iterate over modules in the Module object which is an extension to the slot_list API that turns the Slot into a module on dereference. This is a BC breaking change because we are change core Module loading APIs to no longer return a shared_ptr. Users of the C++ part of the JIT will likely need to replace std::shared_ptr with Module in their code, and replace -> with . where those objects are used.

Differential Revision: D15892401

@pytorchbot pytorchbot added caffe2 oncall: jit Add this issue/PR to JIT oncall triage queue module: cpp Related to C++ API module: custom-operators custom operators, custom ops, custom-operators, custom-ops module: internals Related to internal abstractions in c10 and ATen module: pybind Related to our Python bindings / interactions with other Python libraries labels Jun 19, 2019
zdevito added 3 commits June 18, 2019 19:31
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
@zdevito zdevito requested a review from suo June 19, 2019 04:05
Copy link
Member

@suo suo left a comment

Choose a reason for hiding this comment

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

ngnt

const py::function& var_name_lookup_fn,
bool force_outplace,
const std::shared_ptr<script::Module>& self = nullptr);
script::Module* self = nullptr);
Copy link
Member

Choose a reason for hiding this comment

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

There are a couple places in this PR where we take Module*, I assume so that it can be null. I think it's a bit weird pass around a pointer to a view of a reference type…maybe c10::optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The places where Module* are used are trying to avoid dependencies in headers. For instance, the tracer.h header is included inside of VariableType.h, a huge file. We are careful to avoid including Module.h because then it would rebuild a huge part of pytorch when modified. Unfortunately using c10::optional requires the definition to be present, so Module* is a workaround that does the same thing.

remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
zdevito added 5 commits June 19, 2019 16:51
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
remove uses of std::shared_ptr<Module>

gh-metadata: pytorch pytorch 21934 gh/zdevito/68/head
@zou3519 zou3519 deleted the gh/zdevito/68/head branch June 25, 2019 20:27
@facebook-github-bot
Copy link
Contributor

@zdevito merged this pull request in 5b87049.

facebook-github-bot pushed a commit that referenced this pull request Jun 27, 2019
)

Summary:
Pull Request resolved: #22291

There was a race between landing the benchmark diff and
#21934 from zdevito. This PR
should fix the issue.

Reviewed By: zdevito

Differential Revision: D16023640

fbshipit-source-id: 931714352e656f045f9ef3cd17422db51b168384
# define C10_DEPRECATED_MESSAGE(message) [[deprecated(message)]]
#elif defined(__GNUC__)
# define C10_DEPRECATED __attribute__((deprecated))
//# define C10_DEPRECATED __attribute__((deprecated))
Copy link
Contributor

Choose a reason for hiding this comment

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

ouch was this change intentional part of this diff? I'm working on a diff fixing compiler warnings and it just cost me a few hours to figure out why I don't see them anymore after rebasing. The changes to this file should be reverted.

xzhu1900 pushed a commit to xzhu1900/pytorch that referenced this pull request Jul 5, 2019
…orch#22291)

Summary:
Pull Request resolved: pytorch#22291

There was a race between landing the benchmark diff and
pytorch#21934 from zdevito. This PR
should fix the issue.

Reviewed By: zdevito

Differential Revision: D16023640

fbshipit-source-id: 931714352e656f045f9ef3cd17422db51b168384
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

caffe2 Merged module: cpp Related to C++ API module: custom-operators custom operators, custom ops, custom-operators, custom-ops module: internals Related to internal abstractions in c10 and ATen 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.

7 participants