Skip to documentation
SLOP

tiny.accy.tensor.interpret

Reference tiny.accy tensor interpret

Defined in tensor.

API (23)

Actions

Public operations.

Types and contracts

Public types and contracts.

No direct callersNo direct callstensorinterpret
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/accy/src/tensor/interpret/graph.zig:5

zig
pub const Graph = struct {    builder: *trace.Builder,    pub const Value: type = trace.Value;    pub const Result: type = program_mod.Program;    pub fn operation(self: *@This(), step: *step_mod.Step(Value)) !Value {        var buffer: [program_mod.max_operation_operands]Value = undefined;        return self.bind(step.op, step_mod.arguments(Value, step.op, step.values, &buffer));    }    pub fn bind(self: *@This(), op: *const program_mod.Operation, args: []const Value) !Value {        return self.builder.operation(op, args);    }    pub fn finish(self: *@This(), outputs: []const Value) !Result {        return self.builder.finish(outputs);    }    pub fn builderHandle(self: *@This()) *trace.Builder {        return self.builder;    }};

Source: lib/accy/src/tensor/interpret/context.zig:11

zig
pub fn BindContext(comptime BoundValue: type, comptime Handle: type) type {    return struct {        next: Handle,        op: *const program_mod.Operation,        args: []const BoundValue,        pub fn default(self: *@This()) !BoundValue {            return self.next.bind(self.op, self.args);        }        pub fn arg(self: *@This(), index: usize) BoundValue {            return self.args[index];        }        pub fn builderHandle(self: *@This()) *trace.Builder {            return self.next.builderHandle();        }    };}
Called byCallsNo direct callsprivate sourcelib.accy.src.tensor.interpret.layerLayertensor.interpretBindContext
Static calls · unresolved targets: 0 · external targets: 2.

Source: lib/accy/src/tensor/interpret/context.zig:31

zig
pub fn FinishContext(comptime BoundValue: type, comptime Handle: type) type {    return struct {        next: Handle,        pub fn default(self: *@This(), outputs: []const BoundValue) !pointerChild(Handle).Result {            return self.next.finish(outputs);        }        pub fn builderHandle(self: *@This()) *trace.Builder {            return self.next.builderHandle();        }    };}
Called byCallsprivate sourcelib.accy.src.tensor.interpret.layerLayerprivate sourcelib.accy.src.tensor.interpret.contextpointerChildtensor.interpretFinishContext
Static calls · unresolved targets: 0 · external targets: 2.

Source: lib/accy/src/tensor/interpret/context.zig:45

zig
pub fn LeafBindContext(comptime BoundValue: type) type {    return struct {        op: *const program_mod.Operation,        args: []const BoundValue,        pub fn arg(self: *@This(), index: usize) BoundValue {            return self.args[index];        }    };}
Called byCallsNo direct callstensor.interpretSemanticstensor.interpretLeafBindContext
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/execute.zig:38

zig
pub fn result(comptime Initial: type) type {    if (comptime @hasDecl(Initial, "attach")) return @TypeOf(@as(Initial, undefined).attach(@as(graph_mod.Graph, undefined))).Result;    return Normalized(Initial).Result;}
Called byCallstensor.interpretrunprivate sourcelib.accy.src.tensor.interpret.executeNormalizedtensor.interpretresult
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/execute.zig:8

zig
pub fn run(    allocator: std.mem.Allocator,    source: *const program_mod.Program,    initial: anytype,) !result(@TypeOf(initial)) {    var state = normalize(initial);    const State = @TypeOf(state);    const Value = State.Value;    const values = try allocator.alloc(Value, source.valueCount());    defer allocator.free(values);    for (source.operations) |*op| {        var step = step_mod.Step(Value){            .source = source,            .values = values,            .op = op,        };        values[op.id.index] = try state.operation(&step);    }    const outputs = try allocator.alloc(Value, source.outputs.len);    defer allocator.free(outputs);    for (source.outputs, 0..) |id, index| {        outputs[index] = values[id.index];    }    return try state.finish(outputs);}
Called byCallsNo direct callersprivate sourcelib.accy.src.tensor.interpret.executenormalizetensor.interpretresultprivate sourcelib.tldr.src.profiling.collect.parse.large.co...finishtensor.interpretrun
Static calls · unresolved targets: 0 · external targets: 5.
Called byCallsNo direct callstensor.interpret.Graphoperationtensor.interpret.Graphbind
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallsNo direct callerstensor.interpret.Graphbindtensor.interpret.Graphoperation
Static calls · unresolved targets: 0 · external targets: 2.

Source: lib/accy/src/tensor/interpret/leaf.zig:11

zig
pub fn Semantics(comptime BoundValue: type, comptime Impl: type) type {    return struct {        impl: Impl,        pub const Value: type = BoundValue;        pub const Result: type = Impl.Result;        pub fn operation(self: *@This(), step: *step_mod.Step(Value)) !Value {            var buffer: [program_mod.max_operation_operands]Value = undefined;            return self.bind(step.op, step_mod.arguments(Value, step.op, step.values, &buffer));        }        pub fn bind(self: *@This(), op: *const program_mod.Operation, args: []const Value) !Value {            if (comptime @hasDecl(Impl, "bind")) {                return self.impl.bind(op, args);            }            var ctx = context.LeafBindContext(Value){                .op = op,                .args = args,            };            if (try dispatch.primitive(Value, &self.impl, &ctx)) |value| return value;            if (comptime @hasDecl(Impl, "default")) return self.impl.default(&ctx);            @compileError("tensor leaf semantics without bind must provide primitive handlers and default");        }        pub fn finish(self: *@This(), outputs: []const Value) !Result {            return self.impl.finish(outputs);        }        pub fn builderHandle(self: *@This()) *trace.Builder {            return self.impl.builderHandle();        }    };}
Called byCallsprivate sourcelib.accy.src.tensor.interpret.executeNormalizedtensor.interpretsemanticstensor.interpretLeafBindContextprivate sourcelib.accy.src.tensor.interpret.dispatchprimitivetensor.interpretSemantics
Static calls · unresolved targets: 0 · external targets: 7.

Source: lib/accy/src/tensor/interpret/leaf.zig:7

zig
pub fn semantics(comptime BoundValue: type, impl: anytype) Semantics(BoundValue, @TypeOf(impl)) {    return .{ .impl = impl };}
Called byCallsprivate sourcelib.accy.src.tensor.interpret.executenormalizetensor.interpretSemanticstensor.interpretsemantics
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/spec.zig:46

zig
pub fn Layer(comptime BoundValue: type, comptime Next: type, comptime Impl: type) type {    return dispatch.Layer(BoundValue, Next, Impl);}
Called byCallsNo direct callstensor.interpretWithtensor.interpretlayertensor.interpretLayer
Static calls · unresolved targets: 0 · external targets: 1.

Source: lib/accy/src/tensor/interpret/spec.zig:28

zig
pub fn Stack(comptime Specs: type) type {    _ = stackLength(Specs);    return struct {        specs: Specs,        pub fn attach(self: @This(), next: anytype) StackAttach(0, Specs, @TypeOf(next)) {            return attachFrom(0, self.specs, next);        }    };}
Called byCallstensor.interpretstackprivate sourcelib.accy.src.tensor.interpret.specStackAttachprivate sourcelib.accy.src.tensor.interpret.specattachFromprivate sourcelib.accy.src.tensor.interpret.specstackLengthtensor.interpretStack
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/spec.zig:11

zig
pub fn With(comptime Impl: type) type {    return struct {        impl: Impl,        pub fn attach(self: @This(), next: anytype) Layer(stateValue(@TypeOf(next)), @TypeOf(next), Impl) {            return .{                .next = next,                .impl = self.impl,            };        }    };}
Called byCallstensor.interpretbindtensor.interpretwithtensor.interpretLayerprivate sourcelib.accy.src.tensor.interpret.specstateValuetensor.interpretWith
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/spec.zig:7

zig
pub fn bind(impl: anytype) With(@TypeOf(impl)) {    return with(impl);}
Called byCallsNo direct callerstensor.interpretWithtensor.interpretwithtensor.interpretbind
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/spec.zig:39

zig
pub fn layer(comptime BoundValue: type, next: anytype, impl: anytype) Layer(BoundValue, @TypeOf(next), @TypeOf(impl)) {    return .{        .next = next,        .impl = impl,    };}
Called byCallsNo direct callerstensor.interpretLayertensor.interpretlayer
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/spec.zig:24

zig
pub fn stack(specs: anytype) Stack(@TypeOf(specs)) {    return .{ .specs = specs };}
Called byCallsNo direct callerstensor.interpretStacktensor.interpretstack
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/spec.zig:3

zig
pub fn with(impl: anytype) With(@TypeOf(impl)) {    return .{ .impl = impl };}
Called byCallstensor.interpretbindtensor.interpretWithtensor.interpretwith
Static calls · unresolved targets: 0 · external targets: 0.

Source: lib/accy/src/tensor/interpret/step.zig:3

zig
pub fn Step(comptime Value: type) type {    return struct {        source: *const program_mod.Program,        values: []const Value,        op: *const program_mod.Operation,        pub fn read(self: @This(), id: program_mod.Id) Value {            return self.values[id.index];        }        pub fn typeOf(self: @This(), id: program_mod.Id) program_mod.Type {            return self.source.typeOf(id);        }    };}

Source: lib/accy/src/tensor/interpret/step.zig:19

zig
pub fn arguments(comptime Value: type, op: *const program_mod.Operation, values: []const Value, buffer: *[program_mod.max_operation_operands]Value) []const Value {    return switch (op.kind) {        .parameter, .constant, .iota => buffer[0..0],        .unary => |unary| blk: {            buffer[0] = values[unary.input.index];            break :blk buffer[0..1];        },        .binary => |binary| blk: {            buffer[0] = values[binary.lhs.index];            buffer[1] = values[binary.rhs.index];            break :blk buffer[0..2];        },        .broadcast => |broadcast| blk: {            buffer[0] = values[broadcast.input.index];            break :blk buffer[0..1];        },        .broadcast_in_dim => |broadcast| blk: {            buffer[0] = values[broadcast.input.index];            break :blk buffer[0..1];        },        .reshape => |reshape| blk: {            buffer[0] = values[reshape.input.index];            break :blk buffer[0..1];        },        .transpose => |transpose| blk: {            buffer[0] = values[transpose.input.index];            break :blk buffer[0..1];        },        .reduce => |reduce| blk: {            buffer[0] = values[reduce.input.index];            buffer[1] = values[reduce.init.index];            break :blk buffer[0..2];        },        .gather => |gather| blk: {            buffer[0] = values[gather.input.index];            buffer[1] = values[gather.indices.index];            break :blk buffer[0..2];        },        .scatter_add => |scatter_add| blk: {            buffer[0] = values[scatter_add.input.index];            buffer[1] = values[scatter_add.indices.index];            buffer[2] = values[scatter_add.updates.index];            break :blk buffer[0..3];        },        .sparse_cross_entropy => |sparse_cross_entropy| blk: {            buffer[0] = values[sparse_cross_entropy.logits.index];            buffer[1] = values[sparse_cross_entropy.targets.index];            break :blk buffer[0..2];        },        .dot_general => |dot| blk: {            buffer[0] = values[dot.lhs.index];            buffer[1] = values[dot.rhs.index];            break :blk buffer[0..2];        },        .compare => |compare| blk: {            buffer[0] = values[compare.lhs.index];            buffer[1] = values[compare.rhs.index];            break :blk buffer[0..2];        },        .select => |select| blk: {            buffer[0] = values[select.pred.index];            buffer[1] = values[select.on_true.index];            buffer[2] = values[select.on_false.index];            break :blk buffer[0..3];        },        .custom_call => |custom| blk: {            for (custom.operands, 0..) |operand, index| buffer[index] = values[operand.index];            break :blk buffer[0..custom.operands.len];        },        .scan => |scan| blk: {            for (scan.inits, 0..) |init, index| buffer[index] = values[init.index];            break :blk buffer[0..scan.inits.len];        },        .projection => |projection| blk: {            buffer[0] = values[projection.source.index];            break :blk buffer[0..1];        },    };}

Source: lib/accy/src/tensor/interpret/root.zig

zig
const context_mod = @import("context.zig");const execute = @import("execute.zig");const graph_mod = @import("graph.zig");const leaf = @import("leaf.zig");const spec = @import("spec.zig");const step_mod = @import("step.zig");pub const Step = step_mod.Step;pub const arguments = step_mod.arguments;pub const Graph = graph_mod.Graph;pub const Semantics = leaf.Semantics;pub const BindContext = context_mod.BindContext;pub const FinishContext = context_mod.FinishContext;pub const LeafBindContext = context_mod.LeafBindContext;pub const With = spec.With;pub const Stack = spec.Stack;pub const Layer = spec.Layer;pub const semantics = leaf.semantics;pub const with = spec.with;pub const bind = spec.bind;pub const stack = spec.stack;pub const layer = spec.layer;pub const run = execute.run;pub const result = execute.result;

Source: lib/accy/src/tensor/root.zig:4

zig
pub const interpret = @import("interpret/root.zig");

Audit

Definitions24
Public names24
Members1
Version26.7.0
Revisiondaab053ee433