#include "ckernel_codegen_v2_emit.h"#include "ckernel_dtype.h"#include <stdio.h>#include <string.h>Go to the source code of this file.
Macros | |
| #define | CK_V2_SECTION_ALIGN 64 |
Functions | |
| static size_t | align_up_bytes (size_t n, size_t align) |
| static size_t | align_up_elems (size_t elems, size_t elem_bytes, size_t align_bytes) |
| static size_t | buffer_bytes (const CKIRV2Buffer *buf, const CKModelConfig *cfg, const CKV2AlignInfo *align) |
| void | ck_codegen_v2_emit_sections (FILE *out, const CKIRV2Graph *graph, const CKMemPlan *prefill_plan, const CKMemPlan *decode_plan, const CKMemPlan *backward_plan) |
| static CKV2AlignInfo | compute_align (const CKModelConfig *cfg) |
| static void | emit_body_fields (FILE *out, const CKIRV2Graph *graph, CKBufferRole role_filter, int activation_group) |
| static size_t | emit_body_values (FILE *out, const CKIRV2Graph *graph, const CKMemPlan *plan, CKBufferRole role_filter, int activation_group) |
| static void | emit_footer_fields (FILE *out, const CKIRV2Graph *graph, CKBufferRole role_filter, int activation_group) |
| static void | emit_footer_values (FILE *out, const CKIRV2Graph *graph, const CKMemPlan *plan, CKBufferRole role_filter, int activation_group, size_t *offset) |
| static void | emit_header_fields (FILE *out, const CKIRV2Graph *graph, CKBufferRole role_filter, int activation_group) |
| static void | emit_header_values (FILE *out, const CKIRV2Graph *graph, const CKMemPlan *plan, CKBufferRole role_filter, int activation_group, size_t *offset) |
| static void | emit_span_field (FILE *out, const char *label) |
| static void | emit_span_value (FILE *out, const char *label, size_t offset, size_t size, int comma) |
| static int | is_activation_role (CKBufferRole role) |
| static int | is_footer_global (const char *name) |
| static size_t | plan_size (const CKMemPlan *plan, int idx) |
| static size_t | resolve_dim (const CKModelConfig *cfg, const CKV2AlignInfo *align, CKDimKind kind) |
| static size_t | resolve_shape_elems (const CKModelConfig *cfg, const CKV2AlignInfo *align, const CKDimToken *shape) |
| #define CK_V2_SECTION_ALIGN 64 |
Definition at line 8 of file ckernel_codegen_v2_sections.c.
|
static |
Definition at line 17 of file ckernel_codegen_v2_sections.c.
Referenced by align_up_elems(), emit_body_values(), emit_footer_values(), and emit_header_values().
|
static |
Definition at line 25 of file ckernel_codegen_v2_sections.c.
References align_up_bytes().
Referenced by compute_align().
|
static |
Definition at line 100 of file ckernel_codegen_v2_sections.c.
References ck_dtype_row_bytes(), CKIRV2Buffer::dtype, resolve_shape_elems(), and CKIRV2Buffer::shape.
| void ck_codegen_v2_emit_sections | ( | FILE * | out, |
| const CKIRV2Graph * | graph, | ||
| const CKMemPlan * | prefill_plan, | ||
| const CKMemPlan * | decode_plan, | ||
| const CKMemPlan * | backward_plan | ||
| ) |
Definition at line 309 of file ckernel_codegen_v2_sections.c.
References CK_ROLE_ACTIVATION, CK_ROLE_GRAD, CK_ROLE_WEIGHT, CKIRV2Graph::config, CKModelConfig::context_window, emit_body_fields(), emit_body_values(), emit_footer_fields(), emit_footer_values(), emit_header_fields(), emit_header_values(), CKModelConfig::hidden_size, CKModelConfig::intermediate_size, CKModelConfig::num_heads, CKModelConfig::num_kv_heads, CKModelConfig::num_layers, and CKModelConfig::vocab_size.
Referenced by ck_codegen_v2_emit_runtime().
|
static |
Definition at line 32 of file ckernel_codegen_v2_sections.c.
References align_up_elems(), CK_V2_SECTION_ALIGN, CKModelConfig::context_window, CKModelConfig::hidden_size, CKModelConfig::intermediate_size, and CKModelConfig::num_heads.
|
static |
Definition at line 171 of file ckernel_codegen_v2_sections.c.
References CKIRV2Graph::buffers, CK_SCOPE_LAYER, emit_span_field(), is_activation_role(), CKIRV2Buffer::name, CKIRV2Graph::num_buffers, CKIRV2Buffer::role, and CKIRV2Buffer::scope.
Referenced by ck_codegen_v2_emit_sections().
|
static |
Definition at line 253 of file ckernel_codegen_v2_sections.c.
References align_up_bytes(), CKIRV2Graph::buffers, CK_SCOPE_LAYER, CK_V2_SECTION_ALIGN, emit_span_value(), is_activation_role(), CKIRV2Buffer::name, CKIRV2Graph::num_buffers, plan_size(), CKIRV2Buffer::role, and CKIRV2Buffer::scope.
Referenced by ck_codegen_v2_emit_sections().
|
static |
Definition at line 192 of file ckernel_codegen_v2_sections.c.
References CKIRV2Graph::buffers, CK_SCOPE_GLOBAL, emit_span_field(), is_activation_role(), is_footer_global(), CKIRV2Buffer::name, CKIRV2Graph::num_buffers, CKIRV2Buffer::role, and CKIRV2Buffer::scope.
Referenced by ck_codegen_v2_emit_sections().
|
static |
Definition at line 280 of file ckernel_codegen_v2_sections.c.
References align_up_bytes(), CKIRV2Graph::buffers, CK_SCOPE_GLOBAL, CK_V2_SECTION_ALIGN, emit_span_value(), is_activation_role(), is_footer_global(), CKIRV2Buffer::name, CKIRV2Graph::num_buffers, plan_size(), CKIRV2Buffer::role, and CKIRV2Buffer::scope.
Referenced by ck_codegen_v2_emit_sections().
|
static |
Definition at line 147 of file ckernel_codegen_v2_sections.c.
References CKIRV2Graph::buffers, CK_SCOPE_GLOBAL, emit_span_field(), is_activation_role(), is_footer_global(), CKIRV2Buffer::name, CKIRV2Graph::num_buffers, CKIRV2Buffer::role, and CKIRV2Buffer::scope.
Referenced by ck_codegen_v2_emit_sections().
|
static |
Definition at line 224 of file ckernel_codegen_v2_sections.c.
References align_up_bytes(), CKIRV2Graph::buffers, CK_SCOPE_GLOBAL, CK_V2_SECTION_ALIGN, emit_span_value(), is_activation_role(), is_footer_global(), CKIRV2Buffer::name, CKIRV2Graph::num_buffers, plan_size(), CKIRV2Buffer::role, and CKIRV2Buffer::scope.
Referenced by ck_codegen_v2_emit_sections().
|
static |
Definition at line 131 of file ckernel_codegen_v2_sections.c.
Referenced by emit_body_fields(), emit_footer_fields(), and emit_header_fields().
|
static |
Definition at line 136 of file ckernel_codegen_v2_sections.c.
Referenced by emit_body_values(), emit_footer_values(), and emit_header_values().
|
static |
Definition at line 141 of file ckernel_codegen_v2_sections.c.
References CK_ROLE_ACTIVATION, CK_ROLE_INPUT, CK_ROLE_OUTPUT, and CK_ROLE_SCRATCH.
Referenced by emit_body_fields(), emit_body_values(), emit_footer_fields(), emit_footer_values(), emit_header_fields(), and emit_header_values().
|
static |
Definition at line 108 of file ckernel_codegen_v2_sections.c.
Referenced by emit_footer_fields(), emit_footer_values(), emit_header_fields(), and emit_header_values().
|
static |
Definition at line 216 of file ckernel_codegen_v2_sections.c.
References CKMemPlan::num_spans, CKMemSpan::size_bytes, and CKMemPlan::spans.
Referenced by emit_body_values(), emit_footer_values(), and emit_header_values().
|
static |
Definition at line 49 of file ckernel_codegen_v2_sections.c.
References CK_DIM_ALIGNED_CTX, CK_DIM_ALIGNED_EMBED, CK_DIM_ALIGNED_HEAD, CK_DIM_ALIGNED_INTERMEDIATE, CK_DIM_EMBED, CK_DIM_END, CK_DIM_HEAD_DIM, CK_DIM_INTERMEDIATE, CK_DIM_NUM_HEADS, CK_DIM_NUM_KV_HEADS, CK_DIM_TOKENS, CK_DIM_VOCAB, CKModelConfig::context_window, CKModelConfig::hidden_size, CKModelConfig::intermediate_size, CKModelConfig::num_heads, CKModelConfig::num_kv_heads, and CKModelConfig::vocab_size.
Referenced by resolve_shape_elems().
|
static |
Definition at line 82 of file ckernel_codegen_v2_sections.c.
References CK_DIM_END, CK_IR_V2_MAX_DIMS, and resolve_dim().
Referenced by buffer_bytes().