Go to the source code of this file.
Macros | |
| #define | CACHELINE_BYTES 64 |
Functions | |
| static size_t | align_up_bytes (size_t n, size_t align) |
| static size_t | bump_bytes (size_t *off, size_t bytes, size_t align) |
| void | layout_transformer_from_ir (TransformerModel *m, const CKIRGraph *ir) |
| #define CACHELINE_BYTES 64 |
Definition at line 6 of file ckernel_model_layout.c.
|
static |
Definition at line 8 of file ckernel_model_layout.c.
Referenced by bump_bytes(), and layout_transformer_from_ir().
|
static |
Definition at line 14 of file ckernel_model_layout.c.
References align_up_bytes(), and start.
Referenced by layout_transformer_from_ir().
| void layout_transformer_from_ir | ( | TransformerModel * | m, |
| const CKIRGraph * | ir | ||
| ) |
Compute a simple forward-only layout for TransformerModel based on:
This function:
Offsets are in bytes counted from memory_base. The exact shapes and alignment strategy will evolve; this initial version focuses on correctness and clarity over tight packing. Layout the TransformerModel memory based on its cfg and (optionally) the IR.
If ir is non-NULL, its config is copied into m->cfg. If ir is NULL, the function trusts that m->cfg has already been populated.
Definition at line 21 of file ckernel_model_layout.c.
References align_up_bytes(), CKLayerLayout::attn_proj_bias_offset, CKLayerLayout::attn_proj_weight_offset, bump_bytes(), CACHELINE_BYTES, TransformerModel::cfg, CKIRGraph::config, CKModelConfig::context_window, TransformerModel::elem_bytes, TransformerModel::embedded_input_offset, CKLayerLayout::fc1_bias_offset, CKLayerLayout::fc1_weight_offset, CKLayerLayout::fc2_bias_offset, CKLayerLayout::fc2_weight_offset, TransformerModel::final_ln_bias_offset, TransformerModel::final_ln_weight_offset, TransformerModel::final_output_offset, CKModelConfig::hidden_size, CKModelConfig::intermediate_size, TransformerModel::layers, TransformerModel::layers_start_offset, TransformerModel::lm_head_weight_offset, CKLayerLayout::ln1_bias_offset, CKLayerLayout::ln1_weight_offset, TransformerModel::logits_offset, CKModelConfig::num_layers, TransformerModel::pos_emb_offset, CKLayerLayout::qkv_bias_offset, CKLayerLayout::qkv_weight_offset, TransformerModel::token_emb_offset, TransformerModel::total_bytes, TransformerModel::total_floats, and CKModelConfig::vocab_size.