GetShape

Description

Obtains the shapes of a tensor, including the storage and original shapes.

Prototype

const StorageShape &GetShape() const

StorageShape &GetShape()

Parameters

None

Returns

  • const StorageShape &GetShape() const: returns a read-only shape reference.
  • StorageShape &GetShape(): returns a shape reference.

For details about the definition of the StorageShape type, see StorageShape.

Restrictions

None

Example

StorageShape sh({1, 2, 3}, {2, 1, 3});
Tensor t = {sh, {ge::FORMAT_ND, ge::FORMAT_FRACTAL_NZ, {}}, kOnHost, ge::DT_FLOAT, nullptr};
auto shape = t.GetShape(); // sh