diff --git a/docs/src/ttrt.md b/docs/src/ttrt.md index c9a0da352..4a70aa708 100644 --- a/docs/src/ttrt.md +++ b/docs/src/ttrt.md @@ -93,4 +93,5 @@ d = ttrt.binary.as_dict(fbb) ``` ## bonus -artifacts are saved in ttrt-artifacts directory if the option `--save-artifacts` is provided +- artifacts are saved in ttrt-artifacts directory if the option `--save-artifacts` is provided +- you can specify `SYSTEM_DESC_PATH` with the path to your ttsys file, and lit will automatically generate all the flatbuffer binaries for that system diff --git a/runtime/tools/python/ttrt/common/api.py b/runtime/tools/python/ttrt/common/api.py index d475edd30..71b7d54e3 100644 --- a/runtime/tools/python/ttrt/common/api.py +++ b/runtime/tools/python/ttrt/common/api.py @@ -118,15 +118,18 @@ def run(args): print("executing constraint for all provided flatbuffers") system_desc, device_ids = ttrt.runtime.get_current_system_desc() program_indices = [] + cleaned_binaries = [] for binary in binaries: check_file_exists(binary) fbb = ttrt.binary.load_binary_from_path(binary) check_version(fbb.version) fbb_dict = ttrt.binary.as_dict(fbb) - assert ( - fbb_dict["system_desc"] == system_desc_as_dict(system_desc)["system_desc"] - ), f"system descriptor for binary and system mismatch!" + if fbb_dict["system_desc"] != system_desc_as_dict(system_desc)["system_desc"]: + print( + f"system descriptor for binary and system mismatch, ignoring test={binary}" + ) + continue if arg_program_index != "all": program_index = int(arg_program_index) @@ -145,6 +148,8 @@ def run(args): program_indices, ) ) + cleaned_binaries.append(binary) + binaries = cleaned_binaries # execution print("executing action for all provided flatbuffers") diff --git a/runtime/tools/python/ttrt/common/perf_trace.py b/runtime/tools/python/ttrt/common/perf_trace.py index fc91d6d48..749c89a67 100644 --- a/runtime/tools/python/ttrt/common/perf_trace.py +++ b/runtime/tools/python/ttrt/common/perf_trace.py @@ -156,22 +156,10 @@ def save_perf_artifacts(perf_folder): tracy_file = f"{TT_METAL_HOME}/generated/profiler/.logs/{TRACY_FILE_NAME}" try: - # check_file_exists(profiler_device_side_log_file) - # check_file_exists(profiler_host_device_sync_info_file) - # check_file_exists(profiler_log_location_record_file) check_file_exists(tracy_ops_times_file) check_file_exists(tracy_ops_data_file) check_file_exists(tracy_file) - # shutil.copy(profiler_device_side_log_file, os.path.join(perf_folder, "profiler_device_side_log_file.csv")) - # print(f"File '{profiler_device_side_log_file}' copied to '{perf_folder}' successfully.") - - # shutil.copy(profiler_host_device_sync_info_file, os.path.join(perf_folder, "profiler_host_device_sync_info_file.csv")) - # print(f"File '{profiler_host_device_sync_info_file}' copied to '{perf_folder}' successfully.") - - # shutil.copy(profiler_log_location_record_file, os.path.join(perf_folder, "profiler_log_location_record_file.log")) - # print(f"File '{profiler_log_location_record_file}' copied to '{perf_folder}' successfully.") - shutil.copy( tracy_ops_times_file, os.path.join(perf_folder, "tracy_ops_times_file.csv") ) @@ -187,3 +175,22 @@ def save_perf_artifacts(perf_folder): except Exception as e: print(f"An unexpected error occurred: {e}") + + # Copy datetime folder files into root perf directory + for root, dirs, files in os.walk(perf_folder, topdown=False): + if root == perf_folder: + continue + + for file_name in files: + # Full path of the file + file_path = os.path.join(root, file_name) + # Destination path in the parent folder + dest_path = os.path.join(perf_folder, file_name) + + # Move the file + shutil.move(file_path, dest_path) + print(f"Moved {file_path} to {dest_path}") + + # Remove the subfolder after moving the files + if not os.listdir(root): # Check if the directory is empty + os.rmdir(root) diff --git a/test/lit.cfg.py b/test/lit.cfg.py index 4b77f8c17..16ff1b310 100644 --- a/test/lit.cfg.py +++ b/test/lit.cfg.py @@ -33,8 +33,12 @@ # test_exec_root: The root path where tests should be run. config.test_exec_root = os.path.join(config.ttmlir_obj_root, "test") +# system_desc_path: The system desc that is to be used to generate the binary files. +config.system_desc_path = os.getenv("SYSTEM_DESC_PATH", "") + config.substitutions.append(("%PATH%", config.environment["PATH"])) config.substitutions.append(("%shlibext", config.llvm_shlib_ext)) +config.substitutions.append(("%system_desc_path%", config.system_desc_path)) llvm_config.with_system_environment(["HOME", "INCLUDE", "LIB", "TMP", "TEMP"]) diff --git a/test/ttmlir/Silicon/TTNN/multiple_add_with_loc.mlir b/test/ttmlir/Silicon/TTNN/multiple_add_with_loc.mlir deleted file mode 100644 index 7b0e4ed21..000000000 --- a/test/ttmlir/Silicon/TTNN/multiple_add_with_loc.mlir +++ /dev/null @@ -1,30 +0,0 @@ -// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline %s > %t.mlir -// RUN: FileCheck %s --input-file=%t.mlir -// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn - -#any_device = #tt.operand_constraint -#loc = loc("test_ops.py:17_0_0":0:0) -module @pybuda_graph attributes {} { - func.func @main(%arg0: tensor<1x32x32xf32> loc("test_ops.py:17_0_0":0:0), %arg1: tensor<1x32x32xf32> loc("test_ops.py:17_0_0":0:0), %arg2: tensor<1x32x32xf32> loc("test_ops.py:17_0_0":0:0)) -> (tensor<1x32x32xf32>, tensor<1x32x32xf32>) { - // CHECK: #layout1 = #tt.layout<(d0, d1, d2) -> (d0 * 32 + d1, d2), undef, <8x8>, memref<4x4xf32, #system>> - // CHECK: #layout2 = #tt.layout<(d0, d1, d2) -> (d0 * 32 + d1, d2), undef, <8x8>, memref<4x4xf32, #l1_>> - %0 = tensor.empty() : tensor<1x32x32xf32> loc(#loc5) - // CHECK: %[[C:.*]] = "ttnn.add"[[C:.*]] -> tensor<1x32x32xf32, #layout2> - %1 = "ttir.add"(%arg1, %arg2, %0) <{operandSegmentSizes = array, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<1x32x32xf32>, tensor<1x32x32xf32>, tensor<1x32x32xf32>) -> tensor<1x32x32xf32> loc(#loc5) - %2 = tensor.empty() : tensor<1x32x32xf32> loc(#loc6) - // CHECK: %[[C:.*]] = "ttnn.add"[[C:.*]] -> tensor<1x32x32xf32, #layout2> - %3 = "ttir.add"(%1, %arg0, %2) <{operandSegmentSizes = array, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<1x32x32xf32>, tensor<1x32x32xf32>, tensor<1x32x32xf32>) -> tensor<1x32x32xf32> loc(#loc6) - %4 = tensor.empty() : tensor<1x32x32xf32> loc(#loc7) - // CHECK: %[[C:.*]] = "ttnn.add"[[C:.*]] -> tensor<1x32x32xf32, #layout2> - %5 = "ttir.add"(%arg2, %arg1, %4) <{operandSegmentSizes = array, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<1x32x32xf32>, tensor<1x32x32xf32>, tensor<1x32x32xf32>) -> tensor<1x32x32xf32> loc(#loc7) - // CHECK: return %20, %22 : tensor<1x32x32xf32, #layout1>, tensor<1x32x32xf32, #layout1> - return %3, %5 : tensor<1x32x32xf32>, tensor<1x32x32xf32> loc(#loc4) - } loc(#loc) -} loc(#loc) -#loc1 = loc("test_ops.py:17_0_0":0:4) -#loc2 = loc("test_ops.py:17_0_0":0:6) -#loc3 = loc("test_ops.py:17_0_0":0:3) -#loc4 = loc(unknown) -#loc5 = loc("add_1_0"(#loc1)) -#loc6 = loc("add_2_0"(#loc2)) -#loc7 = loc("add_0"(#loc3)) diff --git a/test/ttmlir/Silicon/TTNN/multiple_add_with_loc_grid_override.mlir b/test/ttmlir/Silicon/TTNN/multiple_add_with_loc_grid_override.mlir deleted file mode 100644 index 26e3d2356..000000000 --- a/test/ttmlir/Silicon/TTNN/multiple_add_with_loc_grid_override.mlir +++ /dev/null @@ -1,31 +0,0 @@ -// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="override-grid-sizes=add_1_0=4x4,add_2_0=4x4" %s > %t.mlir -// RUN: FileCheck %s --input-file=%t.mlir -// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn - -#any_device = #tt.operand_constraint -#loc = loc("test_ops.py:17_0_0":0:0) -module @pybuda_graph attributes {} { - func.func @main(%arg0: tensor<1x32x32xf32> loc("test_ops.py:17_0_0":0:0), %arg1: tensor<1x32x32xf32> loc("test_ops.py:17_0_0":0:0), %arg2: tensor<1x32x32xf32> loc("test_ops.py:17_0_0":0:0)) -> (tensor<1x32x32xf32>, tensor<1x32x32xf32>) { - // CHECK: #layout1 = #tt.layout<(d0, d1, d2) -> (d0 * 32 + d1, d2), undef, <8x8>, memref<4x4xf32, #system>> - // CHECK: #layout2 = #tt.layout<(d0, d1, d2) -> (d0 * 32 + d1, d2), undef, <4x4>, memref<8x8xf32, #l1_>> - // CHECK: #layout3 = #tt.layout<(d0, d1, d2) -> (d0 * 32 + d1, d2), undef, <8x8>, memref<4x4xf32, #l1_>> - %0 = tensor.empty() : tensor<1x32x32xf32> loc(#loc5) - // CHECK: %[[C:.*]] = "ttnn.add"[[C:.*]] -> tensor<1x32x32xf32, #layout2> - %1 = "ttir.add"(%arg1, %arg2, %0) <{operandSegmentSizes = array, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<1x32x32xf32>, tensor<1x32x32xf32>, tensor<1x32x32xf32>) -> tensor<1x32x32xf32> loc(#loc5) - %2 = tensor.empty() : tensor<1x32x32xf32> loc(#loc6) - // CHECK: %[[C:.*]] = "ttnn.add"[[C:.*]] -> tensor<1x32x32xf32, #layout2> - %3 = "ttir.add"(%1, %arg0, %2) <{operandSegmentSizes = array, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<1x32x32xf32>, tensor<1x32x32xf32>, tensor<1x32x32xf32>) -> tensor<1x32x32xf32> loc(#loc6) - %4 = tensor.empty() : tensor<1x32x32xf32> loc(#loc7) - // CHECK: %[[C:.*]] = "ttnn.add"[[C:.*]] -> tensor<1x32x32xf32, #layout3> - %5 = "ttir.add"(%arg2, %arg1, %4) <{operandSegmentSizes = array, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<1x32x32xf32>, tensor<1x32x32xf32>, tensor<1x32x32xf32>) -> tensor<1x32x32xf32> loc(#loc7) - // CHECK: return %20, %22 : tensor<1x32x32xf32, #layout1>, tensor<1x32x32xf32, #layout1> - return %3, %5 : tensor<1x32x32xf32>, tensor<1x32x32xf32> loc(#loc4) - } loc(#loc) -} loc(#loc) -#loc1 = loc("test_ops.py:17_0_0":0:4) -#loc2 = loc("test_ops.py:17_0_0":0:6) -#loc3 = loc("test_ops.py:17_0_0":0:3) -#loc4 = loc(unknown) -#loc5 = loc("add_1_0"(#loc1)) -#loc6 = loc("add_2_0"(#loc2)) -#loc7 = loc("add_0"(#loc3)) diff --git a/test/ttmlir/Silicon/TTNN/simple_eltwise.mlir b/test/ttmlir/Silicon/TTNN/simple_eltwise.mlir index ec071709f..cdf53ffac 100644 --- a/test/ttmlir/Silicon/TTNN/simple_eltwise.mlir +++ b/test/ttmlir/Silicon/TTNN/simple_eltwise.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-load-system-desc --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn diff --git a/test/ttmlir/Silicon/TTNN/simple_ge.mlir b/test/ttmlir/Silicon/TTNN/simple_ge.mlir index 7e65fbe36..66081bbce 100644 --- a/test/ttmlir/Silicon/TTNN/simple_ge.mlir +++ b/test/ttmlir/Silicon/TTNN/simple_ge.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-load-system-desc --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn diff --git a/test/ttmlir/Silicon/TTNN/simple_matmul.mlir b/test/ttmlir/Silicon/TTNN/simple_matmul.mlir index 697ead5da..c97518ce7 100644 --- a/test/ttmlir/Silicon/TTNN/simple_matmul.mlir +++ b/test/ttmlir/Silicon/TTNN/simple_matmul.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-load-system-desc --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn diff --git a/test/ttmlir/Silicon/TTNN/simple_multiply.mlir b/test/ttmlir/Silicon/TTNN/simple_multiply.mlir index 07bf4c0c5..ac0b95413 100644 --- a/test/ttmlir/Silicon/TTNN/simple_multiply.mlir +++ b/test/ttmlir/Silicon/TTNN/simple_multiply.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-load-system-desc --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn diff --git a/test/ttmlir/Silicon/TTNN/simple_relu.mlir b/test/ttmlir/Silicon/TTNN/simple_relu.mlir index d01f08c5f..3d017ab6e 100644 --- a/test/ttmlir/Silicon/TTNN/simple_relu.mlir +++ b/test/ttmlir/Silicon/TTNN/simple_relu.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-load-system-desc --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn diff --git a/test/ttmlir/Silicon/TTNN/simple_subtract.mlir b/test/ttmlir/Silicon/TTNN/simple_subtract.mlir index f216ba6cf..b1c63ee06 100644 --- a/test/ttmlir/Silicon/TTNN/simple_subtract.mlir +++ b/test/ttmlir/Silicon/TTNN/simple_subtract.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-load-system-desc --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn diff --git a/test/ttmlir/Silicon/TTNN/simple_sum.mlir b/test/ttmlir/Silicon/TTNN/simple_sum.mlir index fec8f943b..efd346f8c 100644 --- a/test/ttmlir/Silicon/TTNN/simple_sum.mlir +++ b/test/ttmlir/Silicon/TTNN/simple_sum.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-load-system-desc --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-implicit-device --ttir-layout --ttnn-open-device --convert-ttir-to-ttnn %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn diff --git a/test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline.mlir b/test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline.mlir deleted file mode 100644 index 12dad419f..000000000 --- a/test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline.mlir +++ /dev/null @@ -1,18 +0,0 @@ -// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline %s > %t.mlir -// RUN: FileCheck %s --input-file=%t.mlir -// RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn - -#any_device = #tt.operand_constraint -module attributes {} { - func.func @forward(%arg0: tensor<64x128xf32>, %arg1: tensor<64x128xf32>) -> tensor<64x128xf32> { - // CHECK: #layout2 = #tt.layout<(d0, d1) -> (d0, d1), undef, <8x8>, memref<8x16xf32, #l1_>> - // CHECK: %[[C:.*]] = "ttnn.open_device"[[C:.*]] - // CHECK: %[[C:.*]] = "ttnn.full"[[C:.*]] - %0 = tensor.empty() : tensor<64x128xf32> - // CHECK: %[[C:.*]] = "ttnn.multiply"[[C:.*]] -> tensor<64x128xf32, #layout2> - %1 = "ttir.multiply"(%arg0, %arg1, %0) <{operandSegmentSizes = array, operand_constraints = [#any_device, #any_device, #any_device]}> : (tensor<64x128xf32>, tensor<64x128xf32>, tensor<64x128xf32>) -> tensor<64x128xf32> - // CHECK: %[[C:.*]] = "ttnn.to_memory_config"[[C:.*]] - // CHECK: "ttnn.close_device"[[C:.*]] - return %1 : tensor<64x128xf32> - } -} diff --git a/test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline_custom_opt.mlir b/test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline_custom_opt.mlir index e61b10121..89cbdcf18 100644 --- a/test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline_custom_opt.mlir +++ b/test/ttmlir/Silicon/TTNN/ttir_to_ttnn_pipeline_custom_opt.mlir @@ -1,4 +1,4 @@ -// RUN: ttmlir-opt --ttir-to-ttnn-backend-pipeline="enable-grid-set=false" %s > %t.mlir +// RUN: ttmlir-opt --ttir-load-system-desc="path=%system_desc_path%" --ttir-to-ttnn-backend-pipeline="enable-grid-set=false" %s > %t.mlir // RUN: FileCheck %s --input-file=%t.mlir // RUN: ttmlir-translate --ttnn-to-flatbuffer %t.mlir > %t.ttnn