law broadcast_pointwise

bendtorch-core@0.1.0.0 · src/tensor/contracts/LAWS.bend:49

import bendtorch-core@0.1.0.0/src/tensor/contracts/LAWS.bend as LAWS
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/elementwise.bend as Elementwise
import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
import bendtorch-core@0.1.0.0/src/tensor/contracts/broadcast.bend as Broadcast
import bendtorch-core@0.1.0.0/src/tensor/contracts/pointwise_records.bend as Records

49# Pointwise family, broadcast instance: for every operation, broadcast plan
50# and pair of replayed inputs, the output has the plan's output dimensions,
51# holds `Elementwise.scalar(operation, left[ia(i)], right[ib(i)])` at every
52# in-bounds index i, and both returned inputs keep every word.
53law broadcast_pointwise:
54  for +operation: Elementwise.Operation
55  for +plan: Shape.BroadcastPlan
56  for +left_fill: F32
57  for +left_ops: List<&2, StorageLaws.Op>
58  for -left_fits: {Lifecycle.logical_length(Replayed.storage(Shape.left_shape(plan), left_fill, left_ops)) ==
59    Shape.logical_numel(Shape.dimensions(Shape.left_shape(plan))) : Nat}
60  for +right_fill: F32
61  for +right_ops: List<&2, StorageLaws.Op>
62  for -right_fits: {Lifecycle.logical_length(Replayed.storage(Shape.right_shape(plan), right_fill, right_ops)) ==
63    Shape.logical_numel(Shape.dimensions(Shape.right_shape(plan))) : Nat}
64  Records.PointwiseContract<Shape.output_shape(plan), Shape.left_shape(plan), Shape.right_shape(plan),
65    index => Broadcast.cell(operation, plan, left_fill, left_ops, right_fill, right_ops, index),
66    other => Replayed.value(Shape.left_shape(plan), left_fill, left_ops, other),
67    other => Replayed.value(Shape.right_shape(plan), right_fill, right_ops, other),
68    Broadcast.binary(operation, plan,
69      Core.Packed{Shape.left_shape(plan), Core.TTensor{Replayed.storage(Shape.left_shape(plan), left_fill, left_ops), left_fits}},
70      Core.Packed{Shape.right_shape(plan), Core.TTensor{Replayed.storage(Shape.right_shape(plan), right_fill, right_ops), right_fits}})>

Uses (20)

Used by (0)

No other definition uses this definition.