Skip to content

Commit

Permalink
improving ttkernel conversion tests: part 1 (#2282)
Browse files Browse the repository at this point in the history
### Ticket
This is part 1 of #2068. More dialect ops will be covered but I would
like to get the new lit test form into main as an example for future
tests.

### Problem description
Existing lit tests for ttkernel seemed to be in a form of one func that
tests several ops in one monolithic block.

### What's changed

- the test has been split into func-per-op, in the style of MLIR's own
dialects like arith
- better regex matching is used to validate the ordering of param
passing in lowered form
- several ops confirmed to be unused/never tested removed from the
dialect
  • Loading branch information
vroubtsovTT authored Feb 25, 2025
1 parent b3c4cfb commit ceff7fe
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 452 deletions.
90 changes: 0 additions & 90 deletions include/ttmlir/Dialect/TTKernel/IR/TTKernelOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -20,51 +20,6 @@ def AnyMemRefOrCB: AnyTypeOf<[AnyNon0RankedMemRef, TTKernel_CB]>;
// TTKernel Register operations
//===----------------------------------------------------------------------===//

def TTKernel_PackSetDataTypeOp : TTKernel_Op<"pack_set_data_type"> {
let summary = "Pack set DataType op.";
let description = [{
Pack set DataType operation
}];

let arguments = (ins TT_DataType:$data_type);
}

def TTKernel_UnpackSetDataTypeOp : TTKernel_Op<"unpack_set_data_type"> {
let summary = "Unpack set DataType op.";
let description = [{
Unpack set DataType operation
}];

let arguments = (ins TT_DataType:$data_type_a, TT_DataType:$data_type_b);
}

def TTKernel_PackOp : TTKernel_Op<"pack"> {
let summary = "Pack op.";
let description = [{
Pack operation
}];

let arguments = (ins I32:$dst_index, TTKernel_CB:$out_cb, I32:$out_index);
}

def TTKernel_UnpackAOp : TTKernel_Op<"unpack_a"> {
let summary = "UnpackA op.";
let description = [{
UnpackA operation
}];

let arguments = (ins TTKernel_CB:$cb, I32:$src_index);
}

def TTKernel_UnpackABOp : TTKernel_Op<"unpack_ab"> {
let summary = "UnpackAB op.";
let description = [{
UnpackAB operation
}];

let arguments = (ins TTKernel_CB:$cb_a, I32:$src_a_index, TTKernel_CB:$cb_b, I32:$src_b_index);
}

def TTKernel_TileRegsAcquireOp : TTKernel_Op<"tile_regs_acquire"> {
let summary = "tile_regs_acquire";
let description = [{
Expand Down Expand Up @@ -155,51 +110,6 @@ def TTKernel_CopyTileOp : TTKernel_Op<"copy_tile"> {
// TTKernel FPU operations
//===----------------------------------------------------------------------===//

def TTKernel_AddOp : TTKernel_Op<"add"> {
let summary = "Add operation";
let description = [{
Add operation
}];

let arguments = (ins I32:$dst_index);
}

def TTKernel_SubOp : TTKernel_Op<"sub"> {
let summary = "Sub operation";
let description = [{
Sub operation
}];

let arguments = (ins I32:$dst_index);
}

def TTKernel_MulOp : TTKernel_Op<"mul"> {
let summary = "Mul operation";
let description = [{
Mul operation
}];

let arguments = (ins I32:$dst_index);
}

def TTKernel_MaxOp : TTKernel_Op<"max"> {
let summary = "Max operation";
let description = [{
Max operation
}];

let arguments = (ins I32:$dst_index);
}

def TTKernel_MatmulOp : TTKernel_Op<"matmul"> {
let summary = "Matmul operation";
let description = [{
Matmul operation
}];

let arguments = (ins I32:$dst_index);
}

def TTKernel_BinaryOpInitCommonOp : TTKernel_Op<"binary_op_init_common"> {
let summary = "Init function for all binary ops";
let description = [{
Expand Down
3 changes: 0 additions & 3 deletions python/pykernel/pykernel_ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,8 @@ class TTKernelCompiler(ast.NodeVisitor):
"tile_regs_release": ttkernel.tile_regs_release,
"tile_regs_commit": ttkernel.tile_regs_commit,
"tile_regs_wait": ttkernel.tile_regs_wait,
"pack": ttkernel.pack,
"pack_tile": ttkernel.pack_tile,
"copy_tile": ttkernel.copy_tile,
"unpack_a": ttkernel.unpack_a,
"unpack_ab": ttkernel.unpack_ab,
"add": ttkernel.add,
"add_tiles": ttkernel.add_tiles,
"get_compile_time_arg_val": ttkernel.get_compile_time_arg_val,
Expand Down
Loading

0 comments on commit ceff7fe

Please sign in to comment.