Jazz 1.25.+
Loading...
Searching...
No Matches
snippet.h
1/* Jazz (c) 2018-2025 kaalam.ai (The Authors of Jazz), using (under the same license):
2
3 1. Biomodelling - The AATBlockQueue class (c) Jacques BasaldĂșa, 2009-2012 licensed
4 exclusively for the use in the Jazz server software.
5
6 Copyright 2009-2012 Jacques BasaldĂșa
7
8 2. BBVA - Jazz: A lightweight analytical web server for data-driven applications.
9
10 Copyright 2016-2017 Banco Bilbao Vizcaya Argentaria, S.A.
11
12 This product includes software developed at
13
14 BBVA (https://www.bbva.com/)
15
16 3. LMDB, Copyright 2011-2017 Howard Chu, Symas Corp. All rights reserved.
17
18 Licensed under http://www.OpenLDAP.org/license.html
19
20
21 Licensed under the Apache License, Version 2.0 (the "License");
22 you may not use this file except in compliance with the License.
23 You may obtain a copy of the License at
24
25 http://www.apache.org/licenses/LICENSE-2.0
26
27 Unless required by applicable law or agreed to in writing, software
28 distributed under the License is distributed on an "AS IS" BASIS,
29 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30 See the License for the specific language governing permissions and
31 limitations under the License.
32*/
33
34
35#include "src/jazz_bebop/opcodes.h"
36
37#if defined CATCH_TEST
38#ifndef INCLUDED_JAZZ_CATCH2
39#define INCLUDED_JAZZ_CATCH2
40
41#include "src/catch2/catch.hpp"
42
43#endif
44#endif
45
46
47#ifndef INCLUDED_JAZZ_BEBOP_SNIPPET
48#define INCLUDED_JAZZ_BEBOP_SNIPPET
49
50
58//TODO: Synchronize http://localhost:8888/jazz_reference/api_ref_core.html (Erase this only when Core is done.)
59
60namespace jazz_bebop
61{
62
65const char KIND_SNIPPET[] = "{\"object\" : BYTE[obj_size], \"body\" : STRING[body_len], \"calls\" : STRING[calls_len]," \
66 "\"input\" : STRING[input_len], \"output\" : STRING[output_len], \"reads\" : STRING[reads_len]," \
67 "\"source\" : STRING[source_len], \"writes\" : STRING[writes_len]}";
68
71const char EMPTY_SNIPPET[] = "(\"object\" : [], \"body\" : [NA], \"calls\" : [NA], \"input\" : [NA], \"output\" : [NA]," \
72 "\"reads\" : [NA], \"source\" : [NA], \"writes\" : [NA])";
73
76const char SNIPPET_VERSION[] = "snp1";
77
78const char SNIPSTATE_EMPTY_SNIPPET[] = "____";
79const char SNIPSTATE_SOURCE_AVAILABLE[] = "s___";
80const char SNIPSTATE_SOURCE_PREPROCESSED[] = "sx__";
81const char SNIPSTATE_SOURCE_COMPILED[] = "sxo_";
82const char SNIPSTATE_OBJECT_AVAILABLE[] = "__o_";
83const char SNIPSTATE_OBJECT_PREPROCESSED[] = "_xo_";
84const char SNIPSTATE_CAN_RUN[] = "___a";
85const char SNIPSTATE_CAN_RUN_OBJECT[] = "_xor";
86const char SNIPSTATE_CAN_RUN_SOURCE[] = "sxor";
87const char SNIPSTATE_IS_RUNNING_OBJECT[] = "_xoi";
88const char SNIPSTATE_IS_RUNNING_SOURCE[] = "sxoi";
89const char SNIPSTATE_FAILED_SRC_PREPROC[] = "sX_!";
90const char SNIPSTATE_FAILED_SRC_COMPILE[] = "sxO!";
91const char SNIPSTATE_FAILED_OBJ_PREPROC[] = "_Xo!";
92const char SNIPSTATE_FAILED_RUN_OBJECT[] = "_xo!";
93const char SNIPSTATE_FAILED_RUN_SOURCE[] = "sxo!";
94
95#define MASK_SNIPSTATE_GENERAL 0xff000000
96#define MASK_SNIPSTATE_OBJECT 0x00ff0000
97#define MASK_SNIPSTATE_INTER 0x0000ff00
98#define MASK_SNIPSTATE_SOURCE 0x000000ff
99#define SNIPSTATE_UNDEFINED 0x7fffffff
100
101#define SNIP_INDEX_OBJECT 0
102#define SNIP_INDEX_BODY 1
103#define SNIP_INDEX_CALLS 2
104#define SNIP_INDEX_INPUT 3
105#define SNIP_INDEX_OUTPUT 4
106#define SNIP_INDEX_READS 5
107#define SNIP_INDEX_SOURCE 6
108#define SNIP_INDEX_WRITES 7
109
110
118typedef std::vector<std::string> SnippetText;
120
121
170class Snippet : public Tuple {
171
172 public:
173
174 using Tuple::get_block;
175
176 int get_state();
177 bool get_block(int idx, SnippetText &snip_text);
178 bool get_block(pChar name, SnippetText &snip_text);
179 int object_size();
180 void* get_object();
181};
183
184} // namespace jazz_bebop
185
186#endif // ifndef INCLUDED_JAZZ_BEBOP_SNIPPET
Snippet: A code snippet and the ancestor of Concept.
Definition snippet.h:170
void * get_object()
Definition snippet.cpp:133
bool get_block(int idx, SnippetText &snip_text)
Definition snippet.cpp:73
int get_state()
Definition snippet.cpp:54
int object_size()
Definition snippet.cpp:115
Tuple: A Jazz Block with multiple Tensors.
Definition tuple.h:94
pBlock get_block(int idx)
Definition tuple.h:224
A language to access any container by base using locators.
Definition base_api.cpp:39
const char SNIPSTATE_CAN_RUN_SOURCE[]
The snippet (from source) is ready to run (or has run before)
Definition snippet.h:86
const char SNIPSTATE_SOURCE_PREPROCESSED[]
The source code has been preprocessed successfully.
Definition snippet.h:80
const char SNIPSTATE_FAILED_SRC_PREPROC[]
The source code preprocessing failed.
Definition snippet.h:89
const char SNIPSTATE_EMPTY_SNIPPET[]
The snippet is empty.
Definition snippet.h:78
const char SNIPSTATE_IS_RUNNING_SOURCE[]
The snippet is currently running (from source)
Definition snippet.h:88
const char SNIPSTATE_FAILED_SRC_COMPILE[]
The source code compilation failed.
Definition snippet.h:90
const char SNIPSTATE_CAN_RUN[]
The global state is neither error nor empty state() >= SNIPSTATE_CAN_RUN.
Definition snippet.h:84
const char SNIPSTATE_IS_RUNNING_OBJECT[]
The snippet is currently running (from onnx)
Definition snippet.h:87
const char SNIPSTATE_SOURCE_AVAILABLE[]
The source code is available.
Definition snippet.h:79
const char SNIPSTATE_OBJECT_AVAILABLE[]
The snippet is created from an onnx object.
Definition snippet.h:82
std::vector< std::string > SnippetText
A SnippetText is a vector of strings.
Definition snippet.h:118
const char SNIPSTATE_OBJECT_PREPROCESSED[]
The snippet (from onnx) has been reverse engineered successfully.
Definition snippet.h:83
SnippetText * pSnippetText
A pointer to a SnippetText.
Definition snippet.h:119
const char SNIPSTATE_FAILED_RUN_SOURCE[]
The snippet failed to run (from source)
Definition snippet.h:93
Snippet * pSnippet
A pointer to a Snippet.
Definition snippet.h:182
const char SNIPPET_VERSION[]
The content of the attribute BLOCK_ATTRIB_SNIPVERS.
Definition snippet.h:76
const char KIND_SNIPPET[]
Definition snippet.h:65
const char SNIPSTATE_SOURCE_COMPILED[]
The source code has been compiled successfully.
Definition snippet.h:81
const char SNIPSTATE_FAILED_RUN_OBJECT[]
The snippet failed to run (from onnx)
Definition snippet.h:92
const char SNIPSTATE_FAILED_OBJ_PREPROC[]
The snippet (from onnx) reverse engineering failed.
Definition snippet.h:91
const char SNIPSTATE_CAN_RUN_OBJECT[]
The snippet (from onnx) is ready to run (or has run before)
Definition snippet.h:85
const char EMPTY_SNIPPET[]
Definition snippet.h:71
char * pChar
A pointer to a char buffer.
Definition types.h:185