DML_BATCH_NORMALIZATION_OPERATOR_DESC structure (directml.h)

Performs a batch normalization on the input. This operator performs the following computation: Output = FusedActivation(Scale * ((Input - Mean) / sqrt(Variance + Epsilon)) + Bias).

Any dimension in MeanTensor, VarianceTensor, ScaleTensor, and BiasTensor can be set to 1, and be automatically broadcast to match InputTensor, but otherwise must equal the corresponding dimension's size from InputTensor.

Syntax

struct DML_BATCH_NORMALIZATION_OPERATOR_DESC {
  const DML_TENSOR_DESC   *InputTensor;
  const DML_TENSOR_DESC   *MeanTensor;
  const DML_TENSOR_DESC   *VarianceTensor;
  const DML_TENSOR_DESC   *ScaleTensor;
  const DML_TENSOR_DESC   *BiasTensor;
  const DML_TENSOR_DESC   *OutputTensor;
  BOOL                    Spatial;
  FLOAT                   Epsilon;
  const DML_OPERATOR_DESC *FusedActivation;
};

Members

InputTensor

Type: const DML_TENSOR_DESC*

A tensor containing the Input data.

MeanTensor

Type: const DML_TENSOR_DESC*

A tensor containing the Mean data.

VarianceTensor

Type: const DML_TENSOR_DESC*

A tensor containing the Variance data.

ScaleTensor

Type: const DML_TENSOR_DESC*

A tensor containing the Scale data.

BiasTensor

Type: const DML_TENSOR_DESC*

A tensor containing the Bias data.

OutputTensor

Type: const DML_TENSOR_DESC*

A tensor to write the results to.

Spatial

Type: BOOL

TRUE to specify that locations are spatial, otherwise FALSE. Setting this to FALSE will require the Width and Height dimensions of MeanTensor and VarianceTensor to not be broadcast. This parameter was deprecated in DML_FEATURE_LEVEL_4_0, and has no effect.

Epsilon

Type: FLOAT

The epsilon value to use to avoid division by zero.

FusedActivation

Type: _Maybenull_ const DML_OPERATOR_DESC*

An optional fused activation layer to apply after the normalization. For more info, see Using fused operators for improved performance.

Availability

This operator was introduced in DML_FEATURE_LEVEL_1_0.

Tensor constraints

  • BiasTensor, InputTensor, MeanTensor, OutputTensor, ScaleTensor, and VarianceTensor must have the same DataType and DimensionCount.
  • InputTensor and OutputTensor must have the same Sizes.

Tensor support

DML_FEATURE_LEVEL_3_1 and above

Tensor Kind Dimensions Supported dimension counts Supported data types
InputTensor Input { InputDimensions[] } 1 to 8 FLOAT32, FLOAT16
MeanTensor Input { MeanDimensions[] } 1 to 8 FLOAT32, FLOAT16
VarianceTensor Input { VarianceDimensions[] } 1 to 8 FLOAT32, FLOAT16
ScaleTensor Input { ScaleDimensions[] } 1 to 8 FLOAT32, FLOAT16
BiasTensor Input { BiasDimensions[] } 1 to 8 FLOAT32, FLOAT16
OutputTensor Output { InputDimensions[] } 1 to 8 FLOAT32, FLOAT16

DML_FEATURE_LEVEL_1_0 and above

Tensor Kind Dimensions Supported dimension counts Supported data types
InputTensor Input { InputDimensions[] } 4 FLOAT32, FLOAT16
MeanTensor Input { MeanDimensions[] } 4 FLOAT32, FLOAT16
VarianceTensor Input { VarianceDimensions[] } 4 FLOAT32, FLOAT16
ScaleTensor Input { ScaleDimensions[] } 4 FLOAT32, FLOAT16
BiasTensor Input { BiasDimensions[] } 4 FLOAT32, FLOAT16
OutputTensor Output { InputDimensions[] } 4 FLOAT32, FLOAT16

Requirements

Requirement Value
Header directml.h

See also