Skip to content

Conversation

@lara-hdr
Copy link
Contributor

No description provided.

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.

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

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

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

Could you add test cases?

@lara-hdr
Copy link
Contributor Author

Caffe2 does not have an operator Scatter, but has ScatterAssign defined in utility_ops (that enforces in place operations). Will I have to add a new operator Scatter?

@houseroad
Copy link
Member

houseroad commented Mar 29, 2019

Yeah, they are quite different. I would suggest to add a new Scatter operator then.

@houseroad houseroad requested a review from xiaomengy April 2, 2019 21:58
@houseroad
Copy link
Member

cc: @BIT-silence for the scatter op part.

@houseroad
Copy link
Member

@lara-hdr could you address the comments from @BIT-silence ?

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.

@houseroad 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.

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

@lara-hdr
Copy link
Contributor Author

@houseroad conflicts are solved in this PR :)

@lara-hdr
Copy link
Contributor Author

lara-hdr commented May 8, 2019

@houseroad, comments on this PR?

@pytorchbot pytorchbot added caffe2 module: onnx Related to torch.onnx labels May 14, 2019
@lara-hdr
Copy link
Contributor Author

@houseroad updates on this?

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.

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


bool RunOnDevice() override {
return DispatchHelper<TensorTypes<int32_t, int64_t>>::call(
this, this->template Input<Tensor>(INDICES, CPU));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we fix CPU here?

Copy link
Member

Choose a reason for hiding this comment

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

I would suggest to provide better information here, if the tensor is on some devices other than CPU. To explicitly tell them, Scatter only supports CPU at the moment. :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is a CPU only op, why not remove template Context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a check on the device type, and changed Operator to Operator.

OP_SINGLE_ARG(int, "axis", axis_, 1) {
}

virtual ~ScatterOp() noexcept {}
Copy link
Member

Choose a reason for hiding this comment

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

In file included from caffe2/caffe2/operators/utility_ops.cc:1:
caffe2/caffe2/operators/utility_ops.h:752:11: warning: '~ScatterOp' overrides a destructor but is not marked 'override'

virtual ~ScatterOp() noexcept {}
        ^
caffe2/c10/util/Type.h:19:56: note: in instantiation of template class 'caffe2::ScatterOp<caffe2::CPUContext>' requested here
  static const auto& name = *(new std::string(demangle(typeid(T).name())));
                                                       ^
caffe2/caffe2/operators/utility_ops.cc:54:1: note: in instantiation of function template specialization 'c10::demangle_type<caffe2::ScatterOp<caffe2::CPUContext> >' requested here
REGISTER_CPU_OPERATOR(Scatter, ScatterOp<CPUContext>);
^
caffe2/caffe2/core/operator.h:1257:3: note: expanded from macro 'REGISTER_CPU_OPERATOR'
  C10_REGISTER_CLASS(CPUOperatorRegistry, name, __VA_ARGS__)
  ^
caffe2/c10/util/Registry.h:291:3: note: expanded from macro 'C10_REGISTER_CLASS'
  C10_REGISTER_TYPED_CLASS(RegistryName, #key, __VA_ARGS__)
  ^
caffe2/c10/util/Registry.h:251:14: note: expanded from macro 'C10_REGISTER_TYPED_CLASS'
      ::c10::demangle_type<__VA_ARGS__>());
             ^
caffe2/caffe2/core/operator.h:751:3: note: overridden virtual function is here
  ~Operator() noexcept override {}
  ^

Copy link
Member

Choose a reason for hiding this comment

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

please address this comment as well, thanks.

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.

@houseroad 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.

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

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.



@parse_args('v', 'i', 'v', 'v')
def scatter_add(g, self, dim, index, src):
Copy link
Member

Choose a reason for hiding this comment

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

Add a test?

@facebook-github-bot
Copy link
Contributor

@houseroad merged this pull request in 8d7a025.

@houseroad
Copy link
Member

Feel free to add a test for scatter_add in a different PR, since this one is already closed. :-)

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants