-
Notifications
You must be signed in to change notification settings - Fork 17
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
memref.reshape
causes segfault in JIT backend with opt_level=3
#200
Labels
MLIR Limitation
MLIR limitations
Comments
To compile any MLIR IR with gcc/clang, we can do this: mlir-opt example.mlir \
--convert-linalg-to-affine-loops \
--one-shot-bufferize \
--lower-affine \
--convert-scf-to-cf \
--convert-cf-to-llvm \
--convert-func-to-llvm \
--convert-arith-to-llvm \
--finalize-memref-to-llvm \
--reconcile-unrealized-casts \
-o example.llvm.mlir
mlir-translate example.llvm.mlir \
--mlir-to-llvmir \
-o example.ll
llc example.ll -o example.s
as example.s -o example.o
gcc example.o -o example.exe |
Associated allo program to this sample: import allo
from allo.ir.types import int32, float32
import numpy as np
def test_library_higher_dimension_ops(enable_tensor):
M = 5
N = 4
K = 3
L = 2
A = np.random.uniform(size=(M, K, L)).astype(np.float32)
B = np.random.uniform(size=(N, K)).astype(np.float32)
C = np.random.uniform(size=(N,)).astype(np.float32)
def kernel(
A: float32[M, K, L], B: float32[N, K], C: float32[N]
) -> float32[M, L * N]:
output1 = allo.transpose(A, (-1, -2))
output2 = allo.linear(output1, B, C)
output = allo.view(output2, (5, 8))
return output
s = allo.customize(kernel, enable_tensor=enable_tensor)
mod = s.build()
outp = mod(A, B, C)
np_outp = kernel(A, B, C)
np.testing.assert_allclose(outp, np_outp, rtol=1e-5)
if __name__ == "__main__":
test_library_higher_dimension_ops(False) |
Thank you! This works for me. But when def test_compare_int_float():
Ty = Int(5)
def kernel(A: Ty) -> Ty:
B: Ty = 0
if A > B or A + 1 < 0.0:
B = A
return B
s = allo.customize(kernel)
mod = s.build()
assert mod(2) == kernel(2)
> assert mod(-3) == kernel(-3)
E assert 29 == -3
E + where 29 = <allo.backend.llvm.LLVMModule object at 0x7f8d21573c70>(-3)
E + and -3 = <function test_compare_int_float.<locals>.kernel at 0x7f8d21d588b0>(-3)
tests/test_types.py:165: AssertionError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
This thread documents an issue we met with
memref.reshape
. The generated IR is correct, it can be compiled with clang and executes correctly when mlirExecutionEngine
optimization level is set to 0, 1, 2. However, ifExecutionEngine
optimization level is set to 3, this triggers a segfault.Specifically, this step causes segfault:
Current solution
This is likely an issue with MLIR JIT compiler. We bypass this issue by setting the optimization level lower than 3.
Sample IR to repeat this issue
Stack trace
The text was updated successfully, but these errors were encountered: