TensorIterator

v0 C++ Interface

class TensorIterator : public ngraph::op::util::FusedOp

Iterate a body over tensors, accumulating into tensors.

Public Functions

const NodeTypeInfo &get_type_info() const

Returns the NodeTypeInfo for the node’s class. During transition to type_info, returns a dummy type_info for Node if the class has not been updated yet.

void set_sliced_input(const std::shared_ptr<Parameter> &parameter, const Output<Node> &value, int64_t start, int64_t stride, int64_t part_size, int64_t end, int64_t axis)

Indicate that a body parameter comes from slices of a value.

Parameters
  • parameter: The parameter to receive the slices

  • value: The value to be sliced. This will be added as an input to TensorIterator.

  • start: First index on axis of the slicing

  • stride: Stepping of the slice

  • part_size: Size of the slice on axis

  • end: The last index on axis of the slicing

  • axis: The axis to slice along

void set_merged_input(const std::shared_ptr<Parameter> &body_parameter, const Output<Node> &initial_value, const Output<Node> &successive_value)

Indicates that a body parameter has an initial value in the first iteration and computed value thereafter.

Parameters
  • initial_value: Value for the parameter in first iteration. This will be added as an input to TensorIterator.

  • successive_value: Value for the parameter in successive iterations. The value is what is active in the most recent completed iteration.

void set_invariant_input(const std::shared_ptr<Parameter> &body_parameter, const Output<Node> &value)

Indicates that a body parameter has an invariant value during iteration that may depend on values computed outside of the iteration.

Parameters
  • body_parameter: The body parameter

  • value: The value supplied as an input to the block

Output<Node> get_iter_value(const Output<Node> &body_value, int64_t iteration)

Gets a value for a particular iteration point.

Parameters
  • body_value: The value

  • iteration: The iteration that supplies the value. Negative values are from the last iteration.

Output<Node> get_concatenated_slices(const Output<Node> &value, int64_t start, int64_t stride, int64_t part_size, int64_t end, int64_t axis)

Concatenates slices from all iterations.

Parameters
  • value: The value supplying slice values from each iteration.

  • start: First index on axis of the slicing

  • stride: Stepping of the slice

  • part_size: Size of the slice on axis

  • end: The last index on axis of the slicing

  • axis: The axis to slice along

NodeVector decompose_op() const

Decomposes the FusedOp into a sub-graph consisting of core ngraph ops.

Return

A vector of nodes comprising the sub-graph. The order of output tensors must match the match output tensors of the FusedOp

std::shared_ptr<BodyLambda> get_body() const

Return

the body of the iteration

void set_body(const std::shared_ptr<BodyLambda> &body)

Parameters
  • body: set the body of the iteration

const std::vector<std::shared_ptr<InputDescription>> &get_input_descriptions() const

Return

a reference to the input descriptions.

std::vector<std::shared_ptr<InputDescription>> &get_input_descriptions()

Return

a reference to the input descriptions. Can add input descriptions before validation.

const std::vector<std::shared_ptr<OutputDescription>> &get_output_descriptions() const

Return

a reference to the output descriptions.

std::vector<std::shared_ptr<OutputDescription>> &get_output_descriptions()

Return

a reference to the output descriptions. Can add output descriptions before validation.

virtual void validate_and_infer_types()

Throws if the node is invalid.

class BodyOutputDescription : public ngraph::op::v0::TensorIterator::OutputDescription

Produces an output from a specific iteration.

Public Functions

BodyOutputDescription(uint64_t body_value_index, uint64_t output_index, int64_t iteration)

Parameters
  • body_value_index: A body value that produces the output

  • output_index: The TensorIterator output index

  • iteration: which iteration (typically -1, final) will supply the value

class ConcatOutputDescription : public ngraph::op::v0::TensorIterator::OutputDescription

Produces an output by concatenating an output from each iteration.

Public Functions

ConcatOutputDescription(uint64_t body_value_index, uint64_t output_index, int64_t start, int64_t stride, int64_t part_size, int64_t end, int64_t axis)

Parameters
  • body_value_index: A body value that produces the output

  • output_index: The TensorIterator output index

  • start: First index for slices

  • stride: Step amount for slices

  • part_size: Width of slices

  • end: Last index for slices

  • axis: Axis being sliced

class InputDescription

Describes a connection between a TensorIterator input and the body.

Subclassed by ngraph::op::v0::TensorIterator::InvariantInputDescription, ngraph::op::v0::TensorIterator::MergedInputDescription, ngraph::op::v0::TensorIterator::SliceInputDescription

class MergedInputDescription : public ngraph::op::v0::TensorIterator::InputDescription

Describes a body input initialized from a TensorIterator input on the first iteration, and then a body output thereafter.

Public Functions

MergedInputDescription(uint64_t input_index, uint64_t body_parameter_index, uint64_t body_value_index)

Parameters
  • input_index: Position of the TensorIterator input supplying a value to body_parameter for the initial iteration.

  • body_parameter_index: Body parameter position to receive input.

  • body_value_index: Body value to supply body_parameter for successive iterations.

class OutputDescription

Describes how a TensorIterator output is produced from the body.

Subclassed by ngraph::op::v0::TensorIterator::BodyOutputDescription, ngraph::op::v0::TensorIterator::ConcatOutputDescription

class SliceInputDescription : public ngraph::op::v0::TensorIterator::InputDescription

Describes a body input formed from slices of an input to TensorIterator.

Public Functions

SliceInputDescription(uint64_t input_index, uint64_t body_parameter_index, int64_t start, int64_t stride, int64_t part_size, int64_t end, int64_t axis)

Parameters
  • input_index: Position of the TensorIterator input

  • body_parameter_index: Body parameter position to receive input

  • start: First index for slices

  • stride: Step amount for slices

  • part_size: Width of slices

  • end: Last index for slices

  • axis: Axis being sliced