@@ -32,6 +32,7 @@ def _get_libc_root() -> str:
3232 raise Exception ("LIB_C_ROOT is not set." )
3333 return path
3434
35+
3536def _get_core_dialects_to_mk_pass_arg () -> str :
3637 value = os .getenv ("PRECISION_MODE" , "0" ).strip ()
3738 if value not in ("0" , "1" , "2" ):
@@ -50,7 +51,8 @@ def compile_accelerator(src, metadata, o_path):
5051 if cache_path is None :
5152 with tempfile .TemporaryDirectory () as tmpdir :
5253 dst_path = os .path .join (tmpdir , f"{ name } .so" )
53- xuantie_dir = txda_tools .get_tx8_deps_path ("rcs1fw-rtt/tool/rcsfw-xuantie-sdk/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.0" )
54+ xuantie_dir = txda_tools .get_tx8_deps_path (
55+ "rcs1fw-rtt/tool/rcsfw-xuantie-sdk/Xuantie-900-gcc-elf-newlib-x86_64-V2.8.0" )
5456 gcc_path = os .path .join (xuantie_dir , "bin" , "riscv64-unknown-elf-gcc" )
5557 libc_lib = os .path .join (xuantie_dir , "riscv64-unknown-elf" , "lib" , "rv64imfdc" , "lp64d" )
5658 libgcc_lib = os .path .join (xuantie_dir , "lib" , "gcc" , "riscv64-unknown-elf" , "10.4.0" , "rv64imfdc" , "lp64d" )
@@ -118,20 +120,11 @@ def _ttir_to_coreir(mod, num_stages=2):
118120 pipeline_flag = f"--mk-pipeline=num-stages={ num_stages } "
119121
120122 args = [
121- triton_opt_path ,
122- src_path ,
123- "--triton-to-core-dialects" ,
124- "--tle-to-mk" ,
125- "--dsa-memory-to-core" ,
126- "--linalg-tiling" ,
127- f"{ coreir_to_mk_mode } " ,
128- "--linalg-fusion" ,
129- "--legalize-tensor-form-loops" ,
130- "--one-shot-bufferize" ,
131- "--convert-bufferization-to-memref" ,
132- "--materialize-strided-linalg-inputs" ,
133- "--cse" ,
134- "--canonicalize" ]
123+ triton_opt_path , src_path , "--triton-to-core-dialects" , "--tle-to-mk" , "--dsa-memory-to-core" ,
124+ "--linalg-tiling" , f"{ coreir_to_mk_mode } " , "--linalg-fusion" , "--legalize-tensor-form-loops" ,
125+ "--one-shot-bufferize" , "--convert-bufferization-to-memref" , "--materialize-strided-linalg-inputs" , "--cse" ,
126+ "--canonicalize"
127+ ]
135128
136129 if os .getenv ("TRITON_PIPELINE" , "1" ) == "1" :
137130 args .append (pipeline_flag )
@@ -191,7 +184,9 @@ def _coreir_to_txir(mod):
191184 triton_opt_path = txda_tools .get_tsm_opt_path ()
192185 txda_tools .dump_ir_if_needed ([src_path ])
193186
194- args = [triton_opt_path , src_path ,
187+ args = [
188+ triton_opt_path ,
189+ src_path ,
195190 "--spmd-allocate-shared-memory" ,
196191 "--expand-strided-metadata" ,
197192 "--lower-affine" , # convert affine.load to memref.load, need exec before tx81-to-llvm since we will support spm offset to memref.load
@@ -231,10 +226,9 @@ def _txir_to_llir(mod, metadata):
231226 args = [
232227 triton_opt_path , src_path ,
233228 # Use tx81-memref-to-llvm to replace "--finalize-memref-to-llvm".
234- "--tx81-memref-to-llvm" , "--addr-to-llvm" , "--convert-scf-to-cf" ,
235- "--expand-strided-metadata" ,
236- "--convert-math-to-llvm" ,
237- "--convert-math-to-libm" , "--convert-cf-to-llvm" , # need exec before "convert-func-to-llvm"
229+ "--tx81-memref-to-llvm" , "--addr-to-llvm" , "--convert-scf-to-cf" , "--expand-strided-metadata" ,
230+ "--convert-math-to-llvm" , "--convert-math-to-libm" ,
231+ "--convert-cf-to-llvm" , # need exec before "convert-func-to-llvm"
238232 "--convert-func-to-llvm" , # need exec before "kernel-arg-buffer", otherwise un-rank memref will translate to int(rank) + ptr
239233 # Other unconverted memref ops, eg: memref.global from scan op conversion
240234 "--finalize-memref-to-llvm"
@@ -257,8 +251,7 @@ def _txir_to_llir(mod, metadata):
257251 tx81_to_llvm = "--tx81-to-llvm=gather-scatter-async=true"
258252
259253 args += [
260- tx81_to_llvm ,
261- "--convert-arith-to-llvm" , # need exec last since arith.const conversion
254+ tx81_to_llvm , "--convert-arith-to-llvm" , # need exec last since arith.const conversion
262255 # Remove all unrealized casts created
263256 "--reconcile-unrealized-casts" , "--canonicalize" , "--export-kernel-symbols" , "-o" , llvmir_path
264257 ]
@@ -434,6 +427,7 @@ def hash(self):
434427
435428
436429class TXDABackend (BaseBackend ):
430+
437431 @staticmethod
438432 def supports_target (target : GPUTarget ):
439433 return target .backend == 'txda'
0 commit comments