Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions KLR/Trace/ISA.lean
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ def converRevOps (reverse0 : Bool) (reverse1 : Bool) : TensorScalarReverseOps :=
| false, true => .second
| true, true => .both

def dimsFromPythonDefs (dims : Int) (d : Sum Int (List Int)) : Trace TensorSubDim :=
def dimsFromPythonDefs (d : Sum Int (List Int)) : Trace TensorSubDim :=
match d with
| .inl 1 => return .X
| .inl _ => throw "not a valid dim"
| .inr r => do
if r == [dims-1] then return .X -- last dim, 2d+ case
if r == [dims-2, dims-1] then return .XY -- last 2 dims, 3d+ case
if r == [dims-3, dims-2, dims-1] then return .XYZ -- last 3 dims, 4d+ case
if r == [dims-4, dims-3, dims-2, dims-1] then return .XYZW -- last 4 dims, 5d case
throw "not a valid dim"
| .inr r => match r with
| [4] => return .X
| [3, 4] => return .XY
| [2, 3, 4] => return .XYZ
| [1, 2, 3, 4] => return .XYZW
| _ => throw "not a valid dim"

def getTransposeOps(op: Option (List Int)) : Trace TransposeOps :=
match op with
Expand Down Expand Up @@ -284,7 +284,7 @@ nki builtin.isa.tensor_reduce
dst := .abstract dst,
src := .abstract data,
op := op,
opDim := <- dimsFromPythonDefs (<- data.shape).toList.length axis,
opDim := <- dimsFromPythonDefs axis,
dtype := dst.tensor.dtype,
negated := negate,
keepdims := keepdims
Expand Down
Loading