# ShapeOf¶

ShapeOf  // Operation that returns the shape of its input tensor


## Description¶

Warning

This op is experimental and subject to change without notice.

Returns the shape of its input argument as a tensor of element type u64.

### Inputs¶

Name Element Type Shape
arg Any Any

### Outputs¶

Name Element Type Shape
output element::u64 {r} where r is the rank of arg’s shape.

## Mathematical Definition¶

$\mathtt{output} = \mathtt{shapeof}(\mathtt{arg})$

## C++ Interface¶

class ShapeOf : public ngraph::op::Op

Operation that returns the shape of its input argument as a tensor.

Public Functions

ShapeOf(const std::shared_ptr<Node> &arg)

Constructs a shape-of operation.

std::vector<std::shared_ptr<op::Constant>> as_constants() const

Produce a vector of constant nodes (one for each of this node’s outputs) that can replace this node’s outputs. May return an empty vector to signal that conversion to constants is not possible or not supported.

Conversion does not have to be complete. That means that subclasses *may* override as_constants, but do not have to. It is allowed for as_constants to return an empty vector even in cases where the output values are statically computable. Thus, any user of as_constants must allow for the possibility that conversion will fail (i.e., as_constants will return {}).

Return
If conversion is successful, a vector of op::Constant nodes, corresponding to this node’s outputs in order. If unsuccessful, an empty vector.

Conversion must be sound. That means that if as_constants returns a non-empty vector, the value of each constant in the vector must be exactly the value that would have been returned for the corresponding output at runtime.