def product_allocated

bendtorch-core@0.1.0.0 · src/tensor/matmul.bend:821

import bendtorch-core@0.1.0.0/src/tensor/matmul.bend as Matmul
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
import bendtorch-core@0.1.0.0/src/tensor/elementwise.bend as Elementwise

821def product_allocated(+lo: Order, +ro: Order, +left: Shape.Shape, +right: Shape.Shape, +output: Shape.Shape,
822  +inner: Nat, +rows: Nat, +columns: Nat,
823  a: Core.Tensor<left>, b: Core.Tensor<right>, result: Result<&2, &1, Core.Error, Core.Tensor<output>>) ->
824  Result<&2, &1, Error, Core.Dynamic & Core.Dynamic & Core.Dynamic>:
825  match result:
826    case Fail{error}:
827      Fail{TensorError{error}}
828    case Done{Core.TTensor{storage, exact}}:
829      match storage:
830        case Storage.Empty{}:
831          Done{(Core.pack(left, a), Core.pack(right, b), Core.pack(output, Core.TTensor{Storage.Empty{}, exact}))}
832        case Storage.Owned{+depth, +length, array, balanced, valid}:
833          product_parallel_output(lo, ro, output, inner, rows, columns, depth, length, valid, exact,
834            Elementwise.take(Core.pack(left, a)), Elementwise.take(Core.pack(right, b)))

Uses (14)

Used by (2)