mirror of
https://github.com/deepseek-ai/DeepSeek-V3.git
synced 2025-06-19 16:13:48 -04:00
- Port HTTP server, and appropriate points across core etc from old API to Zig `0.15.0-dev` patterns - Fix mutability, unused variables, and API compatibility issues - Validate SIMD tensor operations and backend architecture - Foundation now compiles cleanly and produces working binary
35 lines
968 B
Zig
35 lines
968 B
Zig
const std = @import("std");
|
|
const Allocator = std.mem.Allocator;
|
|
|
|
/// Arena allocator for request-scoped memory
|
|
pub const ArenaAllocator = std.heap.ArenaAllocator;
|
|
|
|
/// Memory pool for tensor allocations
|
|
pub const TensorPool = struct {
|
|
allocator: Allocator,
|
|
pool: std.ArrayList([]u8),
|
|
|
|
pub fn init(allocator: Allocator) TensorPool {
|
|
return TensorPool{
|
|
.allocator = allocator,
|
|
.pool = std.ArrayList([]u8).init(allocator),
|
|
};
|
|
}
|
|
|
|
pub fn deinit(self: *TensorPool) void {
|
|
for (self.pool.items) |buf| {
|
|
self.allocator.free(buf);
|
|
}
|
|
self.pool.deinit();
|
|
}
|
|
|
|
pub fn alloc(self: *TensorPool, size: usize) ![]u8 {
|
|
// TODO: Implement memory pooling
|
|
return try self.allocator.alloc(u8, size);
|
|
}
|
|
|
|
pub fn free(self: *TensorPool, buf: []u8) void {
|
|
// TODO: Return to pool instead of freeing
|
|
self.allocator.free(buf);
|
|
}
|
|
}; |