Convolution

A convolution primitive performs 1D, 2D or 3D convolution. Supported variants are forward propagation, backward propagation, and weights gradient with or without bias.

API

struct dnnl::convolution_forward : public dnnl::primitive

Convolution forward propagation primitive.

Public Functions

convolution_forward()

Default constructor. Produces an empty object.

convolution_forward(const primitive_desc &pd)

Constructs a convolution forward propagation primitive.

Parameters
  • pd: Primitive descriptor for a convolution forward propagation primitive.

struct desc

Descriptor for a convolution forward propagation primitive.

Public Functions

desc(prop_kind prop_kind, algorithm algorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a convolution forward propagation primitive with bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters

desc(prop_kind prop_kind, algorithm algorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a convolution forward propagation primitive without bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters

desc(prop_kind prop_kind, algorithm algorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a dilated convolution forward propagation primitive with bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters

desc(prop_kind prop_kind, algorithm algorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a dilated convolution forward propagation primitive without bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters

struct primitive_desc : public dnnl::primitive_desc

Primitive descriptor for a convolution forward propagation primitive.

Public Functions

primitive_desc()

Default constructor. Produces an empty object.

primitive_desc(const desc &desc, const engine &engine, bool allow_empty = false)

Constructs a primitive descriptor for a convolution forward propagation primitive.

Parameters
  • desc: Descriptor for a convolution forward propagation primitive.

  • engine: Engine to use.

  • allow_empty: A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.

primitive_desc(const desc &desc, const primitive_attr &attr, const engine &engine, bool allow_empty = false)

Constructs a primitive descriptor for a convolution forward propagation primitive.

Parameters
  • desc: Descriptor for a convolution forward propagation primitive.

  • engine: Engine to use.

  • attr: Primitive attributes to use.

  • allow_empty: A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.

memory::desc src_desc() const

Returns a source memory descriptor.

Return

Source memory descriptor.

Return

A zero memory descriptor if the primitive does not have a source parameter.

memory::desc weights_desc() const

Returns a weights memory descriptor.

Return

Weights memory descriptor.

Return

A zero memory descriptor if the primitive does not have a weights parameter.

memory::desc dst_desc() const

Returns a destination memory descriptor.

Return

Destination memory descriptor.

Return

A zero memory descriptor if the primitive does not have a destination parameter.

memory::desc bias_desc() const

Returns the bias memory descriptor.

Return

The bias memory descriptor.

Return

A zero memory descriptor of the primitive does not have a bias parameter.

struct dnnl::convolution_backward_data : public dnnl::primitive

Convolution backward propagation primitive.

Public Functions

convolution_backward_data()

Default constructor. Produces an empty object.

convolution_backward_data(const primitive_desc &pd)

Constructs a convolution backward propagation primitive.

Parameters
  • pd: Primitive descriptor for a convolution backward propagation primitive.

struct desc

Descriptor for a convolution backward propagation primitive.

Public Functions

desc(algorithm algorithm, const memory::desc &diff_src_desc, const memory::desc &weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a convolution backward propagation primitive.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters
  • algorithm: Convolution algorithm. Possible values are dnnl::algorithm::convolution_direct, dnnl::algorithm::convolution_winograd, and dnnl::algorithm::convolution_auto.

  • diff_src_desc: Diff source memory descriptor.

  • weights_desc: Weights memory descriptor.

  • diff_dst_desc: Diff destination memory descriptor.

  • strides: Strides for each spatial dimension.

  • padding_l: Vector of padding values for low indices for each spatial dimension (front, top, left).

  • padding_r: Vector of padding values for high indices for each spatial dimension (back, bottom, right).

desc(algorithm algorithm, const memory::desc &diff_src_desc, const memory::desc &weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for dilated convolution backward propagation primitive.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters
  • algorithm: Convolution algorithm. Possible values are dnnl::algorithm::convolution_direct, dnnl::algorithm::convolution_winograd, and dnnl::algorithm::convolution_auto.

  • diff_src_desc: Diff source memory descriptor.

  • weights_desc: Weights memory descriptor.

  • diff_dst_desc: Diff destination memory descriptor.

  • strides: Strides for each spatial dimension.

  • dilates: Dilations for each spatial dimension. A zero value means no dilation in the corresponding dimension.

  • padding_l: Vector of padding values for low indices for each spatial dimension (front, top, left).

  • padding_r: Vector of padding values for high indices for each spatial dimension (back, bottom, right).

struct primitive_desc : public dnnl::primitive_desc

Primitive descriptor for a convolution backward propagation primitive.

Public Functions

primitive_desc()

Default constructor. Produces an empty object.

primitive_desc(const desc &desc, const engine &engine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)

Constructs a primitive descriptor for a convolution backward propagation primitive.

Parameters
  • desc: Descriptor for a convolution backward propagation primitive.

  • engine: Engine to perform the operation on.

  • hint_fwd_pd: Primitive descriptor for a convolution forward propagation primitive. It is used as a hint for deciding which memory format to use.

  • allow_empty: A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.

primitive_desc(const desc &desc, const primitive_attr &attr, const engine &engine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)

Constructs a primitive descriptor for a convolution backward propagation primitive.

Parameters
  • desc: Descriptor for a convolution backward propagation primitive.

  • engine: Engine to perform the operation on.

  • attr: Primitive attributes to use.

  • hint_fwd_pd: Primitive descriptor for a convolution forward propagation primitive. It is used as a hint for deciding which memory format to use.

  • allow_empty: A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.

memory::desc diff_src_desc() const

Returns a diff source memory descriptor.

Return

Diff source memory descriptor.

Return

A zero memory descriptor if the primitive does not have a diff source memory with.

memory::desc weights_desc() const

Returns a weights memory descriptor.

Return

Weights memory descriptor.

Return

A zero memory descriptor if the primitive does not have a weights parameter.

memory::desc diff_dst_desc() const

Returns a diff destination memory descriptor.

Return

Diff destination memory descriptor.

Return

A zero memory descriptor if the primitive does not have a diff destination parameter.

struct dnnl::convolution_backward_weights : public dnnl::primitive

Convolution weights gradient primitive.

Public Functions

convolution_backward_weights()

Default constructor. Produces an empty object.

convolution_backward_weights(const primitive_desc &pd)

Constructs a convolution weights gradient primitive.

Parameters
  • pd: Primitive descriptor for a convolution weights gradient primitive.

struct desc

Descriptor for a convolution weights gradient primitive.

Public Functions

desc(algorithm algorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a convolution weights gradient primitive with bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters
  • algorithm: Convolution algorithm. Possible values are dnnl::algorithm::convolution_direct, dnnl::algorithm::convolution_winograd, and dnnl::algorithm::convolution_auto.

  • src_desc: Source memory descriptor.

  • diff_weights_desc: Diff weights memory descriptor.

  • diff_bias_desc: Diff bias memory descriptor. Passing zero memory descriptor disables the bias term.

  • diff_dst_desc: Diff destination memory descriptor.

  • strides: Strides for each spatial dimension.

  • padding_l: Vector of padding values for low indices for each spatial dimension (front, top, left).

  • padding_r: Vector of padding values for high indices for each spatial dimension (back, bottom, right).

desc(algorithm algorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a convolution weights gradient primitive without bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters
  • algorithm: Convolution algorithm. Possible values are dnnl::algorithm::convolution_direct, dnnl::algorithm::convolution_winograd, and dnnl::algorithm::convolution_auto.

  • src_desc: Source memory descriptor.

  • diff_weights_desc: Diff weights memory descriptor.

  • diff_dst_desc: Diff destination memory descriptor.

  • strides: Strides for each spatial dimension.

  • padding_l: Vector of padding values for low indices for each spatial dimension (front, top, left).

  • padding_r: Vector of padding values for high indices for each spatial dimension (back, bottom, right).

desc(algorithm algorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a dilated convolution weights gradient primitive with bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters
  • algorithm: Convolution algorithm. Possible values are dnnl::algorithm::convolution_direct, dnnl::algorithm::convolution_winograd, and dnnl::algorithm::convolution_auto.

  • src_desc: Source memory descriptor.

  • diff_weights_desc: Diff weights memory descriptor.

  • diff_bias_desc: Diff bias memory descriptor. Passing zero memory descriptor disables the bias term.

  • diff_dst_desc: Diff destination memory descriptor.

  • strides: Strides for each spatial dimension.

  • dilates: Dilations for each spatial dimension. A zero value means no dilation in the corresponding dimension.

  • padding_l: Vector of padding values for low indices for each spatial dimension (front, top, left).

  • padding_r: Vector of padding values for high indices for each spatial dimension (back, bottom, right).

desc(algorithm algorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)

Constructs a descriptor for a dilated convolution weights gradient primitive without bias.

Inputs:

Outputs:

Note

All the memory descriptors may be initialized with the dnnl::memory::format_tag::any value of format_tag.

Parameters
  • algorithm: Convolution algorithm. Possible values are dnnl::algorithm::convolution_direct, dnnl::algorithm::convolution_winograd, and dnnl::algorithm::convolution_auto.

  • src_desc: Source memory descriptor.

  • diff_weights_desc: Diff weights memory descriptor.

  • diff_dst_desc: Diff destination memory descriptor.

  • strides: Strides for each spatial dimension.

  • dilates: Dilations for each spatial dimension. A zero value means no dilation in the corresponding dimension.

  • padding_l: Vector of padding values for low indices for each spatial dimension (front, top, left).

  • padding_r: Vector of padding values for high indices for each spatial dimension (back, bottom, right).

struct primitive_desc : public dnnl::primitive_desc

Primitive descriptor for a convolution weights gradient primitive.

Public Functions

primitive_desc()

Default constructor. Produces an empty object.

primitive_desc(const desc &desc, const engine &engine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)

Constructs a primitive descriptor for a convolution weights gradient primitive.

Parameters
  • desc: Descriptor for a convolution weights gradient primitive.

  • engine: Engine to use.

  • hint_fwd_pd: Primitive descriptor for a convolution forward propagation primitive. It is used as a hint for deciding which memory format to use.

  • allow_empty: A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.

primitive_desc(const desc &desc, const primitive_attr &attr, const engine &engine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty = false)

Constructs a primitive descriptor for a convolution weights gradient primitive.

Parameters
  • desc: Descriptor for a convolution weights gradient primitive.

  • attr: Primitive attributes to use.

  • engine: Engine to use.

  • hint_fwd_pd: Primitive descriptor for a convolution forward propagation primitive. It is used as a hint for deciding which memory format to use.

  • allow_empty: A flag signifying whether construction is allowed to fail without throwing an exception. In this case an empty object will be produced. This flag is optional and defaults to false.

memory::desc src_desc() const

Returns a source memory descriptor.

Return

Source memory descriptor.

Return

A zero memory descriptor if the primitive does not have a source parameter.

memory::desc diff_weights_desc() const

Returns a diff weights memory descriptor.

Return

Diff weights memory descriptor.

Return

A zero memory descriptor if the primitive does not have a diff weights parameter.

memory::desc diff_dst_desc() const

Returns a diff destination memory descriptor.

Return

Diff destination memory descriptor.

Return

A zero memory descriptor if the primitive does not have a diff destination parameter.

memory::desc diff_bias_desc() const

Returns the diff bias memory descriptor.

Return

The diff bias memory descriptor.

Return

A zero memory descriptor of the primitive does not have a diff bias parameter.