Skip to main content

TensorConstraint Struct

Declaration

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

Included Headers

#include <TensorSpec.h>

Public Member Functions Index

boolmatches (const Tensor &t) const

Public Member Attributes Index

std::vector< simaai::neat::TensorDType >dtypes
intrank = -1
std::vector< int64_t >shape
std::optional< Device >device
std::vector< Device >allowed_devices
std::optional< Device >preferred_device
std::optional< ImageSpec::PixelFormat >image_format
std::vector< Segment >required_segments
std::vector< std::string >required_segment_names
boolallow_composite = true

Definition at line 16 of file TensorSpec.h.

Public Member Functions

matches()

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

Definition at line 29 of file TensorSpec.h.

29 bool matches(const Tensor& t) const {
30 if (rank >= 0 && static_cast<int>(t.shape.size()) != rank)
31 return false;
32 if (!shape.empty() && shape.size() == t.shape.size()) {
33 for (size_t i = 0; i < shape.size(); ++i) {
34 if (shape[i] >= 0 && t.shape[i] != shape[i])
35 return false;
36 }
37 }
38 if (!dtypes.empty()) {
39 bool ok = false;
40 for (auto dt : dtypes) {
41 if (dt == t.dtype) {
42 ok = true;
43 break;
44 }
45 }
46 if (!ok)
47 return false;
48 }
49 if (device.has_value()) {
50 if (t.device.type != device->type || t.device.id != device->id)
51 return false;
52 }
53 if (!allowed_devices.empty()) {
54 bool ok = false;
55 for (const auto& allowed : allowed_devices) {
56 if (t.device.type == allowed.type && t.device.id == allowed.id) {
57 ok = true;
58 break;
59 }
60 }
61 if (!ok)
62 return false;
63 }
64 if (image_format.has_value()) {
65 if (!t.semantic.image.has_value())
66 return false;
67 if (t.semantic.image->format != *image_format)
68 return false;
69 }
70 if (!required_segments.empty()) {
71 if (!t.storage || t.storage->sima_segments.empty())
72 return false;
73 if (t.storage->sima_segments.size() != required_segments.size())
74 return false;
75 for (size_t i = 0; i < required_segments.size(); ++i) {
76 if (t.storage->sima_segments[i].name != required_segments[i].name)
77 return false;
78 if (t.storage->sima_segments[i].size_bytes != required_segments[i].size_bytes) {
79 return false;
80 }
81 }
82 }
83 if (!required_segment_names.empty()) {
84 if (!t.storage || t.storage->sima_segments.empty())
85 return false;
86 for (const auto& name : required_segment_names) {
87 bool found = false;
88 for (const auto& seg : t.storage->sima_segments) {
89 if (seg.name == name) {
90 found = true;
91 break;
92 }
93 }
94 if (!found)
95 return false;
96 }
97 }
99 return false;
100 return true;
101 }

Public Member Attributes

allow_composite

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

Definition at line 27 of file TensorSpec.h.

27 bool allow_composite = true;

allowed_devices

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

Definition at line 21 of file TensorSpec.h.

21 std::vector<Device> allowed_devices;

device

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

Definition at line 20 of file TensorSpec.h.

20 std::optional<Device> device;

dtypes

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

Definition at line 17 of file TensorSpec.h.

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

image_format

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

Definition at line 24 of file TensorSpec.h.

24 std::optional<ImageSpec::PixelFormat> image_format;

preferred_device

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

Definition at line 22 of file TensorSpec.h.

22 std::optional<Device> preferred_device;

rank

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

Definition at line 18 of file TensorSpec.h.

18 int rank = -1;

required_segment_names

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

Definition at line 26 of file TensorSpec.h.

26 std::vector<std::string> required_segment_names;

required_segments

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

Definition at line 25 of file TensorSpec.h.

25 std::vector<Segment> required_segments;

shape

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

Definition at line 19 of file TensorSpec.h.

19 std::vector<int64_t> shape; // use -1 for dynamic dims

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


Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.