38#include "src/jazz_elements/kind.h"
41#ifndef INCLUDED_JAZZ_CATCH2
42#define INCLUDED_JAZZ_CATCH2
44#include "src/catch2/catch.hpp"
50#ifndef INCLUDED_JAZZ_ELEMENTS_TUPLE
51#define INCLUDED_JAZZ_ELEMENTS_TUPLE
116 if (num_items < 1 || num_items > MAX_ITEMS_IN_KIND)
117 return SERVICE_ERROR_WRONG_ARGUMENTS;
122 rq_sz += 2*att->size();
124 if (num_bytes < rq_sz)
125 return SERVICE_ERROR_NO_MEM;
139 for (
int i = 0; i < num_items; i++) {
140 pBlock p_block = blocks[i];
141 if (p_block ==
nullptr)
142 return SERVICE_ERROR_WRONG_ARGUMENTS;
146 if ((p_block->cell_type & 0xff) > 8)
147 return SERVICE_ERROR_WRONG_TYPE;
152 return SERVICE_ERROR_WRONG_NAME;
154 p_it_hea->
cell_type = p_block->cell_type;
156 p_it_hea->
rank = p_block->rank;
157 p_block->get_dimensions((
int *) &p_it_hea->
dim);
159 if (p_it_hea->
name <= STRING_EMPTY)
160 return SERVICE_ERROR_NO_MEM;
165 if ((uintptr_t) p_dest - (uintptr_t) &
cell_type > num_bytes)
166 return SERVICE_ERROR_NO_MEM;
170 for (
int i = 0; i < num_items; i++) {
171 pBlock p_block = blocks[i];
176 if ((uintptr_t) p_dest - (uintptr_t) &
cell_type + p_block->total_bytes > num_bytes)
177 return SERVICE_ERROR_NO_MEM;
179 memcpy(p_dest, p_block, p_block->total_bytes);
181 p_dest =
align64bit((uintptr_t) p_dest + p_block->total_bytes);
184 return SERVICE_NO_ERROR;
196 if (idx < 0 || idx >=
size)
209 for (
int idx = 0; idx <
size; idx++)
225 if (idx < 0 | idx >=
size)
243 std::map<std::string, int> dimension;
245 for (
int i = 0; i <
size; i++) {
258 if (dimension.count(dim_name)) {
A block is a moveable BlockHeader followed by a Tensor and a StringBuffer.
Definition block.h:99
int get_string_offset(pStringBuffer psb, const char *p_str)
Definition block.cpp:128
int * align64bit(uintptr_t ipt)
Align a pointer (as uintptr_t) to the next 8 byte boundary assuming the block is aligned.
Definition block.h:339
pStringBuffer p_string_buffer()
Definition block.h:363
void set_attributes(AttributeMap *all_att)
Definition block.h:268
Kind: A type definition for Jazz Blocks and Tuples.
Definition kind.h:83
char * item_name(int idx)
Definition kind.h:95
Tuple: A Jazz Block with multiple Tensors.
Definition tuple.h:94
bool is_a(pKind kind)
Definition tuple.h:239
char * item_name(int idx)
Definition tuple.h:195
StatusCode new_tuple(int num_items, pBlock blocks[], Name p_names[], int num_bytes, AttributeMap *att=nullptr)
Definition tuple.h:110
int index(pChar name)
Definition tuple.h:208
int audit()
Definition tuple.cpp:45
pBlock get_block(int idx)
Definition tuple.h:224
The namespace for Jazz Utils, Blocks, Kinds, Tuples, Containers, etc.
Definition block.cpp:39
Tuple * pTuple
A pointer to a Tuple object.
Definition tuple.h:276
bool valid_name(pChar p_name)
Check if a name is valid (Without using the regex).
Definition utils.h:188
char * pChar
A pointer to a char buffer.
Definition types.h:185
class Block * pBlock
A (forward defined) pointer to a Block.
Definition block.h:66
char Name[NAME_SIZE]
A short identifier used in Blocks, Containers and API.
Definition types.h:183
int StatusCode
Type returned by the Service API.
Definition utils.h:141
std::map< int, const char * > AttributeMap
An stdlib map to store all the attributes of a Block at the same time used by the some Block methods.
Definition block.h:63
Structure at the end of a Block, initially created with init_string_buffer()
Definition types.h:282
int last_idx
The index to the first free space after the last stored string.
Definition types.h:285
int buffer_size
The size in bytes of buffer[].
Definition types.h:286
char buffer[]
The buffer where strings are stored starting with two zeroes for STRING_NA & STRING_EMPTY.
Definition types.h:287
int dim[MAX_TENSOR_RANK]
Dimensions for the Tensor. The product of all * (cell_type & 0xff) < 2 Gb.
Definition types.h:193
ItemHeader cell_item[0]
.. An array of BlockHeader used by Kinds and Tuples
Definition types.h:231