← Back to C-Kernel-Engine Docs Doxygen Source Documentation
ckernel_ir_v2.h
Go to the documentation of this file.
1 #ifndef CKERNEL_IR_V2_H
2 #define CKERNEL_IR_V2_H
3 
4 #include "ckernel_ir.h"
5 #include "ckernel_kernel_specs.h"
6 
7 #include <stdint.h>
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #define CK_IR_V2_MAX_DIMS 4
14 #define CK_IR_V2_MAX_INPUTS 8
15 #define CK_IR_V2_MAX_OUTPUTS 4
16 #define CK_IR_V2_MAX_BINDINGS 24
17 
18 typedef enum {
23 
24 typedef struct {
25  char *name;
30  int optional;
31  char *alias_of;
32  char *condition;
33 } CKIRV2Buffer;
34 
35 typedef struct {
36  char *arg;
37  int32_t buffer;
39 
40 typedef struct {
41  char *op;
42  char *kernel;
44  char *condition;
45  uint16_t layer;
46  uint8_t flags;
48  uint8_t n_bindings;
49  int32_t inputs[CK_IR_V2_MAX_INPUTS];
50  uint8_t n_inputs;
51  int32_t outputs[CK_IR_V2_MAX_OUTPUTS];
52  uint8_t n_outputs;
53 } CKIRV2Node;
54 
55 typedef struct {
59  int fused_qkv;
60  int gated_mlp;
63  int num_nodes;
65 } CKIRV2Graph;
66 
67 struct CKMemPlan;
68 
69 int ck_ir_v2_build_decoder(const CKModelConfig *cfg, CKIRV2Graph *graph);
70 int ck_ir_v2_build_decoder_backward(const CKIRV2Graph *forward, CKIRV2Graph *backward);
71 int ck_ir_v2_apply_meta(const char *path, CKIRV2Graph *graph);
72 int ck_ir_v2_serialize_json(const CKIRV2Graph *graph, const char *path);
74  const struct CKMemPlan *plan,
75  const char *mode,
76  int tokens_override,
77  int base_context_window,
78  const char *path);
79 int ck_ir_v2_parse_json(const char *path, CKIRV2Graph *graph);
80 void ck_ir_v2_free(CKIRV2Graph *graph);
81 
82 #ifdef __cplusplus
83 } /* extern "C" */
84 #endif
85 
86 #endif /* CKERNEL_IR_V2_H */
CKDataType
Supported data types in C-Kernel-Engine.
Definition: ckernel_dtype.h:27
#define CK_IR_V2_MAX_DIMS
Definition: ckernel_ir_v2.h:13
#define CK_IR_V2_MAX_BINDINGS
Definition: ckernel_ir_v2.h:16
#define CK_IR_V2_MAX_OUTPUTS
Definition: ckernel_ir_v2.h:15
int ck_ir_v2_serialize_json_with_plan(const CKIRV2Graph *graph, const struct CKMemPlan *plan, const char *mode, int tokens_override, int base_context_window, const char *path)
void ck_ir_v2_free(CKIRV2Graph *graph)
Definition: ckernel_ir_v2.c:34
int ck_ir_v2_apply_meta(const char *path, CKIRV2Graph *graph)
int ck_ir_v2_serialize_json(const CKIRV2Graph *graph, const char *path)
int ck_ir_v2_build_decoder(const CKModelConfig *cfg, CKIRV2Graph *graph)
int ck_ir_v2_parse_json(const char *path, CKIRV2Graph *graph)
#define CK_IR_V2_MAX_INPUTS
Definition: ckernel_ir_v2.h:14
CKIRV2NodeFlags
Definition: ckernel_ir_v2.h:18
@ CK_IR_V2_NODE_FUSED
Definition: ckernel_ir_v2.h:20
@ CK_IR_V2_NODE_INFERENCE_ONLY
Definition: ckernel_ir_v2.h:21
@ CK_IR_V2_NODE_NONE
Definition: ckernel_ir_v2.h:19
int ck_ir_v2_build_decoder_backward(const CKIRV2Graph *forward, CKIRV2Graph *backward)
int32_t buffer
Definition: ckernel_ir_v2.h:37
CKBufferRole role
Definition: ckernel_ir_v2.h:27
char * condition
Definition: ckernel_ir_v2.h:32
CKBufferScope scope
Definition: ckernel_ir_v2.h:26
char * alias_of
Definition: ckernel_ir_v2.h:31
CKDataType dtype
Definition: ckernel_ir_v2.h:28
CKModelConfig config
Definition: ckernel_ir_v2.h:56
int tie_word_embeddings
Definition: ckernel_ir_v2.h:58
CKIRV2Node * nodes
Definition: ckernel_ir_v2.h:64
CKIRV2Buffer * buffers
Definition: ckernel_ir_v2.h:62
uint8_t n_bindings
Definition: ckernel_ir_v2.h:48
char * condition
Definition: ckernel_ir_v2.h:44
uint16_t layer
Definition: ckernel_ir_v2.h:45
uint8_t flags
Definition: ckernel_ir_v2.h:46
CKDataType kernel_dtype
Definition: ckernel_ir_v2.h:43
uint8_t n_outputs
Definition: ckernel_ir_v2.h:52
char * kernel
Definition: ckernel_ir_v2.h:42
uint8_t n_inputs
Definition: ckernel_ir_v2.h:50