const std = @import("std");
const Allocator = std.mem.Allocator;

pub const Tensor = struct {
    data: []f32,
    shape: []const usize,
    allocator: Allocator,

    pub fn init(allocator: Allocator, shape: []const usize) !Tensor {
        var size: usize = 1;
        for (shape) |dim| {
            size *= dim;
        }

        const data = try allocator.alloc(f32, size);
        @memset(data, 0);

        return Tensor{
            .data = data,
            .shape = shape,
            .allocator = allocator,
        };
    }

    pub fn deinit(self: *Tensor) void {
        self.allocator.free(self.data);
    }
};
