Skip to documentation
SLOP

tiny.simd.AlignedLayout

Reference tiny.simd AlignedLayout

Defined in aligned.

Called byCallsalignedArrayalignedViewtest sourcelib.simd.src.alignedtest: aligned owners reject invalid g...private sourcelib.simd.src.alignedcomputeSizesprivate sourcelib.simd.src.alignedroundUpalignedLayout
Static calls · unresolved targets: 1 · external targets: 1.

Source

Source: lib/simd/src/aligned.zig:216

zig
pub fn Layout(comptime axes: usize) type {    if (axes == 0) @compileError("aligned arrays require at least one axis");    return struct {        shape_value: [axes]usize,        memory_shape_value: [axes]usize,        sizes: [axes + 1]usize,        memory_sizes: [axes + 1]usize,        vector_bytes: usize,        const Self = @This();        pub fn init(shape_value: [axes]usize) Error!Self {            return initFor(shape_value, native_vector_bytes);        }        pub fn initFor(            shape_value: [axes]usize,            vector_bytes: usize,        ) Error!Self {            if (!std.math.isPowerOfTwo(vector_bytes)) return error.InvalidVectorBytes;            for (shape_value) |dimension| {                if (dimension == 0) return error.ZeroDimension;            }            var memory_shape_value = shape_value;            memory_shape_value[axes - 1] = try roundUp(                memory_shape_value[axes - 1],                vector_bytes,            );            return .{                .shape_value = shape_value,                .memory_shape_value = memory_shape_value,                .sizes = try computeSizes(axes, shape_value),                .memory_sizes = try computeSizes(axes, memory_shape_value),                .vector_bytes = vector_bytes,            };        }        pub fn shape(self: *const Self) [axes]usize {            return self.shape_value;        }        pub fn memoryShape(self: *const Self) [axes]usize {            return self.memory_shape_value;        }        pub fn len(self: *const Self) usize {            return self.sizes[0];        }        pub fn memoryLen(self: *const Self) usize {            return self.memory_sizes[0];        }        pub fn memoryBytes(self: *const Self, comptime T: type) Error!usize {            return std.math.mul(usize, self.memoryLen(), @sizeOf(T)) catch                error.AllocationSizeOverflow;        }        pub fn rowLen(self: *const Self) usize {            return self.shape_value[axes - 1];        }        pub fn rowOffset(            self: *const Self,            indices: [axes - 1]usize,        ) Error!usize {            var offset: usize = 0;            for (indices, 0..) |index, axis| {                if (index >= self.shape_value[axis]) return error.IndexOutOfBounds;                offset += self.memory_sizes[axis + 1] * index;            }            return offset;        }        pub fn truncate(self: *Self, new_shape: [axes]usize) Error!void {            for (new_shape, self.shape_value) |new_dimension, old_dimension| {                if (new_dimension > old_dimension) return error.ShapeExpansion;            }            self.shape_value = new_shape;            self.sizes = try computeSizes(axes, new_shape);        }    };}

Source: lib/simd/src/root.zig:251

zig
pub const AlignedLayout = aligned.Layout;

Audit

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433