Sum

A primitive to sum multiple tensors.

API

struct dnnl::sum : public dnnl::primitive

Out-of-place summation (sum) primitive.

Public Functions

sum()

Default constructor. Produces an empty object.

sum(const primitive_desc &pd)

Constructs a sum primitive.

Parameters
  • pd: Primitive descriptor for sum primitive.

struct primitive_desc : public dnnl::primitive_desc_base

Primitive descriptor for a sum primitive.

Public Functions

primitive_desc()

Default constructor. Produces an empty object.

primitive_desc(const memory::desc &dst, const std::vector<float> &scales, const std::vector<memory::desc> &srcs, const engine &engine, const primitive_attr &attr = primitive_attr())

Constructs a primitive descriptor for a sum primitive.

Inputs:

Outputs:

Parameters
  • dst: Destination memory descriptor.

  • scales: Vector of scales to multiply data in each source memory by.

  • srcs: Vector of source memory descriptors.

  • engine: Engine to perform the operation on.

  • attr: Primitive attributes to use (optional).

primitive_desc(const std::vector<float> &scales, const std::vector<memory::desc> &srcs, const engine &engine, const primitive_attr &attr = primitive_attr())

Constructs a primitive descriptor for a sum primitive.

This version derives the destination memory descriptor automatically.

Parameters
  • scales: Vector of scales by which to multiply data in each source memory object.

  • srcs: Vector of source memory descriptors.

  • engine: Engine on which to perform the operation.

  • attr: Primitive attributes to use (optional).

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 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.