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

[BUG]Operations unsupported when generating HLS from lowered MLIR #68

Open
mmengjiadai opened this issue Aug 31, 2023 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@mmengjiadai
Copy link
Contributor

Describe the bug
When using build(target = "") certain Operations cannot pass hcl_d.emit_vhls(self.module, buf), with outputs in the form of error: '<name of op>' op is unsupported operation. The list of these operations and the testcase to which they belong is provided in Additional Context below.

To Reproduce

def test_while_basic():
    def kernel(A: int32[10]):
        i: index = 0
        while i < 10:
            A[i] = i
            i += 1

    s = allo.customize(kernel, verbose=True)
    print(s.module)
    mod = s.build(target = "vhls")

Buggy output

loc("-":8:5): error: 'scf.while' op is unsupported operation.
 #0 0x00007f76b2eed9d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work/shared/users/common/hcl-dialect-18.x/build/tools/hcl/python_packages/hcl_core/hcl_mlir/_mlir_libs/libHCLMLIRAggregateCAPI.so.18git+0x185b9d8)
 #1 0x00007f76b2eeb25c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f773a2f7630 __restore_rt sigaction.c:0:0
 #3 0x00007f7739847387 raise (/lib64/libc.so.6+0x36387)
 #4 0x00007f7739848a78 abort (/lib64/libc.so.6+0x37a78)
 #5 0x00007f76b3071f71 /work/shared/users/common/hcl-dialect-18.x/include/hcl/Dialect/Visitor.h:89:10
 #6 0x00007f76b3071cd4 bool mlir::hcl::HLSCppVisitorBase<(anonymous namespace)::ExprVisitor, bool>::dispatchVisitor(mlir::Operation*)::'lambda0'(auto)::operator()<mlir::Operation*>(auto) const /work/shared/users/common/hcl-dialect-18.x/include/hcl/Dialect/Visitor.h:81:18
 #7 0x00007f76b3071ab7 bool llvm::TypeSwitch<mlir::Operation*, bool>::Default<mlir::hcl::HLSCppVisitorBase<(anonymous namespace)::ExprVisitor, bool>::dispatchVisitor(mlir::Operation*)::'lambda0'(auto)>(auto&&) /work/shared/users/common/llvm-project-18.x/llvm/include/llvm/ADT/TypeSwitch.h:131:33
 #8 0x00007f76b306ff33 mlir::hcl::HLSCppVisitorBase<(anonymous namespace)::ExprVisitor, bool>::dispatchVisitor(mlir::Operation*) /work/shared/users/common/hcl-dialect-18.x/include/hcl/Dialect/Visitor.h:84:3
 #9 0x00007f76b306a2f0 (anonymous namespace)::ModuleEmitter::emitBlock(mlir::Block&) /work/shared/users/common/hcl-dialect-18.x/lib/Translation/EmitVivadoHLS.cpp:1692:5
#10 0x00007f76b306bd6e (anonymous namespace)::ModuleEmitter::emitFunction(mlir::func::FuncOp) /work/shared/users/common/hcl-dialect-18.x/lib/Translation/EmitVivadoHLS.cpp:2008:20
#11 0x00007f76b306c306 (anonymous namespace)::ModuleEmitter::emitModule(mlir::ModuleOp) /work/shared/users/common/hcl-dialect-18.x/lib/Translation/EmitVivadoHLS.cpp:2099:21
#12 0x00007f76b306c425 mlir::hcl::emitVivadoHLS(mlir::ModuleOp, llvm::raw_ostream&) /work/shared/users/common/hcl-dialect-18.x/lib/Translation/EmitVivadoHLS.cpp:2115:24
#13 0x00007f76b2c9265e mlirEmitVivadoHls /work/shared/users/common/hcl-dialect-18.x/lib/CAPI/Translation/EmitVivadoHLS.cpp:19:52
#14 0x00007f772f25ff20 emitVivadoHls(MlirModule&, pybind11::object) //work/shared/users/common/hcl-dialect-18.x/lib/Bindings/Python/HCLModule.cpp:91:36
#15 0x00007f772f28869d bool pybind11::detail::argument_loader<MlirModule&, pybind11::object>::call_impl<bool, bool (*&)(MlirModule&, pybind11::object), 0ul, 1ul, pybind11::detail::void_type>(bool (*&)(MlirModule&, pybind11::object), std::integer_sequence<unsigned long, 0ul, 1ul>, pybind11::detail::void_type&&) && /work/shared/users/phd/hc676/envs/allo/lib/python3.8/site-packages/pybind11/include/pybind11/cast.h:1480:37
#16 0x00007f772f285713 _ZNO8pybind116detail15argument_loaderIJR10MlirModuleNS_6objectEEE4callIbNS0_9void_typeERPFbS3_S4_EEENSt9enable_ifIXntsrSt7is_voidIT_E5valueESD_E4typeEOT1_ /work/shared/users/phd/hc676/envs/allo/lib/python3.8/site-packages/pybind11/include/pybind11/cast.h:1450:5
#17 0x00007f772f280806 void pybind11::cpp_function::initialize<bool (*&)(MlirModule&, pybind11::object), bool, MlirModule&, pybind11::object, pybind11::name, pybind11::scope, pybind11::sibling>(bool (*&)(MlirModule&, pybind11::object), bool (*)(MlirModule&, pybind11::object), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::'lambda1'(pybind11::detail::function_call&)::operator()(pybind11::detail::function_call&) const /work/shared/users/phd/hc676/envs/allo/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:253:40
#18 0x00007f772f280940 void pybind11::cpp_function::initialize<bool (*&)(MlirModule&, pybind11::object), bool, MlirModule&, pybind11::object, pybind11::name, pybind11::scope, pybind11::sibling>(bool (*&)(MlirModule&, pybind11::object), bool (*)(MlirModule&, pybind11::object), pybind11::name const&, pybind11::scope const&, pybind11::sibling const&)::'lambda1'(pybind11::detail::function_call&)::_FUN(pybind11::detail::function_call&) /work/shared/users/phd/hc676/envs/allo/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:224:21
#19 0x00007f772f26de5a pybind11::cpp_function::dispatcher(_object*, _object*, _object*) /work/shared/users/phd/hc676/envs/allo/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:946:35
#20 0x00000000004f5592 cfunction_call_varargs /usr/local/src/conda/python-3.8.17/Objects/call.c:745:9
#21 0x00000000004f5592 PyCFunction_Call /usr/local/src/conda/python-3.8.17/Objects/call.c:773:16
#22 0x00000000004e0e1b _PyObject_MakeTpCall /usr/local/src/conda/python-3.8.17/Objects/call.c:159:18
#23 0x00000000004dcf24 _PyObject_Vectorcall /usr/local/src/conda/python-3.8.17/Include/cpython/abstract.h:125:16
#24 0x00000000004dcf24 _PyObject_Vectorcall /usr/local/src/conda/python-3.8.17/Include/cpython/abstract.h:115:1
#25 0x00000000004dcf24 call_function /usr/local/src/conda/python-3.8.17/Python/ceval.c:4963:13
#26 0x00000000004dcf24 _PyEval_EvalFrameDefault /usr/local/src/conda/python-3.8.17/Python/ceval.c:3469:23
#27 0x00000000004d70e1 _PyEval_EvalCodeWithName /usr/local/src/conda/python-3.8.17/Python/ceval.c:4308:9
#28 0x00000000004e823c _PyFunction_Vectorcall /usr/local/src/conda/python-3.8.17/Objects/call.c:436:12
#29 0x00000000004e05d2 _PyObject_FastCallDict /usr/local/src/conda/python-3.8.17/Objects/call.c:105:21
#30 0x00000000004f1c13 _PyObject_Call_Prepend /usr/local/src/conda/python-3.8.17/Objects/call.c:888:14
#31 0x00000000004f1c13 slot_tp_init /usr/local/src/conda/python-3.8.17/Objects/typeobject.c:6790:15
#32 0x00000000004e0e33 type_call /usr/local/src/conda/python-3.8.17/Objects/typeobject.c:995:12
#33 0x00000000004e0e33 _PyObject_MakeTpCall /usr/local/src/conda/python-3.8.17/Objects/call.c:159:18
#34 0x00000000004dd0d6 _PyObject_Vectorcall /usr/local/src/conda/python-3.8.17/Include/cpython/abstract.h:125:16
#35 0x00000000004dd0d6 _PyObject_Vectorcall /usr/local/src/conda/python-3.8.17/Include/cpython/abstract.h:115:1
#36 0x00000000004dd0d6 call_function /usr/local/src/conda/python-3.8.17/Python/ceval.c:4963:13
#37 0x00000000004dd0d6 _PyEval_EvalFrameDefault /usr/local/src/conda/python-3.8.17/Python/ceval.c:3515:19
#38 0x00000000004d70e1 _PyEval_EvalCodeWithName /usr/local/src/conda/python-3.8.17/Python/ceval.c:4308:9
#39 0x00000000004f50fb _PyFunction_Vectorcall /usr/local/src/conda/python-3.8.17/Objects/call.c:436:12
#40 0x00000000004f50fb _PyObject_Vectorcall /usr/local/src/conda/python-3.8.17/Include/cpython/abstract.h:127:11
#41 0x00000000004f50fb method_vectorcall /usr/local/src/conda/python-3.8.17/Objects/classobject.c:60:18
#42 0x00000000004d9276 PyErr_Occurred /usr/local/src/conda/python-3.8.17/Python/errors.c:221:29
#43 0x00000000004d9276 _Py_CheckFunctionResult /usr/local/src/conda/python-3.8.17/Objects/call.c:25:25
#44 0x00000000004d9276 _PyObject_Vectorcall /usr/local/src/conda/python-3.8.17/Include/cpython/abstract.h:128:12
#45 0x00000000004d9276 call_function /usr/local/src/conda/python-3.8.17/Python/ceval.c:4963:13
#46 0x00000000004d9276 _PyEval_EvalFrameDefault /usr/local/src/conda/python-3.8.17/Python/ceval.c:3515:19
#47 0x00000000004e81a6 function_code_fastcall /usr/local/src/conda/python-3.8.17/Objects/call.c:286:9
#48 0x00000000004e81a6 _PyFunction_Vectorcall /usr/local/src/conda/python-3.8.17/Objects/call.c:411:20
#49 0x00000000004d84b9 PyErr_Occurred /usr/local/src/conda/python-3.8.17/Python/errors.c:221:29
#50 0x00000000004d84b9 _Py_CheckFunctionResult /usr/local/src/conda/python-3.8.17/Objects/call.c:25:25
#51 0x00000000004d84b9 _PyObject_Vectorcall /usr/local/src/conda/python-3.8.17/Include/cpython/abstract.h:128:12
#52 0x00000000004d84b9 call_function /usr/local/src/conda/python-3.8.17/Python/ceval.c:4963:13
#53 0x00000000004d84b9 _PyEval_EvalFrameDefault /usr/local/src/conda/python-3.8.17/Python/ceval.c:3500:19
#54 0x00000000004d70e1 _PyEval_EvalCodeWithName /usr/local/src/conda/python-3.8.17/Python/ceval.c:4308:9
#55 0x0000000000585e99 PyEval_EvalCodeEx /usr/local/src/conda/python-3.8.17/Python/ceval.c:4334:1
#56 0x0000000000585e5b PyEval_EvalCode /usr/local/src/conda/python-3.8.17/Python/ceval.c:724:1
#57 0x00000000005a5c21 run_eval_code_obj /usr/local/src/conda/python-3.8.17/Python/pythonrun.c:1166:9
#58 0x00000000005a4c2f _Py_DECREF /usr/local/src/conda/python-3.8.17/Include/object.h:470:8
#59 0x00000000005a4c2f run_mod /usr/local/src/conda/python-3.8.17/Python/pythonrun.c:1189:5
#60 0x000000000045c580 pyrun_file /usr/local/src/conda/python-3.8.17/Python/pythonrun.c:1085:15
#61 0x000000000045c121 pyrun_simple_file /usr/local/src/conda/python-3.8.17/Python/pythonrun.c:439:13
#62 0x000000000045c121 PyRun_SimpleFileExFlags /usr/local/src/conda/python-3.8.17/Python/pythonrun.c:472:15
#63 0x000000000044fe93 _Py_DECREF /usr/local/src/conda/python-3.8.17/Include/object.h:470:8
#64 0x000000000044fe93 _Py_XDECREF /usr/local/src/conda/python-3.8.17/Include/object.h:541:9
#65 0x000000000044fe93 pymain_run_file /usr/local/src/conda/python-3.8.17/Modules/main.c:392:5
#66 0x000000000044fe93 pymain_run_python /usr/local/src/conda/python-3.8.17/Modules/main.c:616:21
#67 0x000000000044fe93 Py_RunMain.cold /usr/local/src/conda/python-3.8.17/Modules/main.c:695:5
#68 0x0000000000579ef9 Py_BytesMain /usr/local/src/conda/python-3.8.17/Modules/main.c:1128:1
#69 0x00007f7739833555 __libc_start_main (/lib64/libc.so.6+0x22555)
#70 0x0000000000579dad _start (/home/md2249/miniconda3/envs/allo/bin/python3.8+0x579dad)
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Aborted

Expected behavior
Should output HLS code in the form given in the Allo tutorial.

Additional context

  • test_builder.py
    scf.while: test_while_basic()
    arith.floordivsi: test_rhs_binaryop()
@mmengjiadai mmengjiadai added the bug Something isn't working label Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants