Skip to main content

TensorConstraint Struct

Declarative tensor contract — describes the shape/dtype/device/format a tensor must satisfy. More...

Declaration

struct simaai::neat::TensorConstraint { ... }

Included Headers

#include <TensorSpec.h>

Public Member Functions Index

boolmatches (const Tensor &t) const

Returns true if t satisfies every non-empty constraint in this spec. More...

Public Member Attributes Index

std::vector< simaai::neat::TensorDType >dtypes

Acceptable dtypes (empty = any). More...

intrank = -1

Required rank (-1 = any). More...

std::vector< int64_t >shape

Required shape; -1 in any position means dynamic. More...

std::optional< Device >device

Required device (empty = any). More...

std::vector< Device >allowed_devices

Acceptable devices (empty = any). More...

std::optional< Device >preferred_device

Preferred device for placement (informational). More...

std::optional< ImageSpec::PixelFormat >image_format

Required image pixel format (only meaningful for image tensors). More...

std::vector< Segment >required_segments

Exact required memory-segment layout (advanced). More...

std::vector< std::string >required_segment_names

Required memory-segment names (must all be present). More...

boolallow_composite = true

If false, reject composite (multi-plane) tensors like NV12. More...

Description

Declarative tensor contract — describes the shape/dtype/device/format a tensor must satisfy.

Used by Model::input_specs()/output_specs() to advertise what the model expects/produces, and by validation code to verify a tensor meets the contract via matches(). Empty fields mean "no constraint on this dimension." Use -1 in shape for dynamic axes.

 sima::TensorConstraint c;
 c.dtypes = { sima::TensorDType::Float32, sima::TensorDType::BFloat16 };
 c.rank = 4;
 c.shape = { 1, 3, -1, -1 }; // batch=1, channels=3, H/W dynamic
 if (!c.matches(my_tensor)) { ... }

Definition at line 44 of file TensorSpec.h.

Public Member Functions

matches()

bool simaai::neat::TensorConstraint::matches (const Tensor & t)
inline

Returns true if t satisfies every non-empty constraint in this spec.

Empty fields are skipped (treated as "no constraint"). Useful for inline validation in application code and as the underlying check used by built-in contracts.

Definition at line 65 of file TensorSpec.h.

Public Member Attributes

allow_composite

bool simaai::neat::TensorConstraint::allow_composite = true

If false, reject composite (multi-plane) tensors like NV12.

Definition at line 57 of file TensorSpec.h.

allowed_devices

std::vector<Device> simaai::neat::TensorConstraint::allowed_devices

Acceptable devices (empty = any).

Definition at line 49 of file TensorSpec.h.

device

std::optional<Device> simaai::neat::TensorConstraint::device

Required device (empty = any).

Definition at line 48 of file TensorSpec.h.

dtypes

std::vector<simaai::neat::TensorDType> simaai::neat::TensorConstraint::dtypes

Acceptable dtypes (empty = any).

Definition at line 45 of file TensorSpec.h.

image_format

std::optional<ImageSpec::PixelFormat> simaai::neat::TensorConstraint::image_format

Required image pixel format (only meaningful for image tensors).

Definition at line 53 of file TensorSpec.h.

preferred_device

std::optional<Device> simaai::neat::TensorConstraint::preferred_device

Preferred device for placement (informational).

Definition at line 50 of file TensorSpec.h.

rank

int simaai::neat::TensorConstraint::rank = -1

Required rank (-1 = any).

Definition at line 46 of file TensorSpec.h.

required_segment_names

std::vector<std::string> simaai::neat::TensorConstraint::required_segment_names

Required memory-segment names (must all be present).

Definition at line 56 of file TensorSpec.h.

required_segments

std::vector<Segment> simaai::neat::TensorConstraint::required_segments

Exact required memory-segment layout (advanced).

Definition at line 54 of file TensorSpec.h.

shape

std::vector<int64_t> simaai::neat::TensorConstraint::shape

Required shape; -1 in any position means dynamic.

Definition at line 47 of file TensorSpec.h.


The documentation for this struct was generated from the following file:


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.