Skip to content
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

eval_module failed when compiling with gcc #2434

Open
qingyunqu opened this issue Jul 13, 2024 · 5 comments
Open

eval_module failed when compiling with gcc #2434

qingyunqu opened this issue Jul 13, 2024 · 5 comments

Comments

@qingyunqu
Copy link
Contributor

qingyunqu commented Jul 13, 2024

What happened?

I found this bug when I try to use stablehlo's interpreter in torch-mlir. It could be reproduced at torch-mlir main branch:

from torch_mlir import ir
from torch_mlir._mlir_libs._stablehlo import eval_module
from torch_mlir._mlir_libs._stablehlo import register_dialect
import numpy as np

module_str = """
module attributes {torch.debug_module_name = "ArgmaxKeepdimModule"} {
  func.func @forward(%arg0: tensor<4x4xf32>, %arg1: tensor<4x4xf32>) -> tensor<4x4xf32> {
    %0 = stablehlo.add %arg0, %arg1 : tensor<4x4xf32>
    return %0 : tensor<4x4xf32>
  }
}
"""

with ir.Context() as context:
    register_dialect(context)
    module = ir.Module.parse(module_str)
    input = ir.DenseElementsAttr.get(np.random.random(size=(4, 4)).astype(np.float32))
    mlir_args = [input, input]
    rets = eval_module(module, mlir_args)
    print(rets)

It will produce error:

ValueError: input args must be DenseElementsAttr
@qingyunqu
Copy link
Contributor Author

BTW, it passed when compiling torch-mlir with clang.

@qingyunqu
Copy link
Contributor Author

_stablehlo.cpython-39-x86_64-linux-gnu.so have different *mlir* symbol between gcc and clang

@qingyunqu
Copy link
Contributor Author

I think it would also get the same failure when building stablehlo by gcc without torch-mlir.

@qingyunqu
Copy link
Contributor Author

I think previous issue(#2170) catch the same problem.

@GleasonK
Copy link
Member

GleasonK commented Aug 9, 2024

Thanks for raising this issue. Starting to understand the importance of not exposing mlir:: symbols in these APIs -- we plan to fix this up but timeline unknown, top of the refactoring priorities, but below feature development like DotAlgorithms.

We will not be adding any new APIs without proper CAPI shims, recently added register_all_passes with proper shim.

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

No branches or pull requests

2 participants