src/tensor/permute_values_contract_LAWS.bend
bendtorch-core@0.1.0.0 · 68 lines · 4 definitions
1import Base
2import bendtorch-core@0.1.0.0/src/shape/core.bend as Shape
3import bendtorch-core@0.1.0.0/src/tensor/layout.bend as Layout
4import bendtorch-core@0.1.0.0/src/tensor/transpose_spec.bend as Transpose
5import bendtorch-core@0.1.0.0/src/tensor/permute_values_records.bend as Records
6import bendtorch-core@0.1.0.0/src/storage/LAWS.bend as StorageLaws
7import bendtorch-core@0.1.0.0/src/tensor/core.bend as Core
8import bendtorch-core@0.1.0.0/src/tensor/lifecycle.bend as Lifecycle
9import bendtorch-core@0.1.0.0/src/tensor/transforms.bend as Transforms
10import bendtorch-core@0.1.0.0/src/tensor/contracts/replayed.bend as Replayed
11
12
13
14
15
16law permute_contract:
17 for +input: Shape.Shape
18 for +values: List<&2, F32>
19 for counted: {List.length(&2, F32, values) == Shape.logical_numel(Shape.dimensions(input)) : Nat}
20 for +axes: List<&2, U32>
21 for valid: {True{} == Layout.bijective(input, axes) : Bool}
22 Records.PermuteContract<input, values, axes>
23
24
25
26law transpose_contract:
27 for +input: Shape.Shape
28 for +values: List<&2, F32>
29 for counted: {List.length(&2, F32, values) == Shape.logical_numel(Shape.dimensions(input)) : Nat}
30 for +a: U32
31 for +b: U32
32 for inside: {True{} == Transpose.valid(input, a, b) : Bool}
33 Records.TransposeContract<input, values, a, b>
34
35
36
37
38
39
40
41law permute_replayed:
42 for +input: Shape.Shape
43 for +fill: F32
44 for +ops: List<&2, StorageLaws.Op>
45 for -fits: {Lifecycle.logical_length(Replayed.storage(input, fill, ops)) == Shape.logical_numel(Shape.dimensions(input)) : Nat}
46 for +axes: List<&2, U32>
47 for +plan: Layout.Plan<input, axes>
48 for laid: {Layout.permutation(input, axes) == Done{plan} : Result<&2, &2, Layout.Error, Layout.Plan<input, axes>>}
49 for -P: Core.Dynamic & Result<&2, &1, Transforms.Error, Core.Dynamic> -> Type
50 for h: Records.PermutedWith(input, fill, ops, axes, plan, P)
51 P(Transforms.permute_dynamic(Core.Packed{input, Core.TTensor{Replayed.storage(input, fill, ops), fits}}, axes))
52
53
54
55law transpose_replayed:
56 for +input: Shape.Shape
57 for +fill: F32
58 for +ops: List<&2, StorageLaws.Op>
59 for -fits: {Lifecycle.logical_length(Replayed.storage(input, fill, ops)) == Shape.logical_numel(Shape.dimensions(input)) : Nat}
60 for +a: U32
61 for +b: U32
62 for inside: {True{} == Transpose.valid(input, a, b) : Bool}
63 for +plan: Layout.Plan<input, Transpose.swapped_axes(input, a, b)>
64 for laid: {Layout.permutation(input, Transpose.swapped_axes(input, a, b)) == Done{plan} :
65 Result<&2, &2, Layout.Error, Layout.Plan<input, Transpose.swapped_axes(input, a, b)>>}
66 for -P: Core.Dynamic & Result<&2, &1, Transforms.Error, Core.Dynamic> -> Type
67 for h: Records.PermutedWith(input, fill, ops, Transpose.swapped_axes(input, a, b), plan, P)
68 P(Transforms.transpose_dynamic(Core.Packed{input, Core.TTensor{Replayed.storage(input, fill, ops), fits}}, a, b))