![]() |
Jazz 1.25.+
|
Snippet: A code snippet and the ancestor of Concept. More...
#include <snippet.h>
Public Member Functions | |
int | get_state () |
bool | get_block (int idx, SnippetText &snip_text) |
bool | get_block (pChar name, SnippetText &snip_text) |
int | object_size () |
void * | get_object () |
pBlock | get_block (int idx) |
![]() | |
StatusCode | new_tuple (int num_items, pBlock blocks[], Name p_names[], int num_bytes, AttributeMap *att=nullptr) |
char * | item_name (int idx) |
int | index (pChar name) |
pBlock | get_block (int idx) |
bool | is_a (pKind kind) |
int | audit () |
![]() | |
void | set_dimensions (int *p_dim) |
void | get_dimensions (int *p_dim) |
bool | validate_index (int *p_idx) |
int | validate_offset (int offset) |
int | get_offset (int *p_idx) |
void | get_index (int offset, int *p_idx) |
char * | get_string (int *p_idx) |
char * | get_string (int offset) |
void | set_string (int *p_idx, const char *p_str) |
void | set_string (int offset, const char *p_str) |
char * | get_attribute (int attribute_id) |
void | set_attributes (AttributeMap *all_att) |
void | get_attributes (AttributeMap *all_att) |
void | init_string_buffer () |
bool | find_NAs_in_tensor () |
int * | align64bit (uintptr_t ipt) |
Align a pointer (as uintptr_t) to the next 8 byte boundary assuming the block is aligned. | |
int * | p_attribute_keys () |
pStringBuffer | p_string_buffer () |
int | get_string_offset (pStringBuffer psb, const char *p_str) |
bool | is_a_filter () |
Check (in depth) the validity of a filter. | |
bool | can_filter (pBlock p_block) |
void | close_block (int set_has_NA=SET_HAS_NA_FALSE, bool set_hash=true, bool set_time=true) |
bool | check_hash () |
Additional Inherited Members | |
![]() | |
int | cell_type |
The type for the cells in the tensor. See CELL_TYPE_*. | |
int | size |
The total number of cells in the tensor. | |
TimePoint | created |
Timestamp when the block was created. | |
int | rank |
The number of dimensions. | |
TensorDim | range |
The dimensions of the tensor in terms of ranges (Max. size is 2 Gb.) | |
int | num_attributes |
Number of elements in the JazzAttributesMap. | |
int | total_bytes |
Total size of the block everything included. | |
bool | has_NA |
If true, at least one value is a NA and block requires NA-aware arithmetic. | |
uint64_t | hash64 |
Hash of everything but the header. | |
Tensor | tensor |
A tensor for type cell_type and dimensions set by Block.set_dimensions() | |
Snippet: A code snippet and the ancestor of Concept.
A Snippet is a Tuple with items and some attributes. The items are sources and compiled onnx code. The attributes identify it as a Snippet and manage state ().
A snippet always defines two attributes:
BLOCK_ATTRIB_SNIPVERS : The version of the Snippet '1' reserved for future use or extension in general (Concepts). BLOCK_ATTRIB_SNIPSTATE : A four character from SNIPSTATE_EMPTY_SNIPPET to SNIPSTATE_FAILED_RUN_SOURCE
The string is made by binary sorted ASCII characters with 4 fields: general, object, intermediate (body, input, output, reads, writes, calls) and source. The characters are (lower is problematic: ! (33) is irrecoverable error, 'A'..'Z' (65..90) are explanations for error states, _ (93) is empty, 'a'..'z' (97..122) are valid states). The order of the fields is general goes in the top bits when represented as an integer. state() >= SNIPSTATE_CAN_RUN matches any can_run or is_running, state() < SNIPSTATE_EMPTY_SNIPPET matches any error.
You can also mask using MASK_SNIPSTATE_GENERAL .. MASK_SNIPSTATE_SOURCE to get the state of a specific part of the Snippet. The indices are defines as SNIP_INDEX_OBJECT .. SNIP_INDEX_WRITES.
A Valid snippet satisfies the Kind defined as KIND_SNIPPET
The items are:
source, input, output, reads, writes, calls, body, object ------ ----------------------------------------- ------ | | +--> The Onnx object code | +----------------------------> The intermediate (preprocessed) source code +-----------------------------------------------------> The original source code (If available)
Item indices: Since the order of the blocks in a tuple are fixed, you can retrieve the items both by name of by index.
The Snippet object provides an interface to access the text parts as a SnippetText and also returns its state as an integer and its onnx object as a pointer.
Since Snippets are immutable, the logic of adding blocks to the tuple is managed by the Fields object.
int jazz_bebop::Snippet::get_state | ( | ) |
bool jazz_bebop::Snippet::get_block | ( | int | idx, |
SnippetText & | snip_text | ||
) |
Get a specific block (whose type is a tensor of strings) into a SnippetText.
idx | The index of the block. |
snip_text | The SnippetText to fill. The caller must provide an empty object and is responsible of disposing it. If not empty, the content will be appended. |
bool jazz_bebop::Snippet::get_block | ( | pChar | name, |
SnippetText & | snip_text | ||
) |
Get a specific block (whose type is a tensor of strings) into a SnippetText.
name | The name of the block. |
snip_text | The SnippetText to fill. The caller must provide an empty object and is responsible of disposing it. If not empty, the content will be appended. |
int jazz_bebop::Snippet::object_size | ( | ) |
Get the size of the onnx object block.
void * jazz_bebop::Snippet::get_object | ( | ) |
|
inline |
Get a Block from a Tuple by item index.
idx | The index of the item. |
NOTE: Use the pointer as read-only (more than one cell may point to the same value) and never try to free it.