Skip to main content

ClikaRT::ops::shape

function

2 overloads.

shape(Tensor, optional<int64_t>)

Tensor shape(Tensor x, std::optional<int64_t> dim = std::nullopt)

The tensor's shape as a 1-D Int64 tensor (or one extent as 0-D).

The value is produced ON DEVICE and is traceable; under tracing it carries the symbolic value. For a plain host integer use the *_host sibling instead. With dim set, returns that single extent as a 0-D Int64 tensor (negative dim counts from the end).

Throws

  • ClikaRT::Error: when dim is out of range (code_name() carries the reason).

Returns: [ndim] Int64, or 0-D Int64 with dim set.

Declared in ClikaRT/compute/ops.h, line 3060

shape(Tensor, optional<int64_t>, optional<int64_t>)

Tensor shape(
    Tensor x,
    std::optional<std::int64_t> start,
    std::optional<std::int64_t> end
)

The [start, end) window of the shape as ONE 1-D Int64 tensor, a contiguous dim range in a single call (Python-slice bounds: negative values count from the end, std::nullopt leaves that side open). Same on-device, traceable contract as shape(x); the host-integer sibling is shape_host(x, start, end).

Throws

  • ClikaRT::Error: (INVALID_ARGUMENT) when the window is out of range (code_name() carries the reason).

Returns: [end - start] Int64 (empty when the window is empty).

Declared in ClikaRT/compute/ops.h, line 3070