def shapes_checked

bendtorch-core@0.1.0.0 · src/autograd/reduce_to_fold_PROOF.bend:64

import bendtorch-core@0.1.0.0/src/autograd/reduce_to_fold_PROOF.bend as ReduceToFoldPROOF
import Base
import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape

64def shapes_checked(+left: Shape.Shape, +right: Shape.Shape) ->
65  {planned_shapes(left, right, Shape.broadcast_checked(left, right)) == (left, right) : Shape.Shape & Shape.Shape}:
66  +left_rank = Shape.rank_dimensions(Shape.dimensions(left))
67  +right_rank = Shape.rank_dimensions(Shape.dimensions(right))
68  shapes_align(left, right, Nat.sub(right_rank, left_rank), Nat.sub(left_rank, right_rank), Shape.minimal(left_rank, right_rank),
69    Shape.align(Shape.pad_words(Nat.sub(right_rank, left_rank), Shape.dimensions(left)),
70      Shape.pad_words(Nat.sub(left_rank, right_rank), Shape.dimensions(right))))

Uses (12)

Used by (1)