Skip to content

Commit

Permalink
Simplify macros for exposing c10 ops to c2 (#17781)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch/pytorch#17781

The wrapper for calling a c10 operator from caffe2 is now based on a runtime FunctionSchema instead of compile time information. This way, it can be created for any c10 operator schema with just one invocation to a simple macro instead of having to define arguments and more as compile time structures.

Furthermore, previously, the wrapper assumed there's an argument present for preallocated outputs, but that was only true for caffe2 operators exported to c10. So the wrapper only worked correctly for calling caffe2->c10->caffe2. Now with the new implementation, it works for any c10 operator.

Also, binary size for this should be much smaller.

Reviewed By: ezyang

Differential Revision: D14375054

fbshipit-source-id: bac7ab8e63929e6e2a148eacac41ed092009aa86
  • Loading branch information
smessmer authored and facebook-github-bot committed Mar 14, 2019
1 parent 0fc3386 commit 135d683
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aten/src/ATen/core/function_schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct Argument {
c10::optional<int32_t> N() const {
return N_;
}
c10::optional<IValue> default_value() const {
const c10::optional<IValue>& default_value() const {
return default_value_;
}
bool kwarg_only() const {
Expand Down

0 comments on commit 135d683

Please sign in to comment.