src/tensor/layout.bend checks
raw source on the hub · import bendtorch-core@0.1.0.0/src/tensor/layout.bend as Layout
3 imports
import Base import ../shape/core.bend as Shape import ./axis_spec.bend as Axis
Types
type Error source · line 5 · raw
Data
ShapeError@error:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error -> Error
AxesLengthMismatchError
AxisOutOfBoundsError
DuplicateAxisError
ElementCountMismatchError
MappingErrorError
type Plan source · line 86 · raw
@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> Data
Permutation@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> @output:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @valid:{True{} == bijective(input, axes) : Bool} -> @ordered:{Some{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output)} == reorder(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes) : Maybe<&2, List<&2, U32>>} -> @count:{True{} == Nat.is_eq(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.elements(input), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.elements(output)) : Bool} -> Plan<input, axes>
type WordsValidStep source · line 207 · raw
@-dimension:U32 -> @-dt:List<&2, U32> -> @-coordinate:U32 -> @-ct:List<&2, U32> -> Data
WStep@-dimension:U32 -> @-dt:List<&2, U32> -> @-coordinate:U32 -> @-ct:List<&2, U32> -> @bound:{True{} == U32.is_lt(coordinate, dimension) : Bool} -> @tail:WordsValid(dt, ct) -> WordsValidStep<dimension, dt, coordinate, ct>
type CheckedCoordinate source · line 246 · raw
@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> Data
CWord@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @values:List<&2, U32> -> @valid:WordsValid(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(shape), values) -> CheckedCoordinate<shape>
type FlatIndex source · line 253 · raw
@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> Data
FIndex@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @value:U32 -> @valid:{True{} == U32.is_lt(value, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.count(shape)) : Bool} -> FlatIndex<shape>
type Mapping source · line 288 · raw
@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> @-plan:Plan<input, axes> -> @-i:U32 -> Data
Mapped@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> @-plan:Plan<input, axes> -> @-i:U32 -> @output_index:FlatIndex<output(input, axes, plan)> -> @output_coordinate:CheckedCoordinate<output(input, axes, plan)> -> @input_coordinate:CheckedCoordinate<input> -> @index:FlatIndex<input> -> @requested:{index_value(output(input, axes, plan), output_index) == i : U32} -> @decoded:{coordinate_values(output(input, axes, plan), output_coordinate) == reverse_words(unflatten_words(reverse_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output(input, axes, plan))), i)) : List<&2, U32>} -> @inverse:{Some{coordinate_values(input, input_coordinate)} == inverse_coordinates(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes, coordinate_values(output(input, axes, plan), output_coordinate), 0) : Maybe<&2, List<&2, U32>>} -> @flattened:{index_value(input, index) == flatten_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), coordinate_values(input, input_coordinate), 0) : U32} -> @roundtrip:{True{} == maybe_same(reorder(coordinate_values(input, input_coordinate), axes), Some{coordinate_values(output(input, axes, plan), output_coordinate)}) : Bool} -> Mapping<input, axes, plan, i>
Definitions
def contains source · line 13 · raw
@+axis:U32 -> @axes:List<&2, U32> -> Bool
def unique source · line 20 · raw
@axes:List<&2, U32> -> Bool
def bounded source · line 27 · raw
@axes:List<&2, U32> -> @+rank:U32 -> Bool
def bijective source · line 34 · raw
@+shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> Bool
def lookup source · line 38 · raw
@values:List<&2, U32> -> @index:Nat -> Maybe<&2, U32>
def reorder_tail source · line 47 · raw
@head:U32 -> @result:Maybe<&2, List<&2, U32>> -> Maybe<&2, List<&2, U32>>
def reorder_head source · line 54 · raw
@rec:(@_:U32 -> Maybe<&2, List<&2, U32>>) -> @head:Maybe<&2, U32> -> Maybe<&2, List<&2, U32>>
def reorder source · line 61 · raw
@+values:List<&2, U32> -> @axes:List<&2, U32> -> Maybe<&2, List<&2, U32>>
def coordinate_for source · line 68 · raw
@axes:List<&2, U32> -> @coordinates:List<&2, U32> -> @+axis:U32 -> Maybe<&2, U32>
def inverse_coordinates source · line 77 · raw
@dimensions:List<&2, U32> -> @+axes:List<&2, U32> -> @+coordinates:List<&2, U32> -> @+axis:U32 -> Maybe<&2, List<&2, U32>>
def output source · line 92 · raw
@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> @plan:Plan<input, axes> -> 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape
def plan_counted source · line 96 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+out:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @valid:{True{} == bijective(input, axes) : Bool} -> @ordered:{Some{0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(out)} == reorder(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes) : Maybe<&2, List<&2, U32>>} -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<Nat.is_eq(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.elements(input), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.elements(out))> -> Result<&2, &2, Error, Plan<input, axes>>
def plan_built source · line 107 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @-dimensions:List<&2, U32> -> @valid:{True{} == bijective(input, axes) : Bool} -> @selected:{Some{dimensions} == reorder(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes) : Maybe<&2, List<&2, U32>>} -> @built:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.ConstructResult<dimensions> -> Result<&2, &2, Error, Plan<input, axes>>
def plan_selected source · line 121 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @valid:{True{} == bijective(input, axes) : Bool} -> @selected:Maybe<&2, List<&2, U32>> -> @same:{selected == reorder(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes) : Maybe<&2, List<&2, U32>>} -> Result<&2, &2, Error, Plan<input, axes>>
def plan_decided source · line 130 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<bijective(input, axes)> -> Result<&2, &2, Error, Plan<input, axes>>
def plan_unique source · line 138 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<unique(axes)> -> Result<&2, &2, Error, Plan<input, axes>>
def plan_bounded source · line 146 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<bounded(axes, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.rank(input))> -> Result<&2, &2, Error, Plan<input, axes>>
def plan_ranked source · line 154 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<Nat.is_eq(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.rank_dimensions(axes), 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.rank_dimensions(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input)))> -> Result<&2, &2, Error, Plan<input, axes>>
def permutation source · line 163 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> Result<&2, &2, Error, Plan<input, axes>>
def transpose_axes source · line 167 · raw
@dimensions:List<&2, U32> -> @+a:U32 -> @+b:U32 -> @+i:U32 -> List<&2, U32>
def word_same source · line 175 · raw
@n:Nat -> @a:Word(n) -> @b:Word(n) -> Bool
def word_value_same source · line 184 · raw
@a:U32 -> @b:U32 -> Bool
def words_same source · line 189 · raw
@a:List<&2, U32> -> @b:List<&2, U32> -> Bool
def maybe_same source · line 198 · raw
@a:Maybe<&2, List<&2, U32>> -> @b:Maybe<&2, List<&2, U32>> -> Bool
def WordsValid source · line 210 · raw
@dims:List<&2, U32> -> @coordinates:List<&2, U32> -> Data
def words_finish source · line 219 · raw
@-dimension:U32 -> @-dt:List<&2, U32> -> @-coordinate:U32 -> @-ct:List<&2, U32> -> @bound:{True{} == U32.is_lt(coordinate, dimension) : Bool} -> @result:Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, WordsValid(dt, ct)> -> Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, WordsValid(dimension <> dt, coordinate <> ct)>
def words_decided source · line 228 · raw
@+dimension:U32 -> @-dt:List<&2, U32> -> @+coordinate:U32 -> @-ct:List<&2, U32> -> @rec:(@_:Unit -> Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, WordsValid(dt, ct)>) -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<U32.is_lt(coordinate, dimension)> -> Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, WordsValid(dimension <> dt, coordinate <> ct)>
def words_check source · line 237 · raw
@+dims:List<&2, U32> -> @+coordinates:List<&2, U32> -> Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, WordsValid(dims, coordinates)>
def coordinate_values source · line 249 · raw
@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @coordinate:CheckedCoordinate<shape> -> List<&2, U32>
def index_value source · line 256 · raw
@-shape:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @index:FlatIndex<shape> -> U32
def flatten_words source · line 260 · raw
@dims:List<&2, U32> -> @coordinates:List<&2, U32> -> @accumulator:U32 -> U32
def reverse_words_go source · line 263 · raw
@values:List<&2, U32> -> @accumulator:List<&2, U32> -> List<&2, U32>
def reverse_words source · line 270 · raw
@values:List<&2, U32> -> List<&2, U32>
def unflatten_words source · line 273 · raw
@reversed_dimensions:List<&2, U32> -> @+index:U32 -> List<&2, U32>
def reference_source_coordinates source · line 276 · raw
@+dimensions:List<&2, U32> -> @coordinates:Maybe<&2, List<&2, U32>> -> Maybe<&2, U32>
def reference_source source · line 283 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @index:U32 -> Maybe<&2, U32>
def source_index source · line 303 · raw
@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> @-plan:Plan<input, axes> -> @-i:U32 -> @mapping:Mapping<input, axes, plan, i> -> U32
def output_words source · line 308 · raw
@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> @-plan:Plan<input, axes> -> @-i:U32 -> @mapping:Mapping<input, axes, plan, i> -> List<&2, U32>
def input_words source · line 313 · raw
@-input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @-axes:List<&2, U32> -> @-plan:Plan<input, axes> -> @-i:U32 -> @mapping:Mapping<input, axes, plan, i> -> List<&2, U32>
def map_flat source · line 318 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @+i:U32 -> @oi:FlatIndex<output(input, axes, plan)> -> @oc:CheckedCoordinate<output(input, axes, plan)> -> @+ic:CheckedCoordinate<input> -> @requested:{index_value(output(input, axes, plan), oi) == i : U32} -> @decoded:{coordinate_values(output(input, axes, plan), oc) == reverse_words(unflatten_words(reverse_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output(input, axes, plan))), i)) : List<&2, U32>} -> @inverse:{Some{coordinate_values(input, ic)} == inverse_coordinates(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes, coordinate_values(output(input, axes, plan), oc), 0) : Maybe<&2, List<&2, U32>>} -> @roundtrip:{True{} == maybe_same(reorder(coordinate_values(input, ic), axes), Some{coordinate_values(output(input, axes, plan), oc)}) : Bool} -> @+j:U32 -> @flat:{j == flatten_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), coordinate_values(input, ic), 0) : U32} -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<U32.is_lt(j, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.count(input))> -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>
def map_roundtrip source · line 336 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @+i:U32 -> @oi:FlatIndex<output(input, axes, plan)> -> @+oc:CheckedCoordinate<output(input, axes, plan)> -> @+ic:CheckedCoordinate<input> -> @requested:{index_value(output(input, axes, plan), oi) == i : U32} -> @decoded:{coordinate_values(output(input, axes, plan), oc) == reverse_words(unflatten_words(reverse_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output(input, axes, plan))), i)) : List<&2, U32>} -> @inverse:{Some{coordinate_values(input, ic)} == inverse_coordinates(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes, coordinate_values(output(input, axes, plan), oc), 0) : Maybe<&2, List<&2, U32>>} -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<maybe_same(reorder(coordinate_values(input, ic), axes), Some{coordinate_values(output(input, axes, plan), oc)})> -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>
def map_input source · line 354 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @+i:U32 -> @oi:FlatIndex<output(input, axes, plan)> -> @+oc:CheckedCoordinate<output(input, axes, plan)> -> @requested:{index_value(output(input, axes, plan), oi) == i : U32} -> @decoded:{coordinate_values(output(input, axes, plan), oc) == reverse_words(unflatten_words(reverse_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output(input, axes, plan))), i)) : List<&2, U32>} -> @+words:List<&2, U32> -> @inverse:{Some{words} == inverse_coordinates(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes, coordinate_values(output(input, axes, plan), oc), 0) : Maybe<&2, List<&2, U32>>} -> @checked:Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, WordsValid(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), words)> -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>
def map_inverse source · line 371 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @+i:U32 -> @oi:FlatIndex<output(input, axes, plan)> -> @+oc:CheckedCoordinate<output(input, axes, plan)> -> @requested:{index_value(output(input, axes, plan), oi) == i : U32} -> @decoded:{coordinate_values(output(input, axes, plan), oc) == reverse_words(unflatten_words(reverse_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output(input, axes, plan))), i)) : List<&2, U32>} -> @result:Maybe<&2, List<&2, U32>> -> @same:{result == inverse_coordinates(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(input), axes, coordinate_values(output(input, axes, plan), oc), 0) : Maybe<&2, List<&2, U32>>} -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>
def map_output source · line 386 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @+i:U32 -> @oi:FlatIndex<output(input, axes, plan)> -> @requested:{index_value(output(input, axes, plan), oi) == i : U32} -> @+words:List<&2, U32> -> @decoded:{words == reverse_words(unflatten_words(reverse_words(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output(input, axes, plan))), i)) : List<&2, U32>} -> @checked:Result<&2, &2, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Error, WordsValid(0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.dimensions(output(input, axes, plan)), words)> -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>
def map_decided source · line 401 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @+i:U32 -> @decision:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.BoolCase<U32.is_lt(i, 0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.count(output(input, axes, plan)))> -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>
def map_index source · line 412 · raw
@+input:0x1689e5deb278c16abd3bd45eac101ef3/src/shape/core.Shape -> @+axes:List<&2, U32> -> @+plan:Plan<input, axes> -> @+i:U32 -> Result<&2, &2, Error, Mapping<input, axes, plan, i>>