law broadcast_to_pointwise

bendtorch-core@0.1.0.0 · src/autograd/broadcast_pointwise_LAWS.bend:76

import bendtorch-core@0.1.0.0/src/autograd/broadcast_pointwise_LAWS.bend as BroadcastPointwiseLAWS
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/broadcast.bend as PointwiseBroadcast
import bendtorch-core@0.1.0.0/src/autograd/broadcast.bend as Broadcast

76# Pointwise family, broadcast_to instance: when the input shape broadcasts to
77# exactly the target, broadcasting a replayed input succeeds with the target's
78# dimensions, output index i holds the input word at left_map(plan, i), its
79# right-aligned broadcast projection, and the returned input keeps every word.
80law broadcast_to_pointwise:
81  for +shape: Shape.Shape
82  for +target: Shape.Shape
83  for +plan: Shape.BroadcastPlan
84  for planned: {Shape.broadcast_checked(shape, target) == Done{plan} : Result<&2, &2, Shape.Error, Shape.BroadcastPlan>}
85  for same: {Shape.dimensions(Shape.output_shape(plan)) == Shape.dimensions(target) : List<&2, U32>}
86  for +fill: F32
87  for +ops: List<&2, StorageLaws.Op>
88  for -fits: {Lifecycle.logical_length(Replayed.storage(shape, fill, ops)) == Shape.logical_numel(Shape.dimensions(shape)) : Nat}
89  BroadcastToContract<target, shape,
90    index => Replayed.value(shape, fill, ops, U32.from_nat(PointwiseBroadcast.left_map(plan, index))),
91    other => Replayed.value(shape, fill, ops, other),
92    Broadcast.broadcast_to(Core.Packed{shape, Core.TTensor{Replayed.storage(shape, fill, ops), fits}}, target)>

Uses (23)

Used by (1)