OutputShapeDependOnCompute
Function Usage
Identifies whether the output shape of an operator depends on computation. For NonZero (counting the number of non-zero values in a tensor), the output shape information of the operator cannot be obtained before the computation is complete. When defining the prototype of this type of operator, you need to use the OutputShapeDependOnCompute API to identify the operator, and write the actual output shape to the output parameter in the operator kernel function so that the framework can manage the output memory based on the information. For details about the implementation on the kernel, see Implementing Operator Whose Output Shape Depends on Computation on the Kernel.
Prototype
OpParamDef &OutputShapeDependOnCompute();
Parameters
None
Returns
OpParamDef operator definition. For details, see OpParamDef.
Constraints
- This API can only be used to identify the operator output.
- Currently, integrating operators into a graph is not supported.
Example
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)
.DataType({ge::DT_FLOAT, ge::DT_FLOAT})
.Format({ge::FORMAT_ND, ge::FORMAT_ND})
.OutputShapeDependOnCompute();