FormatMatchMode

Function Usage

Sets the format matching mode of the input and output tensors.

Prototype

OpDef &FormatMatchMode(FormatCheckOption option);

Parameters

Parameter

Input/Output

Description

option

Input

A parameter for configuring the matching mode, which is of the FormatCheckOption type. The following values are supported:

  • DEFAULT: The input and output data in NCHW/NHWC/DHWCN/NCDHW/NCL format is converted into ND format for processing.
  • STRICT: The data formats are strictly distinguished. The framework does not convert the data in NCHW/NHWC/DHWCN/NCDHW/NCL format.

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

 AddCustomC(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);
}