def built_empty

bendtorch-core@0.1.0.0 · src/tensor/slice.bend:331

import bendtorch-core@0.1.0.0/src/tensor/slice.bend as Slice
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/main.bend as Storage
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core

331# An empty source: the forward copy never has cells then, and the backward
332# of an empty gradient reads nothing, so the build reads an empty array.
333def built_empty(+kind: Pass, +output: Shape.Shape, +plan: Plan, +depth: Nat, +length: Nat,
334  -valid: {Storage.bounds(depth, length) == True{} : Bool},
335  -exact: {length == Shape.logical_numel(Shape.dimensions(output)) : Nat}) -> Result<&2, &1, Error, Core.Dynamic>:
336  match kind:
337    case Forward{}:
338      Fail{TensorError{Core.StorageError{Storage.OutOfBounds{}}}}
339    case Backward{}:
340      Done{Core.Packed{output, Core.TTensor{Storage.Owned{depth, length, built_array(Backward{}, depth, plan, length, Array.new(F32, 0n, 0.0)),
341        built_balanced(Backward{}, depth, plan, length, Array.new(F32, 0n, 0.0)), valid}, exact}}}

Uses (19)

Used by (1)