-
Couldn't load subscription status.
- Fork 5.9k
Let OpProto support multiple and temporary #2860
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
Let OpProto support multiple and temporary #2860
Conversation
* Each input/output of Paddle's Op could be a list. Add multiple mark to OpProto. Also add a `input_format`/`output_format` attribute if that Op has multiple input or output. The format of that attribute please reference the comments in `op_proto.proto` * Add temporary mark, because some output of an Op is not used by user but used by other op for faster computation. Explicitly mark which output is temporary could let future memory/computation optimization. * Add generated field to AttrProto.
1e8cc1e to 81b3437 Compare | The all input variables of this op is six, and they are segmented into three | ||
| inputs. | ||
| The first input is input[0:4], second is input[4:5], third is input[5:6]. |
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.
just 3 variable length inputs? why 3, no information about the op's input definition.
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.
That information is stored in OpProto because it is shared between all instances of the same types.
This PR does not touch C++ OperatorBase interface, but it is better for OperatorBase can get Input/Output information for that type.
paddle/framework/op_registry_test.cc Outdated
| : OpProtoAndCheckerMaker(proto, op_checker) { | ||
| AddInput("input", "input of cosine op"); | ||
| AddOutput("output", "output of cosine op"); | ||
| AddInput("input", "input of cosine op", /*multiple*/ true); |
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.
offer a AddInputs to repalce AddInput("input", true) ?
two methods to add inputs:
AddInputto add a normal inputAddInputsto add a variable length input
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.
Cool!
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.
Done.
| private: | ||
| void SetHasMultiple(const std::string& in_out, bool* flag) { | ||
| if (!*flag) { | ||
| AddAttr<std::vector<int>>(in_out + "_format", |
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.
each variable length input will has a input format ?
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.
The input_format is an attribute for that Op.
* It is more readable to invoke `AddInputs` not `AddInput(multiple=true)`.
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
| // } | ||
| // } | ||
| // | ||
| optional bool multiple = 3 [default=false]; |
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 repeated a better name?
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
OpProto. Also add a
input_format/output_formatattribute if thatOp has multiple input or output. The format of that attribute please
reference the comments in
op_proto.protobut used by other op for faster computation. Explicitly mark which
output is temporary could let future memory/computation optimization.