Jazz 1.25.+
Loading...
Searching...
No Matches
Public Member Functions
jazz_bebop::Snippet Class Reference

Snippet: A code snippet and the ancestor of Concept. More...

#include <snippet.h>

Inheritance diagram for jazz_bebop::Snippet:
jazz_elements::Tuple jazz_elements::Block jazz_elements::StaticBlockHeader jazz_models::Concept

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)
 
- Public Member Functions inherited from jazz_elements::Tuple
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 ()
 
- Public Member Functions inherited from jazz_elements::Block
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

- Data Fields inherited from jazz_elements::StaticBlockHeader
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()
 

Detailed Description

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 ().

Attributes

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.

Kind

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.

Interface

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.

Member Function Documentation

◆ get_state()

int jazz_bebop::Snippet::get_state ( )

Returns the state of the Snippet as an integer.

Returns the value of the attribute BLOCK_ATTRIB_SNIPSTATE (only the first 4 chars) as an integer.

See also
Snippet
Returns
The state of the Snippet as an integer.

◆ get_block() [1/3]

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.

Parameters
idxThe index of the block.
snip_textThe SnippetText to fill. The caller must provide an empty object and is responsible of disposing it. If not empty, the content will be appended.
Returns
True if the block was found and either is is empty or snip_text was filled.

◆ get_block() [2/3]

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.

Parameters
nameThe name of the block.
snip_textThe SnippetText to fill. The caller must provide an empty object and is responsible of disposing it. If not empty, the content will be appended.
Returns
True if the block was found and either is is empty or snip_text was filled.

◆ object_size()

int jazz_bebop::Snippet::object_size ( )

Get the size of the onnx object block.

Returns
The size of the object block or 0 if the block is not found.

◆ get_object()

void * jazz_bebop::Snippet::get_object ( )

Get the onnx object block.

This does not copy or allocate memory, it returns a pointer inside the Snippet object which will be valid as long as the Snippet object is valid. Do not try to free it.

Returns
A pointer to the onnx object block or nullptr if the block is not found.

◆ get_block() [3/3]

pBlock jazz_elements::Tuple::get_block ( int  idx)
inline

Get a Block from a Tuple by item index.

Parameters
idxThe index of the item.
Returns
The block stored in the tuple or nullptr for an invalid index.

NOTE: Use the pointer as read-only (more than one cell may point to the same value) and never try to free it.


The documentation for this class was generated from the following files: