FormatMatchMode
Function
Sets the format matching mode of the input and output tensors.
Prototype
1 | OpDef &FormatMatchMode(FormatCheckOption option) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
option |
Input |
Matching mode configuration parameter, which is of the FormatCheckOption enumeration type. The following values are supported:
|
Returns
OpDef operator definition. For details, see OpDef.
Constraints
If this API is not called, the input and output data in NCHW/NHWC/DHWCN/NCDHW/NCL format is converted into ND format by default.
Example
In the following example, the input x of the AddCustom operator supports only the NCHW format, and the input y supports only the NHWC format. You need to set FormatMatchMode to FormatCheckOption::STRICT. If FormatMatchMode is not set, the aclnn framework converts the input to the ND format and passes it to the tiling operator.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | AddCustom(const char* name) : OpDef(name) { this->Input("x") .ParamType(REQUIRED) .DataType({ge::DT_FLOAT}) .FormatList({ge::FORMAT_NCHW}); this->Input("y") .ParamType(REQUIRED) .DataType({ge::DT_FLOAT}) .FormatList({ge::FORMAT_NHWC}); this->Output("z") .ParamType(REQUIRED) .DataType({ge::DT_FLOAT}) .FormatList({ge::FORMAT_ND}); this->AICore().SetTiling(optiling::TilingFunc); this->AICore().AddConfig("ascendxxx"); this->FormatMatchMode(FormatCheckOption::STRICT); } |
Parent topic: OpDef