Binary

A primitive to perform tensor operations over two tensors.

API

struct dnnl::binary : public dnnl::primitive

Elementwise binary operator primitive.

Public Functions

binary()

Default constructor. Produces an empty object.

binary(const primitive_desc &pd)

Constructs an elementwise binary operation primitive.

Parameters
  • pd: Primitive descriptor for an elementwise binary operation primitive.

struct desc

Descriptor for an elementwise binary operator primitive.

Public Functions

desc(algorithm algorithm, const memory::desc &src0, const memory::desc &src1, const memory::desc &dst)

Constructs a descriptor for an elementwise binary operator primitive.

Inputs:

Outputs:

Parameters
  • algorithm: Elementwise algorithm.

  • src0: Memory descriptor for source tensor #0.

  • src1: Memory descriptor for source tensor #1.

  • dst: Memory descriptor for destination tensor.

struct primitive_desc : public dnnl::primitive_desc

Primitive descriptor for an elementwise binary operator 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 an elementwise binary operator primitive.

Parameters
  • desc: Descriptor for an elementwise binary operator 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 an elementwise binary operator primitive.

Parameters
  • desc: Descriptor for an elementwise binary operator 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(int idx = 0) const

Returns a source memory descriptor.

Return

Source memory descriptor.

Return

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

Parameters
  • idx: Source index.

memory::desc src0_desc() const

Returns the memory descriptor for source #0.

memory::desc src1_desc() const

Returns the memory descriptor for source #1.

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.