Skip to content

Make JIT tracing a thread-local property#9414

Closed
apaszke wants to merge 8 commits intomasterfrom
weak_tracing
Closed

Make JIT tracing a thread-local property#9414
apaszke wants to merge 8 commits intomasterfrom
weak_tracing

Conversation

@apaszke
Copy link
Contributor

@apaszke apaszke commented Jul 13, 2018

As in the title. Lets us simplify a lot of code.

Depends on #9363, so please review only the last commit.

@zdevito

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@anderspapitto
Copy link
Contributor

thread locals have been causing trouble for me over at #8792 because once python-less libtorch.so is split out from python-full _C.so, Windows doesn't support exposing thread_local variables across the shared-object boundary. Will this PR introduce another occurrence of this issue?

@ssnl
Copy link
Collaborator

ssnl commented Jul 13, 2018

@ezyang told me that this will solve allow solving #9069 :D

@ezyang
Copy link
Contributor

ezyang commented Jul 14, 2018

@anderspapitto The thread local is not exported (it is not even in a header) so there should be no problem.

namespace torch { namespace autograd {
// Helper methods for working with Attributes (torch/csrc/jit/attributes.h)

at::Tensor maybeUnwrapVar(const at::Tensor& t) {

This comment was marked as off-topic.

This comment was marked as off-topic.

if (!THPVariable_Check(item)) return false;
auto & var = reinterpret_cast<THPVariable*>(item)->cdata;
return torch::jit::tracer::isTracing(var);
return var.dim() == 0 && torch::jit::tracer::getValueTrace(var);

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

////////////////////////////////////////////////////////////////////////////////
thread_local ArgumentStash ArgumentStash::stash;

void ArgumentStash::stashIntListElem(const std::string& arg_name, size_t size, size_t idx, const Variable& var) {

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

seems legit

Copy link
Contributor

@zdevito zdevito left a comment

Choose a reason for hiding this comment

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

This looks good! Cleans up a lot of stuff.

if (!THPVariable_Check(item)) return false;
auto & var = reinterpret_cast<THPVariable*>(item)->cdata;
return torch::jit::tracer::isTracing(var);
return var.dim() == 0 && torch::jit::tracer::getValueTrace(var);

This comment was marked as off-topic.

////////////////////////////////////////////////////////////////////////////////
thread_local ArgumentStash ArgumentStash::stash;

void ArgumentStash::stashIntListElem(const std::string& arg_name, size_t size, size_t idx, const Variable& var) {

This comment was marked as off-topic.

@ezyang
Copy link
Contributor

ezyang commented Jul 17, 2018

@pytorchbot retest this please

@apaszke
Copy link
Contributor Author

apaszke commented Jul 17, 2018

I would change the name of the function, but this would mean a whole roundtrip through the internal CI, which I'd like to avoid. We can fix it up later.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@apaszke has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

jramseyer pushed a commit to jramseyer/pytorch that referenced this pull request Jul 30, 2018
Summary:
As in the title. Lets us simplify a lot of code.

Depends on pytorch#9363, so please review only the last commit.

zdevito
Pull Request resolved: pytorch#9414

Reviewed By: zdevito

Differential Revision: D8836496

Pulled By: apaszke

fbshipit-source-id: 9b3c3d1f001a9dc522f8478abc005b6b86cfa3e3
goodlux pushed a commit to goodlux/pytorch that referenced this pull request Aug 15, 2018
Summary:
As in the title. Lets us simplify a lot of code.

Depends on pytorch#9363, so please review only the last commit.

zdevito
Pull Request resolved: pytorch#9414

Reviewed By: zdevito

Differential Revision: D8836496

Pulled By: apaszke

fbshipit-source-id: 9b3c3d1f001a9dc522f8478abc005b6b86cfa3e3
@soumith soumith deleted the weak_tracing branch February 21, 2019 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants