-
Notifications
You must be signed in to change notification settings - Fork 26.3k
ONNX Export Scatter #18543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ONNX Export Scatter #18543
Conversation
facebook-github-bot
left a comment
There was a problem hiding this 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.
houseroad
left a comment
There was a problem hiding this 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?
|
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? |
|
Yeah, they are quite different. I would suggest to add a new Scatter operator then. |
|
cc: @BIT-silence for the scatter op part. |
|
@lara-hdr could you address the comments from @BIT-silence ? |
facebook-github-bot
left a comment
There was a problem hiding this 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.
facebook-github-bot
left a comment
There was a problem hiding this 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.
|
@houseroad conflicts are solved in this PR :) |
|
@houseroad, comments on this PR? |
|
@houseroad updates on this? |
facebook-github-bot
left a comment
There was a problem hiding this 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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. :-)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
caffe2/operators/utility_ops.h
Outdated
| OP_SINGLE_ARG(int, "axis", axis_, 1) { | ||
| } | ||
|
|
||
| virtual ~ScatterOp() noexcept {} |
There was a problem hiding this comment.
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 {}
^
There was a problem hiding this comment.
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.
facebook-github-bot
left a comment
There was a problem hiding this 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.
facebook-github-bot
left a comment
There was a problem hiding this 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.
houseroad
left a comment
There was a problem hiding this 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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test?
|
@houseroad merged this pull request in 8d7a025. |
|
Feel free to add a test for |
No description provided.