Reorder

A primitive to copy data between two memory objects. This primitive is typically used to change the way that the data is laid out in memory.

API

struct dnnl::reorder : public dnnl::primitive

Reorder primitive.

Public Functions

reorder()

Default constructor. Produces an empty object.

reorder(const primitive_desc &pd)

Constructs a reorder primitive.

Parameters
  • pd: Primitive descriptor for reorder primitive.

reorder(const memory &src, const memory &dst, const primitive_attr &attr = primitive_attr())

Constructs a reorder primitive that would reorder data between memory objects having the same memory descriptors as memory objects src and dst.

Parameters
  • src: Source memory object.

  • dst: Destination memory object.

  • attr: Primitive attributes to use (optional).

void execute(const stream &stream, memory &src, memory &dst) const

Executes the reorder primitive.

Parameters
  • stream: Stream object. The stream must belong to the same engine as the primitive.

  • src: Source memory object.

  • dst: Destination memory object.

cl::sycl::event execute_sycl(const stream &stream, memory &src, memory &dst, const std::vector<cl::sycl::event> &deps = {}) const

Executes the reorder primitive (SYCL-aware version)

Return

SYCL event that corresponds to the SYCL queue underlying the stream.

Parameters
  • stream: Stream object. The stream must belong to the same engine as the primitive.

  • src: Source memory object.

  • dst: Destination memory object.

  • deps: Vector of SYCL events that the execution should depend on.

struct primitive_desc : public dnnl::primitive_desc_base

Primitive descriptor for a reorder primitive.

Public Functions

primitive_desc()

Default constructor. Produces an empty object.

primitive_desc(const engine &src_engine, const memory::desc &src_md, const engine &dst_engine, const memory::desc &dst_md, const primitive_attr &attr = primitive_attr())

Constructs a primitive descriptor for reorder primitive.

Inputs:

Outputs:

Parameters
  • src_engine: Engine on which the source memory object will be located.

  • src_md: Source memory descriptor.

  • dst_engine: Engine on which the destination memory object will be located.

  • dst_md: Destination memory descriptor.

  • attr: Primitive attributes to use (optional).

primitive_desc(const memory &src, const memory &dst, const primitive_attr &attr = primitive_attr())

Constructs a primitive descriptor for reorder primitive.

Parameters
  • src: Source memory object. It is used to obtain the source memory descriptor and engine.

  • dst: Destination memory object. It is used to obtain the destination memory descriptor and engine.

  • attr: Primitive attributes to use (optional).

engine get_src_engine() const

Returns the engine on which the source memory is allocated.

Return

The engine on which the source memory is allocated.

engine get_dst_engine() const

Returns the engine on which the destination memory is allocated.

Return

The engine on which the destination memory is allocated.

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