def parallel_allocated

bendtorch-core@0.1.0.0 · src/autograd/reduce.bend:275

import bendtorch-core@0.1.0.0/src/autograd/reduce.bend as Reduce
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

275def parallel_allocated(input: Core.Dynamic, +target: Shape.Shape, +plan: Shape.BroadcastPlan,
276  result: Result<&2, &1, Core.Error, Core.Tensor<target>>) -> Core.Dynamic & Result<&2, &1, Error, Core.Dynamic>:
277  match result:
278    case Fail{error}:
279      (input, Fail{TensorError{error}})
280    case Done{Core.TTensor{storage, exact}}:
281      match storage:
282        case Storage.Empty{}:
283          (input, Done{Core.Packed{target, Core.TTensor{Storage.Empty{}, exact}}})
284        case Storage.Owned{+depth, +length, array, balanced, valid}:
285          parallel_indexed(input, target, plan, Core.TTensor{Storage.Owned{depth, length, array, balanced, valid}, exact},
286            depth, length, valid, exact, Shape.index_map(plan))

Uses (12)

Used by (6)