update instructions
following, `prepare` doesn't alloc anymore, `ExeWithWeights` is `ModuleExe`
This commit is contained in:
parent
27c8309424
commit
eb20548241
@ -144,12 +144,12 @@ corresponding types.
|
|||||||
|
|
||||||
3. Compile the model struct and its `forward` function into an executable.
|
3. Compile the model struct and its `forward` function into an executable.
|
||||||
`foward` is a `Tensor -> Tensor` function, executable is a
|
`foward` is a `Tensor -> Tensor` function, executable is a
|
||||||
`zml.Exe(Model.forward)`
|
`zml.FnExe(Model.forward)`
|
||||||
|
|
||||||
4. Load the model weights from disk, onto accelerator memory ->
|
4. Load the model weights from disk, onto accelerator memory ->
|
||||||
`zml.Bufferized(Model)` struct (with `zml.Buffer` inside)
|
`zml.Bufferized(Model)` struct (with `zml.Buffer` inside)
|
||||||
|
|
||||||
5. Bind the model weights to the executable `zml.ExeWithWeight(Model.forward)`
|
5. Bind the model weights to the executable `zml.ModuleExe(Model.forward)`
|
||||||
|
|
||||||
6. Load some user inputs (custom struct), encode them into arrays of numbers
|
6. Load some user inputs (custom struct), encode them into arrays of numbers
|
||||||
(`zml.HostBuffer`), and copy them to the accelerator (`zml.Buffer`).
|
(`zml.HostBuffer`), and copy them to the accelerator (`zml.Buffer`).
|
||||||
|
|||||||
@ -282,7 +282,8 @@ executable.
|
|||||||
|
|
||||||
```zig
|
```zig
|
||||||
// pass the model weights to the compiled module to create an executable module
|
// pass the model weights to the compiled module to create an executable module
|
||||||
var executable = try compiled.prepare(arena, model_weights);
|
// all required memory has been allocated in `compile`.
|
||||||
|
var executable = compiled.prepare(model_weights);
|
||||||
defer executable.deinit();
|
defer executable.deinit();
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -498,7 +499,7 @@ pub fn asyncMain() !void {
|
|||||||
|
|
||||||
// pass the model weights to the compiled module to create an executable
|
// pass the model weights to the compiled module to create an executable
|
||||||
// module
|
// module
|
||||||
var executable = try compiled.prepare(arena, model_weights);
|
var executable = compiled.prepare(model_weights);
|
||||||
defer executable.deinit();
|
defer executable.deinit();
|
||||||
|
|
||||||
// prepare an input buffer
|
// prepare an input buffer
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user