Working basic eq between TensorAlloc

This commit is contained in:
adrien 2026-05-24 18:40:14 +02:00
parent 09d6ca1ff5
commit ba671ee486
5 changed files with 1026 additions and 4 deletions

View File

@ -5,8 +5,8 @@
.minimum_zig_version = "0.16.0", .minimum_zig_version = "0.16.0",
.dependencies = .{ .dependencies = .{
.zig_wgpu = .{ .zig_wgpu = .{
.url = "git+https://git.bouvais.lu/adrien/zig-wgpu?ref=0.2.0#9c329a5a0657b00682958457bb118e2fc977dd63", .url = "git+https://git.bouvais.lu/adrien/zig-wgpu?ref=0.2.2#5f8da0940d77c40eacd39c268d09acbeaea0b2a5",
.hash = "zig_wgpu-0.2.0-xsLAy56X0QMafD4OTAvoQIJSo5VDBiw3B24DcB6wd1ZO", .hash = "zig_wgpu-0.2.0-xsLAy2-s0QPNwR2QNd8ZX2kWiVfV5oB92N3ga1V1Uwpu",
}, },
}, },
.paths = .{ .paths = .{

1019
src/TensorAlloc.zig Normal file

File diff suppressed because it is too large Load Diff

View File

@ -37,7 +37,7 @@ pub fn Tensor(
pub const total: comptime_int = _total; pub const total: comptime_int = _total;
pub const strides_arr: [shape_.len]comptime_int = _strides; pub const strides_arr: [shape_.len]comptime_int = _strides;
pub const ISTENSOR = true; pub const ISTENSOR = true;
pub const TENSORSTATIC = true; pub const TENSORKIND: sh.TensorKind = .static;
/// Convert N-D coords (row-major) to flat index fully comptime. /// Convert N-D coords (row-major) to flat index fully comptime.
/// Usage: Tensor.idx(.{row, col}) /// Usage: Tensor.idx(.{row, col})
@ -53,7 +53,7 @@ pub fn Tensor(
} }
/// Broadcast a single value across all elements. /// Broadcast a single value across all elements.
pub inline fn splat(v: T) Self { pub fn splat(v: T) Self {
return .{ .data = @splat(v) }; return .{ .data = @splat(v) };
} }

View File

@ -4,6 +4,8 @@ const UnitScale = Scales.UnitScale;
const Dimensions = @import("Dimensions.zig"); const Dimensions = @import("Dimensions.zig");
const Dimension = Dimensions.Dimension; const Dimension = Dimensions.Dimension;
pub const TensorKind = enum { static, alloc, gpu };
pub fn isTensor(comptime T: type) bool { pub fn isTensor(comptime T: type) bool {
return comptime @typeInfo(T) == .@"struct" and @hasDecl(T, "ISTENSOR"); return comptime @typeInfo(T) == .@"struct" and @hasDecl(T, "ISTENSOR");
} }

View File

@ -1,5 +1,6 @@
test { test {
_ = @import("TensorStatic.zig"); _ = @import("TensorStatic.zig");
_ = @import("TensorAlloc.zig");
_ = @import("Dimensions.zig"); _ = @import("Dimensions.zig");
_ = @import("Scales.zig"); _ = @import("Scales.zig");
_ = @import("Base.zig"); _ = @import("Base.zig");