1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
//! GPU neural network inference module.
//!
//! This module provides GPU-embeddable inference functions that can be
//! called from within existing GPU kernels using WGSL and wgpu.
//!
//! # Architecture
//!
//! The GPU inference is designed for embedding within other GPU kernels,
//! particularly useful for RL scenarios where each episode runs in its
//! own GPU thread and can call model.predict() multiple times.
//!
//! # Memory Layout
//!
//! All model data is packed into a single contiguous f32 array:
//! - Header (13 f32s) - model metadata
//! - Instructions (N x 8 f32s each)
//! - Weights (flattened f32 array)
//! - Parameters (flattened f32 array)
//!
//! # Usage
//!
//! ```ignore
//! use instmodel_inference::gpu::{GpuModel, shaders::get_instmodel_wgsl};
//! use instmodel_inference::InstructionModelInfo;
//!
//! // Create GPU model from existing InstructionModelInfo
//! let gpu_model = GpuModel::from_info(&model_info)?;
//!
//! // Get WGSL shader source to embed in your kernel
//! let wgsl_source = get_instmodel_wgsl(4096);
//!
//! // In your WGSL kernel:
//! // var compute_buffer: array<f32, MAX_SIZE>;
//! // // ... copy input to compute_buffer ...
//! // predict(&model_data, &compute_buffer);
//! // // ... read output from compute_buffer[output_start..] ...
//! ```
pub use ;
pub use GpuInstruction;
pub use GpuModel;
pub use get_instmodel_wgsl;