Skip to content

[LLVM] Update LLVM version to 21.0.0git #472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: v-snake
Choose a base branch
from

Conversation

WuXintong123
Copy link
Contributor

No description provided.

@WuXintong123 WuXintong123 changed the title llvm update temporary [LLVM] Update LLVM version to 21.0.0git Mar 4, 2025
@zhanghb97 zhanghb97 changed the base branch from main to v-snake March 6, 2025 04:22
@Avimitin
Copy link
Contributor

Avimitin commented Apr 7, 2025

Running standalone build for llvm doesn't install MLIRPythonCAPI library into build/tool/mlir, please make this link path configurable:

@Avimitin
Copy link
Contributor

Avimitin commented Apr 8, 2025

Also worth notice that, buddy-llc breaks after bump:

$ buddy-llc forward-lowered.mlir.ll -mtriple=riscv32 -target-abi=ilp32f -mattr=+m,+f,+zve32f --filetype=obj -o forward-lowered.mlir.ll.o
#5 0x0000555556f05896 getFeatures(llvm::MCSubtargetInfo&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::SubtargetSubTypeKV>, llvm::ArrayRef<llvm::SubtargetFeatureKV>) (/nix/store/wcvck76nnpi9slmj4csksgp37df4sx09->
 #6 0x0000555556f054bc llvm::MCSubtargetInfo::InitMCProcessorInfo(llvm::StringRef, llvm::StringRef, llvm::StringRef) (/nix/store/wcvck76nnpi9slmj4csksgp37df4sx09-buddy-mlir-unstable-2024-07-18/bin/buddy-llc+0x19b14bc)
 #7 0x0000555556b38c77 llvm::TargetSubtargetInfo::TargetSubtargetInfo(llvm::Triple const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::ArrayRef<llvm::StringRef>, llvm::ArrayRef<llvm::SubtargetFeatureKV>, llvm::ArrayRef<llvm::SubtargetSubTypeKV>, llvm::MCWrite>
 #8 0x0000555555dd736c llvm::RISCVSubtarget::RISCVSubtarget(llvm::Triple const&, llvm::StringRef, llvm::StringRef, llvm::StringRef, llvm::StringRef, unsigned int, unsigned int, llvm::TargetMachine const&) (/nix/store/wcvck76nnpi9slmj4csksgp37df4sx09-buddy-mlir-unstable-20>
 #9 0x0000555555dd9049 llvm::RISCVTargetMachine::getSubtargetImpl(llvm::Function const&) const (/nix/store/wcvck76nnpi9slmj4csksgp37df4sx09-buddy-mlir-unstable-2024-07-18/bin/buddy-llc+0x885049)

I don't get such error using LLVM llc, so I guess there are missing linking libraries.

@Avimitin
Copy link
Contributor

Avimitin commented Apr 9, 2025

Met Python op error after bump:

Traceback (most recent call last):
  File "/build/tinyllama/./tinyllama.py", line 54, in <module>
    driver.subgraphs[0].lower_to_top_level_ir()
  File "/nix/store/7dzdynizjqv55py9fx99ccbk2qi7ax41-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 316, in lower_to_top_level_ir
    self._imported_module = fx_importer.import_graph()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7dzdynizjqv55py9fx99ccbk2qi7ax41-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 534, in import_graph
    @func.FuncOp.from_py_func(*arguments, name=self._func_name)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7dzdynizjqv55py9fx99ccbk2qi7ax41-python3-3.12.9-env/lib/python3.12/site-packages/mlir/dialects/func.py", line 197, in decorator
    return_values = f(*func_args, **func_kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/7dzdynizjqv55py9fx99ccbk2qi7ax41-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 558, in generated_func
    self._import_op(node)
  File "/nix/store/7dzdynizjqv55py9fx99ccbk2qi7ax41-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 687, in _import_op
    self._ops_registry[op_name](node, self._symbol_table)
  File "/nix/store/7dzdynizjqv55py9fx99ccbk2qi7ax41-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/ops/linalg.py", line 2072, in ge_op
    rhs = tensor.SplatOp(tensor_type, scalar)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: SplatOp.__init__() missing 1 required positional argument: 'dynamicSizes'

@sequencer
Copy link

llvm/llvm-project#74626

@Avimitin
Copy link
Contributor

Avimitin commented Apr 9, 2025

Should be fixed with following patch. The new SplatOp required a dynamic size specification when dynamic dim is used. Since this is not the case in this codegen script, I just use empty size here.

--- a/frontend/Python/ops/linalg.py	1970-01-01 08:00:01.000000000 +0800
+++ b/frontend/Python/ops/linalg.py	2025-04-09 21:59:09.917019537 +0800
@@ -1854,9 +1854,9 @@
     output = tensor.EmptyOp(output_shape, mlir_dtype)
 
     if not isinstance(input2.type, ir.RankedTensorType):
-        input2 = tensor.SplatOp(tensor_type, input2).result
+        input2 = tensor.SplatOp(tensor_type, input2, []).result
     if not isinstance(input3.type, ir.RankedTensorType):
-        input3 = tensor.SplatOp(tensor_type, input3).result
+        input3 = tensor.SplatOp(tensor_type, input3, []).result
 
     generic_map = ir.AffineMap.get_permutation(
         [i for i in range(len(output_shape))]
@@ -2038,7 +2038,7 @@
     input_shape = ir.RankedTensorType(input_tensor.type).shape
     tensor_type = ir.RankedTensorType.get(input_shape, input_dtype)
     scalar = arith.ConstantOp(input_dtype, node.args[1])
-    rhs = tensor.SplatOp(tensor_type, scalar)
+    rhs = tensor.SplatOp(tensor_type, scalar, [])
     if str(input_dtype).find("i") != -1:
         cmp_op = arith.CmpIOp(4, input_tensor, rhs)
     else:
@@ -2069,7 +2069,7 @@
     tensor_type = ir.RankedTensorType.get(input_shape, input_dtype)
 
     scalar = arith.ConstantOp(input_dtype, node.args[1])
-    rhs = tensor.SplatOp(tensor_type, scalar)
+    rhs = tensor.SplatOp(tensor_type, scalar, [])
 
     if str(input_dtype).find("i") != -1:
         cmp_op = arith.CmpIOp(5, input_tensor, rhs)
@@ -2390,7 +2390,7 @@
         scalar = arith.ConstantOp(input_dtype, float(node.args[1]))
     else:
         scalar = arith.ConstantOp(input_dtype, node.args[1])
-    rhs = tensor.SplatOp(tensor_type, scalar)
+    rhs = tensor.SplatOp(tensor_type, scalar, [])
     if str(input_dtype).find("i") != -1:
         cmp_op = arith.CmpIOp(0, input_tensor, rhs)
     else:

@Avimitin
Copy link
Contributor

Avimitin commented Apr 9, 2025

Now with following error:

Traceback (most recent call last):
  File "/build/tinyllama/./tinyllama.py", line 54, in <module>
    driver.subgraphs[0].lower_to_top_level_ir()
  File "/nix/store/aym9cznfwd898grcnxjsqfbjhz18m8y3-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 316, in lower_to_top_level_ir
    self._imported_module = fx_importer.import_graph()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/aym9cznfwd898grcnxjsqfbjhz18m8y3-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 534, in import_graph
    @func.FuncOp.from_py_func(*arguments, name=self._func_name)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/aym9cznfwd898grcnxjsqfbjhz18m8y3-python3-3.12.9-env/lib/python3.12/site-packages/mlir/dialects/func.py", line 197, in decorator
    return_values = f(*func_args, **func_kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/aym9cznfwd898grcnxjsqfbjhz18m8y3-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 558, in generated_func
    self._import_op(node)
  File "/nix/store/aym9cznfwd898grcnxjsqfbjhz18m8y3-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 687, in _import_op
    self._ops_registry[op_name](node, self._symbol_table)
  File "/nix/store/aym9cznfwd898grcnxjsqfbjhz18m8y3-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/ops/linalg.py", line 1169, in matmul_op
    op = linalg.matmul(input1, input2, outs=[matmul_result_buffer])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: matmul() got an unexpected keyword argument 'outs'

@Avimitin
Copy link
Contributor

Avimitin commented Apr 9, 2025

Should be fixed with following patch

--- a/frontend/Python/ops/linalg.py	1970-01-01 08:00:01.000000000 +0800
+++ b/frontend/Python/ops/linalg.py	1970-01-01 08:00:01.000000000 +0800
@@ -1166,7 +1166,7 @@
     element = mlir_element_attr_get(dtype, 0.0)
     attr = ir.DenseElementsAttr.get_splat(tensor_type, element)
     matmul_result_buffer = arith.ConstantOp(tensor_type, attr).result
-    op = linalg.matmul(input1, input2, outs=[matmul_result_buffer])
+    op = linalg.matmul(input1, input2, outputs=[matmul_result_buffer])
     return op
 
 
@@ -1186,7 +1186,7 @@
     element = mlir_element_attr_get(dtype, 0.0)
     attr = ir.DenseElementsAttr.get_splat(tensor_type, element)
     result_buffer = arith.ConstantOp(tensor_type, attr).result
-    op = linalg.matmul_transpose_b(input1, input2, outs=[result_buffer])
+    op = linalg.matmul_transpose_b(input1, input2, outputs=[result_buffer])
     return op
 

@Avimitin
Copy link
Contributor

Avimitin commented Apr 9, 2025

Now with error:

Traceback (most recent call last):
  File "/build/tinyllama/./tinyllama.py", line 54, in <module>
    driver.subgraphs[0].lower_to_top_level_ir()
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 316, in lower_to_top_level_ir
    self._imported_module = fx_importer.import_graph()
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 534, in import_graph
    @func.FuncOp.from_py_func(*arguments, name=self._func_name)
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/mlir/dialects/func.py", line 197, in decorator
    return_values = f(*func_args, **func_kwargs)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 558, in generated_func
    self._import_op(node)
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/graph/graph.py", line 687, in _import_op
    self._ops_registry[op_name](node, self._symbol_table)
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/buddy/compiler/ops/linalg.py", line 1169, in matmul_op
    op = linalg.matmul(input1, input2, outputs=[matmul_result_buffer])
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/mlir/dialects/_linalg_ops_gen.py", line 4238, in matmul
    return _get_op_result_or_op_results(MatmulOp(result_tensors=result_tensors, inputs=inputs, outputs=outputs, indexing_maps=indexing_maps, cast=cast, loc=loc, ip=ip))
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/af94y0lmin3aamwmnfbrs2kii4p7zh6i-python3-3.12.9-env/lib/python3.12/site-packages/mlir/dialects/_linalg_ops_gen.py", line 4176, in __init__
    results.extend(result_tensors)
TypeError: 'mlir._mlir_libs._mlir.ir.OpResult' object is not iterable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants