def run_lift
bendtorch-core@0.1.0.0 · src/tensor/contracts/pointwise_proof.bend:417
import bendtorch-core@0.1.0.0/src/tensor/contracts/pointwise_proof.bend as PointwiseProof
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/tensor/contracts/pointwise.bend as Pointwise
417def run_lift(~O: Data, ~f: O -> F32 -> F32 -> F32, ~P: Data, ~ia: P -> Nat -> Nat, ~ib: P -> Nat -> Nat,
418 +operation: O, +plan: P, +left: Shape.Shape, +left_fill: F32, +left_ops: List<&2, StorageLaws.Op>,
419 +right: Shape.Shape, +right_fill: F32, +right_ops: List<&2, StorageLaws.Op>, +shape: Shape.Shape,
420 +left_inside: {Pointwise.inside(~P, ~ia, plan, Shape.logical_numel(Shape.dimensions(shape)), Shape.logical_numel(Shape.dimensions(left))) == True{} : Bool},
421 +right_inside: {Pointwise.inside(~P, ~ib, plan, Shape.logical_numel(Shape.dimensions(shape)), Shape.logical_numel(Shape.dimensions(right))) == True{} : Bool},
422 -Q: (Core.Dynamic & Core.Dynamic) & Result<&2, &1, Core.Error, Core.Dynamic> -> Type,
423 h: Final(~O, ~f, ~P, ~ia, ~ib, operation, plan, left, left_fill, left_ops, right, right_fill, right_ops, shape,
424 Shape.logical_numel(Shape.dimensions(shape)), Q)) ->
425 @-left_fits: {Lifecycle.logical_length(Replayed.storage(left, left_fill, left_ops)) == Shape.logical_numel(Shape.dimensions(left)) : Nat} ->
426 @-right_fits: {Lifecycle.logical_length(Replayed.storage(right, right_fill, right_ops)) == Shape.logical_numel(Shape.dimensions(right)) : Nat} ->
427 Q(Pointwise.run(~O, ~f, ~P, ~ia, ~ib, operation, plan, shape,
428 Core.Packed{left, Core.TTensor{Replayed.storage(left, left_fill, left_ops), left_fits}},
429 Core.Packed{right, Core.TTensor{Replayed.storage(right, right_fill, right_ops), right_fits}})):
430 left_fits => right_fits =>
431 Replayed.new_lift(shape, 0.0,
432 result => Q(Pointwise.allocated(~O, ~f, ~P, ~ia, ~ib, operation, plan, shape,
433 Core.Packed{left, Core.TTensor{Replayed.storage(left, left_fill, left_ops), left_fits}},
434 Core.Packed{right, Core.TTensor{Replayed.storage(right, right_fill, right_ops), right_fits}}, result)),
435 output_fits => start_cast(~O, ~f, ~P, ~ia, ~ib, Shape.elements(shape), operation, plan, left, left_fill, left_ops,
436 right, right_fill, right_ops, shape, Q,
437 loop_lift(~O, ~f, ~P, ~ia, ~ib, Shape.elements(shape), operation, plan, left, left_fill, left_ops, right, right_fill, right_ops,
438 shape, 0n, Shape.elements_exact(shape), left_inside, right_inside, Q, h))(left_fits, right_fits, output_fits))