73 std::optional<size_t>
axis;
98 std::vector<DataDimension>
axes;
107 [[nodiscard]]
size_t rank() const noexcept {
return shape.size(); }
110 [[nodiscard]] std::optional<uint64_t> element_count() const noexcept;
113 [[nodiscard]]
bool is_contiguous() const noexcept;
116 [[nodiscard]]
std::vector<int64_t> resolved_strides() const;
122 [[nodiscard]]
std::optional<
std::pair<uint64_t, uint64_t>> byte_range() const noexcept;
125 [[nodiscard]]
std::
string diagnose() const;
131 [[nodiscard]] std::vector<DataDimension> dimensions()
const;
142 [[nodiscard]] std::optional<TensorSpec> window(
143 std::span<const uint64_t> origin, std::span<const uint64_t> extent)
const;
154 [[nodiscard]] std::optional<TensorSpec> window(
const Region& region)
const;
TensorDeviceType
Where tensor memory lives.
Represents a point or span in N-dimensional space.
Element type as kind, bit width and lane count.
constexpr bool is_host_accessible() const noexcept
Whether the host can read this memory directly.
constexpr bool operator==(const TensorDevice &) const noexcept=default
Device type and ordinal holding a tensor's memory.
std::optional< size_t > axis
std::vector< double > scale
std::vector< int64_t > zero_point
Affine quantization: real = scale * (stored - zero_point).
size_t rank() const noexcept
Number of dimensions.
std::vector< DataDimension > axes
std::string diagnose() const
Empty when the spec is self-consistent, otherwise the reason it is not.
std::optional< TensorQuantization > quantization
std::vector< int64_t > strides
static TensorSpec contiguous(TensorDType dtype, std::vector< uint64_t > shape, std::string name={})
C-ordered spec with no offset, axes or quantization.
bool is_valid() const
Whether diagnose() reports no problem.
std::vector< uint64_t > shape
Complete description of a tensor: type, shape, layout, meaning.