Skip to content

Commit 6b2df26

Browse files
[Test] add xla perf test, adjust script path (#632)
1 parent ce451a6 commit 6b2df26

File tree

11 files changed

+157
-6
lines changed

11 files changed

+157
-6
lines changed

benchmarks/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ add_subdirectory(relu)
22
add_subdirectory(silu)
33
add_subdirectory(softmax)
44
add_subdirectory(transpose)
5+
add_subdirectory(reduce)
6+
add_subdirectory(kLoopFusion)
7+
add_subdirectory(kInputFusion)
58

69
if(WIN32)
710
set(MLIR_RUNNER_UTILS_DIR ${LLVM_BINARY_DIR}/bin)

benchmarks/bench_imex.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ case "${platform}" in
1111
*) echo "UNKNOWN platform:${platform}" && exit -1
1212
esac
1313

14-
MLIR_RUNNER_UTILS=/home/cchen/.local/lib/libmlir_runner_utils.so
15-
MLIR_C_RUNNER_UTILS=/home/cchen/.local/lib/libmlir_c_runner_utils.so
16-
IMEX_SYCL_RUNTIME=/home/cchen/imex/frameworks.ai.mlir.mlir-extensions/build/lib/libsycl-runtime.so
17-
IMEX_L0_RUNTIME=/home/cchen/imex/frameworks.ai.mlir.mlir-extensions/build/lib/liblevel-zero-runtime.so
18-
BENCHMARK_ROOT=/home/cchen/imex/frameworks.ai.mlir.mlir-extensions/build/benchmarks
19-
IMEX_RUNNER=/home/cchen/imex/frameworks.ai.mlir.mlir-extensions/build/bin/imex-runner.py
14+
MLIR_RUNNER_UTILS=@LLVM_LIBRARY_DIR@/libmlir_runner_utils.so
15+
MLIR_C_RUNNER_UTILS=@LLVM_LIBRARY_DIR@/libmlir_c_runner_utils.so
16+
IMEX_SYCL_RUNTIME=@IMEX_LIB_DIR@/libsycl-runtime.so
17+
IMEX_L0_RUNTIME=@IMEX_LIB_DIR@/liblevel-zero-runtime.so
18+
BENCHMARK_ROOT=@IMEX_BINARY_DIR@/benchmarks
19+
IMEX_RUNNER=@IMEX_BINARY_DIR@/bin/imex-runner.py
2020

2121
# -l: using level-zero runtime
2222
# -s: using sycl runtime
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
file(STRINGS kInputFusion.dtypes.in test_dtypes)
2+
list(APPEND test_shapes "512x1024")
3+
4+
foreach(shape ${test_shapes})
5+
foreach(dtype ${test_dtypes})
6+
configure_file(kInputFusion.mlir.in ${IMEX_BINARY_DIR}/benchmarks/kInputFusion/kInputFusion_${shape}_${dtype}.mlir @ONLY)
7+
endforeach()
8+
endforeach()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
f32
2+
f16
3+
bf16
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#map = affine_map<(d0) -> (d0)>
2+
#map1 = affine_map<(d0, d1) -> (d0, d1)>
3+
#map2 = affine_map<(d0, d1) -> (d1, d0)>
4+
#map3 = affine_map<(d0, d1) -> (d0)>
5+
module {
6+
func.func @fusion(%arg4: tensor<512x1024x@dtype@>, %arg5: tensor<512x1024x@dtype@>) -> (tensor<1024x@dtype@> {lmhlo.written}) {
7+
%0 = tensor.empty() : tensor<512x1024x@dtype@>
8+
%1 = linalg.generic {indexing_maps = [#map1, #map1], iterator_types = ["parallel", "parallel"]} ins(%arg5 : tensor<512x1024x@dtype@>) outs(%0 : tensor<512x1024x@dtype@>) {
9+
^bb0(%in: @dtype@, %out: @dtype@):
10+
%9 = math.log %in : @dtype@
11+
linalg.yield %9 : @dtype@
12+
} -> tensor<512x1024x@dtype@>
13+
%2 = tensor.empty() : tensor<512x1024x@dtype@>
14+
%3 = linalg.generic {indexing_maps = [#map1, #map1], iterator_types = ["parallel", "parallel"]} ins(%arg4 : tensor<512x1024x@dtype@>) outs(%2 : tensor<512x1024x@dtype@>) {
15+
^bb0(%in: @dtype@, %out: @dtype@):
16+
%9 = math.absf %in : @dtype@
17+
linalg.yield %9 : @dtype@
18+
} -> tensor<512x1024x@dtype@>
19+
%4 = tensor.empty() : tensor<512x1024x@dtype@>
20+
%5 = linalg.generic {indexing_maps = [#map1, #map1, #map1], iterator_types = ["parallel", "parallel"]} ins(%1, %3 : tensor<512x1024x@dtype@>, tensor<512x1024x@dtype@>) outs(%4 : tensor<512x1024x@dtype@>) {
21+
^bb0(%in: @dtype@, %in_7: @dtype@, %out: @dtype@):
22+
%9 = arith.addf %in, %in_7 : @dtype@
23+
linalg.yield %9 : @dtype@
24+
} -> tensor<512x1024x@dtype@>
25+
%cst = arith.constant dense<0.000000e+00> : tensor<@dtype@>
26+
%cst_6 = arith.constant 0.000000e+00 : @dtype@
27+
%6 = tensor.empty() : tensor<1024x@dtype@>
28+
%7 = linalg.fill ins(%cst_6 : @dtype@) outs(%6 : tensor<1024x@dtype@>) -> tensor<1024x@dtype@>
29+
%8 = linalg.generic {indexing_maps = [#map2, #map3], iterator_types = ["parallel", "reduction"]} ins(%5 : tensor<512x1024x@dtype@>) outs(%7 : tensor<1024x@dtype@>) {
30+
^bb0(%in: @dtype@, %out: @dtype@):
31+
%from_elements = tensor.from_elements %out : tensor<@dtype@>
32+
%from_elements_7 = tensor.from_elements %in : tensor<@dtype@>
33+
%extracted = tensor.extract %from_elements[] : tensor<@dtype@>
34+
%extracted_8 = tensor.extract %from_elements_7[] : tensor<@dtype@>
35+
%9 = arith.addf %extracted, %extracted_8 : @dtype@
36+
%from_elements_9 = tensor.from_elements %9 : tensor<@dtype@>
37+
%extracted_10 = tensor.extract %from_elements_9[] : tensor<@dtype@>
38+
linalg.yield %extracted_10 : @dtype@
39+
} -> tensor<1024x@dtype@>
40+
return %8 : tensor<1024x@dtype@>
41+
//%expanded = tensor.expand_shape %8 [[0, 1]] : tensor<1024x@dtype@> into tensor<1x1024x@dtype@>
42+
//return %expanded : tensor<1x1024x@dtype@>
43+
}
44+
func.func @main() {
45+
%0 = arith.constant dense<3.3> : tensor<512x1024x@dtype@>
46+
%1 = arith.constant dense<1.0> : tensor<512x1024x@dtype@>
47+
%2 = call @fusion(%0, %1) : (tensor<512x1024x@dtype@>, tensor<512x1024x@dtype@>) -> tensor<1024x@dtype@>
48+
return
49+
}
50+
}

benchmarks/kLoopFusion/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
file(STRINGS kLoopFusion.dtypes.in test_dtypes)
2+
list(APPEND test_shapes "512x1024")
3+
4+
foreach(shape ${test_shapes})
5+
foreach(dtype ${test_dtypes})
6+
configure_file(kLoopFusion.mlir.in ${IMEX_BINARY_DIR}/benchmarks/kLoopFusion/kLoopFusion_${shape}_${dtype}.mlir @ONLY)
7+
endforeach()
8+
endforeach()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
f32
2+
f16
3+
bf16
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#map = affine_map<(d0) -> (d0)>
2+
#map1 = affine_map<(d0, d1) -> (d0, d1)>
3+
module {
4+
func.func @fusion(%arg3: tensor<512x1024x@dtype@>, %arg4: tensor<512x1024x@dtype@>) -> (tensor<512x1024x@dtype@> {lmhlo.written}) {
5+
%0 = tensor.empty() : tensor<512x1024x@dtype@>
6+
%1 = linalg.generic {indexing_maps = [#map1, #map1], iterator_types = ["parallel", "parallel"]} ins(%arg3 : tensor<512x1024x@dtype@>) outs(%0 : tensor<512x1024x@dtype@>) {
7+
^bb0(%in: @dtype@, %out: @dtype@):
8+
%8 = math.log %in : @dtype@
9+
linalg.yield %8 : @dtype@
10+
} -> tensor<512x1024x@dtype@>
11+
%2 = tensor.empty() : tensor<512x1024x@dtype@>
12+
%3 = linalg.generic {indexing_maps = [#map1, #map1], iterator_types = ["parallel", "parallel"]} ins(%arg4 : tensor<512x1024x@dtype@>) outs(%2 : tensor<512x1024x@dtype@>) {
13+
^bb0(%in: @dtype@, %out: @dtype@):
14+
%8 = math.absf %in : @dtype@
15+
linalg.yield %8 : @dtype@
16+
} -> tensor<512x1024x@dtype@>
17+
%4 = tensor.empty() : tensor<512x1024x@dtype@>
18+
%5 = linalg.generic {indexing_maps = [#map1, #map1, #map1], iterator_types = ["parallel", "parallel"]} ins(%1, %3 : tensor<512x1024x@dtype@>, tensor<512x1024x@dtype@>) outs(%4 : tensor<512x1024x@dtype@>) {
19+
^bb0(%in: @dtype@, %in_4: @dtype@, %out: @dtype@):
20+
%8 = arith.addf %in, %in_4 : @dtype@
21+
linalg.yield %8 : @dtype@
22+
} -> tensor<512x1024x@dtype@>
23+
%6 = tensor.empty() : tensor<512x1024x@dtype@>
24+
%7 = linalg.generic {indexing_maps = [#map1, #map1, #map1], iterator_types = ["parallel", "parallel"]} ins(%5, %arg3 : tensor<512x1024x@dtype@>, tensor<512x1024x@dtype@>) outs(%6 : tensor<512x1024x@dtype@>) {
25+
^bb0(%in: @dtype@, %in_4: @dtype@, %out: @dtype@):
26+
%8 = arith.subf %in, %in_4 : @dtype@
27+
linalg.yield %8 : @dtype@
28+
} -> tensor<512x1024x@dtype@>
29+
return %7 : tensor<512x1024x@dtype@>
30+
}
31+
func.func @main() {
32+
%0 = arith.constant dense<3.3> : tensor<512x1024x@dtype@>
33+
%1 = arith.constant dense<1.0> : tensor<512x1024x@dtype@>
34+
%2 = call @fusion(%0, %1) : (tensor<512x1024x@dtype@>, tensor<512x1024x@dtype@>) -> tensor<512x1024x@dtype@>
35+
return
36+
}
37+
}

benchmarks/reduce/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
file(STRINGS reduce.dtypes.in test_dtypes)
2+
list(APPEND test_shapes "1x16x512x512")
3+
4+
foreach(shape ${test_shapes})
5+
foreach(dtype ${test_dtypes})
6+
configure_file(reduce.mlir.in ${IMEX_BINARY_DIR}/benchmarks/reduce/reduce_${shape}_${dtype}.mlir @ONLY)
7+
endforeach()
8+
endforeach()

benchmarks/reduce/reduce.dtypes.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
f32
2+
f16
3+
bf16

0 commit comments

Comments
 (0)