Jazz 1.26.+
Loading...
Searching...
No Matches
snippet.h
1/* Jazz (c) 2018-2026 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_core/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
61//TODO: Synchronize http://localhost:8888/jazz_reference/api_ref_core.html (Erase this only when Core is done.)
62
63namespace jazz_core
64{
65
68const char KIND_SNIPPET[] = "{\"object\" : BYTE[obj_size], \"body\" : STRING[body_len], \"calls\" : STRING[calls_len]," \
69 "\"input\" : STRING[input_len], \"output\" : STRING[output_len], \"reads\" : STRING[reads_len]," \
70 "\"source\" : STRING[source_len], \"writes\" : STRING[writes_len]}";
71
74const char EMPTY_SNIPPET[] = "(\"object\" : [], \"body\" : [NA], \"calls\" : [NA], \"input\" : [NA], \"output\" : [NA]," \
75 "\"reads\" : [NA], \"source\" : [NA], \"writes\" : [NA])";
76
79const char SNIPPET_VERSION[] = "snp1";
80
81const char SNIPSTATE_EMPTY_SNIPPET[] = "____";
82const char SNIPSTATE_SOURCE_AVAILABLE[] = "s___";
83const char SNIPSTATE_SOURCE_PREPROCESSED[] = "sx__";
84const char SNIPSTATE_SOURCE_COMPILED[] = "sxo_";
85const char SNIPSTATE_OBJECT_AVAILABLE[] = "__o_";
86const char SNIPSTATE_OBJECT_PREPROCESSED[] = "_xo_";
87const char SNIPSTATE_CAN_RUN[] = "___a";
88const char SNIPSTATE_CAN_RUN_OBJECT[] = "_xor";
89const char SNIPSTATE_CAN_RUN_SOURCE[] = "sxor";
90const char SNIPSTATE_IS_RUNNING_OBJECT[] = "_xoi";
91const char SNIPSTATE_IS_RUNNING_SOURCE[] = "sxoi";
92const char SNIPSTATE_FAILED_SRC_PREPROC[] = "sX_!";
93const char SNIPSTATE_FAILED_SRC_COMPILE[] = "sxO!";
94const char SNIPSTATE_FAILED_OBJ_PREPROC[] = "_Xo!";
95const char SNIPSTATE_FAILED_RUN_OBJECT[] = "_xo!";
96const char SNIPSTATE_FAILED_RUN_SOURCE[] = "sxo!";
97
98#define MASK_SNIPSTATE_GENERAL 0xff000000
99#define MASK_SNIPSTATE_OBJECT 0x00ff0000
100#define MASK_SNIPSTATE_INTER 0x0000ff00
101#define MASK_SNIPSTATE_SOURCE 0x000000ff
102#define SNIPSTATE_UNDEFINED 0x7fffffff
103
104#define SNIP_INDEX_OBJECT 0
105#define SNIP_INDEX_BODY 1
106#define SNIP_INDEX_CALLS 2
107#define SNIP_INDEX_INPUT 3
108#define SNIP_INDEX_OUTPUT 4
109#define SNIP_INDEX_READS 5
110#define SNIP_INDEX_SOURCE 6
111#define SNIP_INDEX_WRITES 7
112
113#define BLOCK_ATTRIB_SNIPSTATE (BLOCK_ATTRIB_BASE_BOP + 1)
114#define BLOCK_ATTRIB_SNIPVERS (BLOCK_ATTRIB_BASE_BOP + 2)
115
123typedef std::vector<String> SnippetText;
125
126
175class Snippet : public Tuple {
176
177 public:
178
179 using Tuple::get_block;
180
181 int get_state();
182 bool get_block(int idx, SnippetText &snip_text);
183 bool get_block(pChar name, SnippetText &snip_text);
184 int object_size();
185 void* get_object();
186};
188
189} // namespace jazz_core
190
191#endif // ifndef INCLUDED_JAZZ_BEBOP_SNIPPET
Snippet: A code snippet and the ancestor of Concept.
Definition snippet.h:175
void * get_object()
Definition snippet.cpp:133
int get_state()
Definition snippet.cpp:54
bool get_block(int idx, SnippetText &snip_text)
Definition snippet.cpp:73
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:221
A language to access any container by base using locators.
Definition base_api.cpp:39
const char SNIPSTATE_FAILED_SRC_COMPILE[]
The source code compilation failed.
Definition snippet.h:93
const char SNIPSTATE_EMPTY_SNIPPET[]
The snippet is empty.
Definition snippet.h:81
const char SNIPSTATE_CAN_RUN[]
The global state is neither error nor empty state() >= SNIPSTATE_CAN_RUN.
Definition snippet.h:87
const char SNIPSTATE_FAILED_OBJ_PREPROC[]
The snippet (from onnx) reverse engineering failed.
Definition snippet.h:94
Snippet * pSnippet
A pointer to a Snippet.
Definition snippet.h:187
const char SNIPSTATE_CAN_RUN_OBJECT[]
The snippet (from onnx) is ready to run (or has run before)
Definition snippet.h:88
const char SNIPSTATE_IS_RUNNING_OBJECT[]
The snippet is currently running (from onnx)
Definition snippet.h:90
const char SNIPSTATE_IS_RUNNING_SOURCE[]
The snippet is currently running (from source)
Definition snippet.h:91
const char SNIPSTATE_OBJECT_AVAILABLE[]
The snippet is created from an onnx object.
Definition snippet.h:85
SnippetText * pSnippetText
A pointer to a SnippetText.
Definition snippet.h:124
std::vector< String > SnippetText
A SnippetText is a vector of strings.
Definition snippet.h:123
const char SNIPSTATE_OBJECT_PREPROCESSED[]
The snippet (from onnx) has been reverse engineered successfully.
Definition snippet.h:86
const char KIND_SNIPPET[]
Definition snippet.h:68
const char SNIPPET_VERSION[]
The content of the attribute BLOCK_ATTRIB_SNIPVERS.
Definition snippet.h:79
const char SNIPSTATE_CAN_RUN_SOURCE[]
The snippet (from source) is ready to run (or has run before)
Definition snippet.h:89
const char EMPTY_SNIPPET[]
Definition snippet.h:74
const char SNIPSTATE_FAILED_SRC_PREPROC[]
The source code preprocessing failed.
Definition snippet.h:92
const char SNIPSTATE_FAILED_RUN_SOURCE[]
The snippet failed to run (from source)
Definition snippet.h:96
const char SNIPSTATE_FAILED_RUN_OBJECT[]
The snippet failed to run (from onnx)
Definition snippet.h:95
const char SNIPSTATE_SOURCE_COMPILED[]
The source code has been compiled successfully.
Definition snippet.h:84
const char SNIPSTATE_SOURCE_PREPROCESSED[]
The source code has been preprocessed successfully.
Definition snippet.h:83
const char SNIPSTATE_SOURCE_AVAILABLE[]
The source code is available.
Definition snippet.h:82
char * pChar
A pointer to a char buffer.
Definition types.h:189