Follow
Function
Specifies that the data type, format, and shape of the current input or output are the same as those of a previously defined input.
Prototype
- All the data type, format, and shape information must be the same.
1OpParamDef &Follow(const char *paramName)
- The data type, format, and shape specific information must be the same.
1OpParamDef &Follow(const char *paramName, FollowType ftype)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
paramName |
Input |
Input name that has been defined. |
ftype |
Input |
Enumeration type of FollowType, indicating the follow type. The options are as follows:
|
Returns
OpParamDef operator definition. For details, see OpParamDef.
Constraints
- The data source of Follow can only be input.
- For shape inference, an input parameter can only be followed by an output parameter rather than another input parameter.
- Chain-style follow is supported. For example, C follows B, and B follows A. However, the follow type cannot be changed (ftype must be consistent) during the process.
- The Follow API has simpler logic than the InferShape function. Using the Follow API is recommended so that you do not have to register the InferShape function.
- The InferShape function and the Follow API cannot be used together. If they are used together, the InferShape function prevails. Ensure that all output shapes can be inferred from the InferShape function.
- The input parameter type of Follow can also be DataTypeList or FormatList After the Follow API is called, the data type/format of the current input/output is the same as that of combined paramName.
Examples
- If the output y1 follows the input x1, the data type, format, and shape of y1 are the same as those of x1.
1 2 3 4 5 6 7 8 9 10 11
this->Input("x1") .ParamType(REQUIRED) .DataType({ge::DT_FLOAT, ge::DT_FLOAT}) .Format({ge::FORMAT_ND, ge::FORMAT_ND}); this->Input("x2") .ParamType(REQUIRED) .DataType({ge::DT_FLOAT, ge::DT_FLOAT}) .Format({ge::FORMAT_ND, ge::FORMAT_ND}); this->Output("y1") .ParamType(REQUIRED) .Follow("x1");
- In the chain follow scenario, the sequence is y1 -> x2 -> x1. In this case, the data type, format, and shape of y1 are the same as those of x1, and the data type and format of x2 are the same as those of x1.
1 2 3 4 5 6 7 8 9 10
this->Input("x1") .ParamType(REQUIRED) .DataType({ge::DT_FLOAT, ge::DT_FLOAT}) .Format({ge::FORMAT_ND, ge::FORMAT_ND}); this->Input("x2") .ParamType(REQUIRED) .Follow("x1"); this->Output("y1") .ParamType(REQUIRED) .Follow("x2");
Parent topic: OpParamDef