Specifies that the data type, format, and shape of the current input or output are the same as those of a previously defined input.
OpParamDef &Follow(const char *paramName); OpParamDef &Follow(const char *paramName, FollowType ftype);
| 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: - ALL: The data type, format, and shape are the same as those of paramName. - DTYPE: The data type is the same as that of paramName. - FORMAT: The format is the same as that of paramName. - SHAPE: The shape is the same as that of paramName. |
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-type 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. Otherwise, the InferShape function should be preferred. Ensure that all output shapes can be inferred from the InferShape function.
If the output y1 follows the input x1, the data type, format, and shape of y1 are the same as those of x1.
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")
.OutputShapeDependOnCompute();