Skip to content

Conversation

@RockingJavaBean
Copy link
Contributor

@RockingJavaBean RockingJavaBean commented Jun 30, 2020

Fix #40701

A new special case is added to let dim() save an int instead of self.

@RockingJavaBean
Copy link
Contributor Author

Before adding the special case, RepeatBackward struct in the generated code looks like below:

struct TORCH_API RepeatBackward : public TraceableFunction {
  using TraceableFunction::TraceableFunction;
  variable_list apply(variable_list&& grads) override;
  std::string name() const override { return "RepeatBackward"; }
  void release_variables() override {
    std::lock_guard<std::mutex> lock(mutex_);
    self_.reset_data();
    self_.reset_grad_function();
  }

  SavedVariable self_;
  std::vector<int64_t> repeats;

};

With the special case added, the struct looks like below:

struct TORCH_API RepeatBackward : public TraceableFunction {
  using TraceableFunction::TraceableFunction;
  variable_list apply(variable_list&& grads) override;
  std::string name() const override { return "RepeatBackward"; }
  void release_variables() override {


  }

  int64_t self_dim = 0;
  std::vector<int64_t> repeats;

};

please kind review this PR @albanD

@albanD albanD added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Jun 30, 2020
Copy link
Collaborator

@albanD albanD left a comment

Choose a reason for hiding this comment

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

Wow I wasn't expecting this to be so simple :)
Thanks for taking the time to make the PR!

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.

@albanD is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@albanD merged this pull request in c732558.

@RockingJavaBean RockingJavaBean deleted the fix_repeat_autograd_codegen branch July 2, 2020 00:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.dim() is not handled properly by the autograd codegen

5 participants