Skip to main content

ev_tensor_abi.h File

Included Headers

#include <stdint.h>

Enumerations Index

enumsima_ev_op_type { ... }
enumsima_ev_dtype { ... }
enumsima_ev_layout_kind { ... }
enumsima_ev_run_target { ... }
enumsima_ev_tiled_flags { ... }
enumsima_ev_axis_semantic { ... }
enumsima_ev_dense_tensor_format { ... }

Functions Index

struct__attribute__ ((packed)) sima_ev_abi_header
static uint32_tsima_ev_tensor_count (const struct sima_ev_abi_header *hdr)
static enum sima_ev_run_targetsima_ev_requested_run_target (const struct sima_ev_abi_header *hdr)
static const char *sima_ev_run_target_name (enum sima_ev_run_target run_target)
static intsima_ev_axis_index (const struct sima_ev_shape_desc *desc, enum sima_ev_axis_semantic axis)
static int64_tsima_ev_axis_size (const struct sima_ev_shape_desc *desc, enum sima_ev_axis_semantic axis, int64_t fallback)
static int64_tsima_ev_axis_stride_bytes (const struct sima_ev_shape_desc *shape, const struct sima_ev_strided_layout_desc *layout, enum sima_ev_axis_semantic axis, int64_t fallback)
static int64_tsima_ev_tensor_axis_stride_bytes (const struct sima_ev_tensor_desc *desc, enum sima_ev_axis_semantic axis, int64_t fallback)
static int64_tsima_ev_tile_axis_size (const struct sima_ev_shape_desc *shape, const struct sima_ev_tiled_layout_desc *layout, enum sima_ev_axis_semantic axis, int64_t fallback)
static int64_tsima_ev_tensor_tile_axis_size (const struct sima_ev_tensor_desc *desc, enum sima_ev_axis_semantic axis, int64_t fallback)
static intsima_ev_elem_size_bytes (uint32_t dtype)
static enum sima_ev_dense_tensor_formatsima_ev_infer_dense_tensor_format (const struct sima_ev_tensor_desc *desc)
static intsima_ev_tile_is_aligned (const struct sima_ev_tensor_desc *desc)
static intsima_ev_tiled_uses_compact_channels (const struct sima_ev_tensor_desc *desc)
static intsima_ev_tensor_is_contiguous (const struct sima_ev_tensor_desc *desc)

Macro Definitions Index

#defineSIMA_EV_ABI_VERSION_V1   1U
#defineSIMA_EV_MAX_TENSORS   32U
#defineSIMA_EV_MAX_RANK   6U

Enumerations

sima_ev_axis_semantic

enum sima_ev_axis_semantic
Enumeration values
SIMA_EV_AXIS_UNKNOWN (= 0)
SIMA_EV_AXIS_N (= 1)
SIMA_EV_AXIS_D (= 2)
SIMA_EV_AXIS_H (= 3)
SIMA_EV_AXIS_W (= 4)
SIMA_EV_AXIS_C (= 5)

Definition at line 54 of file ev_tensor_abi.h.

sima_ev_dense_tensor_format

enum sima_ev_dense_tensor_format
Enumeration values
SIMA_EV_DENSE_FORMAT_UNKNOWN (= 0)
SIMA_EV_DENSE_FORMAT_NDHWC (= 1)
SIMA_EV_DENSE_FORMAT_NDCHW (= 2)

Definition at line 63 of file ev_tensor_abi.h.

sima_ev_dtype

enum sima_ev_dtype
Enumeration values
SIMA_EV_DTYPE_INT8 (= 0)
SIMA_EV_DTYPE_INT16 (= 1)
SIMA_EV_DTYPE_BF16 (= SIMA_EV_DTYPE_INT16)
SIMA_EV_DTYPE_INT32 (= 2)
SIMA_EV_DTYPE_FP32 (= 3)
SIMA_EV_DTYPE_FP16 (= 4)

Definition at line 28 of file ev_tensor_abi.h.

sima_ev_layout_kind

enum sima_ev_layout_kind
Enumeration values
SIMA_EV_LAYOUT_STRIDED (= 0)
SIMA_EV_LAYOUT_TILED (= 1)
SIMA_EV_LAYOUT_OPAQUE (= 2)

Definition at line 37 of file ev_tensor_abi.h.

sima_ev_op_type

enum sima_ev_op_type
Enumeration values
SIMA_EV_OP_INVALID (= 0)
SIMA_EV_OP_TESSELLATE (= 1)
SIMA_EV_OP_DETESSELLATE (= 2)
SIMA_EV_OP_CAST (= 3)
SIMA_EV_OP_CASTTESSELLATE (= 4)
SIMA_EV_OP_DETESSELLATECAST (= 5)
SIMA_EV_OP_QUANTIZE (= 6)
SIMA_EV_OP_QUANTIZETESSELLATE (= 7)
SIMA_EV_OP_DEQUANTIZE (= 8)
SIMA_EV_OP_QUANTTESS (= 9)
SIMA_EV_OP_DETESSDEQUANT (= 10)

Definition at line 14 of file ev_tensor_abi.h.

sima_ev_run_target

enum sima_ev_run_target
Enumeration values
SIMA_EV_RUN_AUTO (= 0)
SIMA_EV_RUN_EV74 (= 1)
SIMA_EV_RUN_A65 (= 2)

Definition at line 43 of file ev_tensor_abi.h.

sima_ev_tiled_flags

enum sima_ev_tiled_flags
Enumeration values
SIMA_EV_TILED_FLAG_NONE (= 0)
SIMA_EV_TILED_FLAG_COMPACT_CHANNELS (= 1U << 0)

Definition at line 49 of file ev_tensor_abi.h.

Functions

__attribute__()

struct __attribute__ ((packed))

Definition at line 1 of file ev_tensor_abi.h.

69struct __attribute__((packed)) sima_ev_abi_header {
70 uint16_t abi_version;
71 uint16_t op_type;
72 uint32_t flags;
73 uint32_t tensor_count;
74 uint32_t run_target;
75};

sima_ev_axis_index()

int sima_ev_axis_index (const struct sima_ev_shape_desc * desc, enum sima_ev_axis_semantic axis)
inline static

Definition at line 140 of file ev_tensor_abi.h.

140static inline int sima_ev_axis_index(const struct sima_ev_shape_desc* desc,
141 enum sima_ev_axis_semantic axis) {
142 if (!desc) {
143 return -1;
144 }
145 const uint32_t rank = desc->rank < SIMA_EV_MAX_RANK ? desc->rank : SIMA_EV_MAX_RANK;
146 for (uint32_t i = 0; i < rank; ++i) {
147 if ((enum sima_ev_axis_semantic)desc->axis_semantics[i] == axis) {
148 return (int)i;
149 }
150 }
151 return -1;
152}

sima_ev_axis_size()

int64_t sima_ev_axis_size (const struct sima_ev_shape_desc * desc, enum sima_ev_axis_semantic axis, int64_t fallback)
inline static

Definition at line 154 of file ev_tensor_abi.h.

154static inline int64_t sima_ev_axis_size(const struct sima_ev_shape_desc* desc,
155 enum sima_ev_axis_semantic axis, int64_t fallback) {
156 const int axis_index = sima_ev_axis_index(desc, axis);
157 return axis_index >= 0 ? desc->sizes[axis_index] : fallback;
158}

sima_ev_axis_stride_bytes()

int64_t sima_ev_axis_stride_bytes (const struct sima_ev_shape_desc * shape, const struct sima_ev_strided_layout_desc * layout, enum sima_ev_axis_semantic axis, int64_t fallback)
inline static

Definition at line 160 of file ev_tensor_abi.h.

160static inline int64_t sima_ev_axis_stride_bytes(const struct sima_ev_shape_desc* shape,
161 const struct sima_ev_strided_layout_desc* layout,
162 enum sima_ev_axis_semantic axis, int64_t fallback) {
163 if (!shape || !layout) {
164 return fallback;
165 }
166 const int axis_index = sima_ev_axis_index(shape, axis);
167 return axis_index >= 0 ? layout->strides_bytes[axis_index] : fallback;
168}

sima_ev_elem_size_bytes()

int sima_ev_elem_size_bytes (uint32_t dtype)
inline static

Definition at line 198 of file ev_tensor_abi.h.

198static inline int sima_ev_elem_size_bytes(uint32_t dtype) {
199 switch ((enum sima_ev_dtype)dtype) {
202 return 4;
205 return 2;
207 default:
208 return 1;
209 }
210}

sima_ev_infer_dense_tensor_format()

enum sima_ev_dense_tensor_format sima_ev_infer_dense_tensor_format (const struct sima_ev_tensor_desc * desc)
inline static

Definition at line 213 of file ev_tensor_abi.h.

213sima_ev_infer_dense_tensor_format(const struct sima_ev_tensor_desc* desc) {
214 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_STRIDED) {
216 }
217
218 const int64_t height = sima_ev_axis_size(&desc->shape, SIMA_EV_AXIS_H, 0);
219 const int64_t width = sima_ev_axis_size(&desc->shape, SIMA_EV_AXIS_W, 0);
220 const int64_t channels = sima_ev_axis_size(&desc->shape, SIMA_EV_AXIS_C, 0);
221 const int64_t elem_size = sima_ev_elem_size_bytes(desc->dtype);
222 const int64_t stride_d = sima_ev_tensor_axis_stride_bytes(
223 desc, SIMA_EV_AXIS_D,
224 (height > 0 && width > 0 && channels > 0) ? height * width * channels * elem_size : -1);
225 const int64_t stride_h = sima_ev_tensor_axis_stride_bytes(
226 desc, SIMA_EV_AXIS_H, (width > 0 && channels > 0) ? width * channels * elem_size : -1);
227 const int64_t stride_w = sima_ev_tensor_axis_stride_bytes(
228 desc, SIMA_EV_AXIS_W, (channels > 0) ? channels * elem_size : -1);
229 const int64_t stride_c = sima_ev_tensor_axis_stride_bytes(desc, SIMA_EV_AXIS_C, -1);
230
231 const int64_t ndhwc_stride_c = elem_size;
232 const int64_t ndhwc_stride_w = channels * elem_size;
233 const int64_t ndhwc_stride_h = width * ndhwc_stride_w;
234 const int64_t ndhwc_stride_d = height * ndhwc_stride_h;
235 if (stride_c == ndhwc_stride_c && stride_w == ndhwc_stride_w && stride_h == ndhwc_stride_h &&
236 stride_d == ndhwc_stride_d) {
238 }
239
240 const int64_t ndchw_stride_w = elem_size;
241 const int64_t ndchw_stride_h = width * ndchw_stride_w;
242 const int64_t ndchw_stride_c = height * ndchw_stride_h;
243 const int64_t ndchw_stride_d = channels * ndchw_stride_c;
244 if (stride_w == ndchw_stride_w && stride_h == ndchw_stride_h && stride_c == ndchw_stride_c &&
245 stride_d == ndchw_stride_d) {
247 }
248
250}

sima_ev_requested_run_target()

enum sima_ev_run_target sima_ev_requested_run_target (const struct sima_ev_abi_header * hdr)
inline static

Definition at line 114 of file ev_tensor_abi.h.

114sima_ev_requested_run_target(const struct sima_ev_abi_header* hdr) {
115 if (!hdr) {
116 return SIMA_EV_RUN_AUTO;
117 }
118 switch ((enum sima_ev_run_target)hdr->run_target) {
121 case SIMA_EV_RUN_A65:
122 return (enum sima_ev_run_target)hdr->run_target;
123 default:
124 return SIMA_EV_RUN_AUTO;
125 }
126}

sima_ev_run_target_name()

const char * sima_ev_run_target_name (enum sima_ev_run_target run_target)
inline static

Definition at line 128 of file ev_tensor_abi.h.

128static inline const char* sima_ev_run_target_name(enum sima_ev_run_target run_target) {
129 switch (run_target) {
131 return "EV74";
132 case SIMA_EV_RUN_A65:
133 return "A65";
135 default:
136 return "AUTO";
137 }
138}

sima_ev_tensor_axis_stride_bytes()

int64_t sima_ev_tensor_axis_stride_bytes (const struct sima_ev_tensor_desc * desc, enum sima_ev_axis_semantic axis, int64_t fallback)
inline static

Definition at line 170 of file ev_tensor_abi.h.

170static inline int64_t sima_ev_tensor_axis_stride_bytes(const struct sima_ev_tensor_desc* desc,
171 enum sima_ev_axis_semantic axis,
172 int64_t fallback) {
173 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_STRIDED) {
174 return fallback;
175 }
176 return sima_ev_axis_stride_bytes(&desc->shape, &desc->layout.strided, axis, fallback);
177}

sima_ev_tensor_count()

uint32_t sima_ev_tensor_count (const struct sima_ev_abi_header * hdr)
inline static

Definition at line 109 of file ev_tensor_abi.h.

109static inline uint32_t sima_ev_tensor_count(const struct sima_ev_abi_header* hdr) {
110 return hdr ? hdr->tensor_count : 0U;
111}

sima_ev_tensor_is_contiguous()

int sima_ev_tensor_is_contiguous (const struct sima_ev_tensor_desc * desc)
inline static

Definition at line 262 of file ev_tensor_abi.h.

262static inline int sima_ev_tensor_is_contiguous(const struct sima_ev_tensor_desc* desc) {
263 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_STRIDED) {
264 return 0;
265 }
266
267 int64_t expected_stride = sima_ev_elem_size_bytes(desc->dtype);
268 for (uint32_t idx = desc->shape.rank; idx-- > 0U;) {
269 if (desc->layout.strided.strides_bytes[idx] != expected_stride) {
270 return 0;
271 }
272 if (desc->shape.sizes[idx] > 0 && expected_stride <= (INT64_MAX / desc->shape.sizes[idx])) {
273 expected_stride *= desc->shape.sizes[idx];
274 }
275 }
276 return 1;
277}

sima_ev_tensor_tile_axis_size()

int64_t sima_ev_tensor_tile_axis_size (const struct sima_ev_tensor_desc * desc, enum sima_ev_axis_semantic axis, int64_t fallback)
inline static

Definition at line 189 of file ev_tensor_abi.h.

189static inline int64_t sima_ev_tensor_tile_axis_size(const struct sima_ev_tensor_desc* desc,
190 enum sima_ev_axis_semantic axis,
191 int64_t fallback) {
192 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_TILED) {
193 return fallback;
194 }
195 return sima_ev_tile_axis_size(&desc->shape, &desc->layout.tiled, axis, fallback);
196}

sima_ev_tile_axis_size()

int64_t sima_ev_tile_axis_size (const struct sima_ev_shape_desc * shape, const struct sima_ev_tiled_layout_desc * layout, enum sima_ev_axis_semantic axis, int64_t fallback)
inline static

Definition at line 179 of file ev_tensor_abi.h.

179static inline int64_t sima_ev_tile_axis_size(const struct sima_ev_shape_desc* shape,
180 const struct sima_ev_tiled_layout_desc* layout,
181 enum sima_ev_axis_semantic axis, int64_t fallback) {
182 if (!shape || !layout) {
183 return fallback;
184 }
185 const int axis_index = sima_ev_axis_index(shape, axis);
186 return axis_index >= 0 ? layout->tile_sizes[axis_index] : fallback;
187}

sima_ev_tile_is_aligned()

int sima_ev_tile_is_aligned (const struct sima_ev_tensor_desc * desc)
inline static

Definition at line 252 of file ev_tensor_abi.h.

252static inline int sima_ev_tile_is_aligned(const struct sima_ev_tensor_desc* desc) {
253 return desc && desc->layout_kind == SIMA_EV_LAYOUT_TILED &&
254 desc->layout.tiled.tile_align_bytes != 0U;
255}

sima_ev_tiled_uses_compact_channels()

int sima_ev_tiled_uses_compact_channels (const struct sima_ev_tensor_desc * desc)
inline static

Definition at line 257 of file ev_tensor_abi.h.

257static inline int sima_ev_tiled_uses_compact_channels(const struct sima_ev_tensor_desc* desc) {
258 return desc && desc->layout_kind == SIMA_EV_LAYOUT_TILED &&
259 ((desc->layout.tiled.flags & SIMA_EV_TILED_FLAG_COMPACT_CHANNELS) != 0U);
260}

Macro Definitions

SIMA_EV_ABI_VERSION_V1

#define SIMA_EV_ABI_VERSION_V1   1U

Definition at line 10 of file ev_tensor_abi.h.

10#define SIMA_EV_ABI_VERSION_V1 1U

SIMA_EV_MAX_RANK

#define SIMA_EV_MAX_RANK   6U

Definition at line 12 of file ev_tensor_abi.h.

12#define SIMA_EV_MAX_RANK 6U

SIMA_EV_MAX_TENSORS

#define SIMA_EV_MAX_TENSORS   32U

Definition at line 11 of file ev_tensor_abi.h.

11#define SIMA_EV_MAX_TENSORS 32U

File Listing

The file content with the documentation metadata removed is:

1#ifndef EV_TENSOR_ABI_H
2#define EV_TENSOR_ABI_H
3
4#ifdef __cplusplus
5#include <cstdint>
6#else
7#include <stdint.h>
8#endif
9
10#define SIMA_EV_ABI_VERSION_V1 1U
11#define SIMA_EV_MAX_TENSORS 32U
12#define SIMA_EV_MAX_RANK 6U
13
26};
27
35};
36
41};
42
47};
48
52};
53
61};
62
67};
68
69struct __attribute__((packed)) sima_ev_abi_header {
70 uint16_t abi_version;
71 uint16_t op_type;
72 uint32_t flags;
73 uint32_t tensor_count;
74 uint32_t run_target;
75};
76
77struct __attribute__((packed)) sima_ev_storage_desc {
78 uint64_t addr;
79 uint64_t nbytes;
80};
81
82struct __attribute__((packed)) sima_ev_shape_desc {
83 uint32_t rank;
84 uint8_t axis_semantics[SIMA_EV_MAX_RANK];
85 int64_t sizes[SIMA_EV_MAX_RANK];
86};
87
88struct __attribute__((packed)) sima_ev_strided_layout_desc {
89 int64_t strides_bytes[SIMA_EV_MAX_RANK];
90};
91
92struct __attribute__((packed)) sima_ev_tiled_layout_desc {
93 int64_t tile_sizes[SIMA_EV_MAX_RANK];
94 uint32_t tile_align_bytes;
95 uint32_t flags;
96};
97
98struct __attribute__((packed)) sima_ev_tensor_desc {
99 uint32_t dtype;
100 uint32_t layout_kind;
101 struct sima_ev_storage_desc storage;
102 struct sima_ev_shape_desc shape;
103 union {
104 struct sima_ev_strided_layout_desc strided;
105 struct sima_ev_tiled_layout_desc tiled;
106 } layout;
107};
108
109static inline uint32_t sima_ev_tensor_count(const struct sima_ev_abi_header* hdr) {
110 return hdr ? hdr->tensor_count : 0U;
111}
112
113static inline enum sima_ev_run_target
114sima_ev_requested_run_target(const struct sima_ev_abi_header* hdr) {
115 if (!hdr) {
116 return SIMA_EV_RUN_AUTO;
117 }
118 switch ((enum sima_ev_run_target)hdr->run_target) {
121 case SIMA_EV_RUN_A65:
122 return (enum sima_ev_run_target)hdr->run_target;
123 default:
124 return SIMA_EV_RUN_AUTO;
125 }
126}
127
128static inline const char* sima_ev_run_target_name(enum sima_ev_run_target run_target) {
129 switch (run_target) {
131 return "EV74";
132 case SIMA_EV_RUN_A65:
133 return "A65";
135 default:
136 return "AUTO";
137 }
138}
139
140static inline int sima_ev_axis_index(const struct sima_ev_shape_desc* desc,
141 enum sima_ev_axis_semantic axis) {
142 if (!desc) {
143 return -1;
144 }
145 const uint32_t rank = desc->rank < SIMA_EV_MAX_RANK ? desc->rank : SIMA_EV_MAX_RANK;
146 for (uint32_t i = 0; i < rank; ++i) {
147 if ((enum sima_ev_axis_semantic)desc->axis_semantics[i] == axis) {
148 return (int)i;
149 }
150 }
151 return -1;
152}
153
154static inline int64_t sima_ev_axis_size(const struct sima_ev_shape_desc* desc,
155 enum sima_ev_axis_semantic axis, int64_t fallback) {
156 const int axis_index = sima_ev_axis_index(desc, axis);
157 return axis_index >= 0 ? desc->sizes[axis_index] : fallback;
158}
159
160static inline int64_t sima_ev_axis_stride_bytes(const struct sima_ev_shape_desc* shape,
161 const struct sima_ev_strided_layout_desc* layout,
162 enum sima_ev_axis_semantic axis, int64_t fallback) {
163 if (!shape || !layout) {
164 return fallback;
165 }
166 const int axis_index = sima_ev_axis_index(shape, axis);
167 return axis_index >= 0 ? layout->strides_bytes[axis_index] : fallback;
168}
169
170static inline int64_t sima_ev_tensor_axis_stride_bytes(const struct sima_ev_tensor_desc* desc,
171 enum sima_ev_axis_semantic axis,
172 int64_t fallback) {
173 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_STRIDED) {
174 return fallback;
175 }
176 return sima_ev_axis_stride_bytes(&desc->shape, &desc->layout.strided, axis, fallback);
177}
178
179static inline int64_t sima_ev_tile_axis_size(const struct sima_ev_shape_desc* shape,
180 const struct sima_ev_tiled_layout_desc* layout,
181 enum sima_ev_axis_semantic axis, int64_t fallback) {
182 if (!shape || !layout) {
183 return fallback;
184 }
185 const int axis_index = sima_ev_axis_index(shape, axis);
186 return axis_index >= 0 ? layout->tile_sizes[axis_index] : fallback;
187}
188
189static inline int64_t sima_ev_tensor_tile_axis_size(const struct sima_ev_tensor_desc* desc,
190 enum sima_ev_axis_semantic axis,
191 int64_t fallback) {
192 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_TILED) {
193 return fallback;
194 }
195 return sima_ev_tile_axis_size(&desc->shape, &desc->layout.tiled, axis, fallback);
196}
197
198static inline int sima_ev_elem_size_bytes(uint32_t dtype) {
199 switch ((enum sima_ev_dtype)dtype) {
202 return 4;
205 return 2;
207 default:
208 return 1;
209 }
210}
211
212static inline enum sima_ev_dense_tensor_format
213sima_ev_infer_dense_tensor_format(const struct sima_ev_tensor_desc* desc) {
214 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_STRIDED) {
216 }
217
218 const int64_t height = sima_ev_axis_size(&desc->shape, SIMA_EV_AXIS_H, 0);
219 const int64_t width = sima_ev_axis_size(&desc->shape, SIMA_EV_AXIS_W, 0);
220 const int64_t channels = sima_ev_axis_size(&desc->shape, SIMA_EV_AXIS_C, 0);
221 const int64_t elem_size = sima_ev_elem_size_bytes(desc->dtype);
222 const int64_t stride_d = sima_ev_tensor_axis_stride_bytes(
223 desc, SIMA_EV_AXIS_D,
224 (height > 0 && width > 0 && channels > 0) ? height * width * channels * elem_size : -1);
225 const int64_t stride_h = sima_ev_tensor_axis_stride_bytes(
226 desc, SIMA_EV_AXIS_H, (width > 0 && channels > 0) ? width * channels * elem_size : -1);
227 const int64_t stride_w = sima_ev_tensor_axis_stride_bytes(
228 desc, SIMA_EV_AXIS_W, (channels > 0) ? channels * elem_size : -1);
229 const int64_t stride_c = sima_ev_tensor_axis_stride_bytes(desc, SIMA_EV_AXIS_C, -1);
230
231 const int64_t ndhwc_stride_c = elem_size;
232 const int64_t ndhwc_stride_w = channels * elem_size;
233 const int64_t ndhwc_stride_h = width * ndhwc_stride_w;
234 const int64_t ndhwc_stride_d = height * ndhwc_stride_h;
235 if (stride_c == ndhwc_stride_c && stride_w == ndhwc_stride_w && stride_h == ndhwc_stride_h &&
236 stride_d == ndhwc_stride_d) {
238 }
239
240 const int64_t ndchw_stride_w = elem_size;
241 const int64_t ndchw_stride_h = width * ndchw_stride_w;
242 const int64_t ndchw_stride_c = height * ndchw_stride_h;
243 const int64_t ndchw_stride_d = channels * ndchw_stride_c;
244 if (stride_w == ndchw_stride_w && stride_h == ndchw_stride_h && stride_c == ndchw_stride_c &&
245 stride_d == ndchw_stride_d) {
247 }
248
250}
251
252static inline int sima_ev_tile_is_aligned(const struct sima_ev_tensor_desc* desc) {
253 return desc && desc->layout_kind == SIMA_EV_LAYOUT_TILED &&
254 desc->layout.tiled.tile_align_bytes != 0U;
255}
256
257static inline int sima_ev_tiled_uses_compact_channels(const struct sima_ev_tensor_desc* desc) {
258 return desc && desc->layout_kind == SIMA_EV_LAYOUT_TILED &&
259 ((desc->layout.tiled.flags & SIMA_EV_TILED_FLAG_COMPACT_CHANNELS) != 0U);
260}
261
262static inline int sima_ev_tensor_is_contiguous(const struct sima_ev_tensor_desc* desc) {
263 if (!desc || desc->layout_kind != SIMA_EV_LAYOUT_STRIDED) {
264 return 0;
265 }
266
267 int64_t expected_stride = sima_ev_elem_size_bytes(desc->dtype);
268 for (uint32_t idx = desc->shape.rank; idx-- > 0U;) {
269 if (desc->layout.strided.strides_bytes[idx] != expected_stride) {
270 return 0;
271 }
272 if (desc->shape.sizes[idx] > 0 && expected_stride <= (INT64_MAX / desc->shape.sizes[idx])) {
273 expected_stride *= desc->shape.sizes[idx];
274 }
275 }
276 return 1;
277}
278
279#endif // EV_TENSOR_ABI_H

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.