def offset_spec

bendtorch-core@0.1.0.0 · src/tensor/projection_LAWS.bend:16

import bendtorch-core@0.1.0.0/src/tensor/projection_LAWS.bend as ProjectionLAWS
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
import bendtorch-core@0.1.0.0/src/shape/LAWS.bend as ShapeLaws

16def offset_spec(+plan: Shape.BroadcastPlan, +position: Nat) -> Maybe<&1, U32 & U32>:
17  +left = Shape.extents(Shape.left_shape(plan))
18  +right = Shape.extents(Shape.right_shape(plan))
19  +output = Shape.extents(Shape.output_shape(plan))
20  +index = ShapeLaws.fin_of(Shape.numel(output), position)
21  pair_offsets(
22    ShapeLaws.flatten_spec(left, ShapeLaws.project_left_coordinate(left, right, output, Shape.alignment(plan), index)),
23    ShapeLaws.flatten_spec(right, ShapeLaws.project_right_coordinate(left, right, output, Shape.alignment(plan), index)))

Uses (16)

Used by (17)