Skip to content

issue when running MultiHeadSelfAttention #14

@patrickmcewen

Description

@patrickmcewen

Hello,

I ran the following command after setting tilelimit=1, timelimit=1, and dsps=357 in run_streamhls.py:

$ python run_streamhls.py -b transformers -k MultiHeadSelfAttention -O 5

And it produced this output, including the bug trace below. Is this an issue with my configuration? Or an actual bug in the code?

Model: MultiHeadSelfAttention
Importing: pymodels.transformers.MultiHeadSelfAttention
Saving golden results to designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/hls/data/
Model 'MultiHeadSelfAttention' successfully imported and initialized.
MLIR to HLS for MultiHeadSelfAttention
Permutation DesignSpaceSize: 15407021574586368
Parallelization DesignSpaceSize: 0
Total DesignSpaceSize: 0
Combined solver: Combined Latency: 344050
Total DSPs: 356
streamhls-opt: /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/SmallVector.h:204: void llvm::SmallVectorTemplateCommonmlir::memref::AllocOp::assertSafeToReferenceAfterResize(const void , size_t) [T = mlir::memref::AllocOp]: Assertion `isSafeToReferenceAfterResize(Elt, NewSize) && "Attempting to reference an element of the vector in an operation " "that invalidates it"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: streamhls-opt /scratch/patrick/Stream-HLS/examples/designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/mlir/input/MultiHeadSelfAttention.mlir "-streamhls-kernel-pipeline=top-func=forward graph-file=/scratch/patrick/Stream-HLS/examples/designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/mlir/graphs/graph report-file=/scratch/patrick/Stream-HLS/examples/designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/mlir/intermediates/MultiHeadSelfAttention optimize-schedule=true parallelize-nodes=true combined-optimization=true board-dsps=357 tiling-limit=1 time-limit-minutes=1 bufferize-func-args=0 optimize-conv-reuse=0 minimize-on-chip-buffers=0 debug-point=14"
#0 0x000000000ab21dcd llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:11
#1 0x000000000ab2228b PrintStackTraceSignalHandler(void
) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x000000000ab2042f llvm::sys::RunSignalHandlers() /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/lib/Support/Signals.cpp:105:5
#3 0x000000000ab2295e SignalHandler(int) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007feb95045990 __restore_rt (/lib64/libpthread.so.0+0x12990)
#5 0x00007feb938c552f raise (/lib64/libc.so.6+0x4e52f)
#6 0x00007feb93898e65 abort (/lib64/libc.so.6+0x21e65)
#7 0x00007feb93898d39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)
#8 0x00007feb938bde86 (/lib64/libc.so.6+0x46e86)
#9 0x0000000007b51f44 llvm::SmallVectorTemplateCommon<mlir::memref::AllocOp, void>::assertSafeToReferenceAfterResize(void const*, unsigned long) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/SmallVector.h:205:3
#10 0x0000000007b51ecd llvm::SmallVectorTemplateCommon<mlir::memref::AllocOp, void>::assertSafeToAdd(void const*, unsigned long) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/SmallVector.h:211:3
#11 0x0000000007b51e24 llvm::SmallVectorTemplateCommon<mlir::memref::AllocOp, void>::assertSafeToAddRange(mlir::memref::AllocOp const*, mlir::memref::AllocOp const*) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/SmallVector.h:230:11
#12 0x0000000007b461f9 void llvm::SmallVectorImplmlir::memref::AllocOp::append<mlir::memref::AllocOp*, void>(mlir::memref::AllocOp*, mlir::memref::AllocOp*) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/SmallVector.h:697:11
#13 0x0000000007b2ed4f mlir::streamhls::DFG::mergeNodes(unsigned int, unsigned int) /scratch/patrick/Stream-HLS/lib/Support/DFG.cpp:569:3
#14 0x0000000007b2e512 mlir::streamhls::DFG::init(bool) /scratch/patrick/Stream-HLS/lib/Support/DFG.cpp:361:7
#15 0x0000000007b0ff24 (anonymous namespace)::PrintDataflowGraph::runOnOperation() /scratch/patrick/Stream-HLS/lib/Analysis/PrintDataflowGraph.cpp:38:9
#16 0x000000000a65ff14 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:0:17
#17 0x000000000a65feb5 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#18 0x0000000008e4c9d9 llvm::function_ref<void ()>::operator()() const /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#19 0x000000000a66299b void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRefmlir::IRUnit, mlir::Pass&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/include/mlir/IR/MLIRContext.h:276:3
#20 0x000000000a65b980 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:525:17
#21 0x000000000a65be97 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:585:16
#22 0x000000000a661035 mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo&) const /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:805:36
#23 0x000000000a660d58 mlir::LogicalResult mlir::failableParallelForEach<__gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, __gnu_cxx::__normal_iterator<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>>, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/include/mlir/IR/Threading.h:46:18
#24 0x000000000a65d14b mlir::LogicalResult mlir::failableParallelForEach<std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&>(mlir::MLIRContext*, std::vector<mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo, std::allocatormlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::OpPMInfo>&, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool)::$_0&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/include/mlir/IR/Threading.h:92:10
#25 0x000000000a65ca4c mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:815:14
#26 0x000000000a65c560 mlir::detail::OpToOpPassAdaptor::runOnOperation(bool) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:706:5
#27 0x000000000a65ff02 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1::operator()() const /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:517:11
#28 0x000000000a65feb5 void llvm::function_ref<void ()>::callback_fn<mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int)::$_1>(long) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:5
#29 0x0000000008e4c9d9 llvm::function_ref<void ()>::operator()() const /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:5
#30 0x000000000a66299b void mlir::MLIRContext::executeAction<mlir::PassExecutionAction, mlir::Pass&>(llvm::function_ref<void ()>, llvm::ArrayRefmlir::IRUnit, mlir::Pass&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/include/mlir/IR/MLIRContext.h:276:3
#31 0x000000000a65b980 mlir::detail::OpToOpPassAdaptor::run(mlir::Pass*, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:525:17
#32 0x000000000a65be97 mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager&, mlir::Operation*, mlir::AnalysisManager, bool, unsigned int, mlir::PassInstrumentor*, mlir::PassInstrumentation::PipelineParentInfo const*) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:585:16
#33 0x000000000a65d8e8 mlir::PassManager::runPasses(mlir::Operation*, mlir::AnalysisManager) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:896:10
#34 0x000000000a65d823 mlir::PassManager::run(mlir::Operation*) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Pass/Pass.cpp:876:60
#35 0x0000000007a3e7fd performActions(llvm::raw_ostream&, std::shared_ptrllvm::SourceMgr const&, mlir::MLIRContext*, mlir::MlirOptMainConfig const&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:394:17
#36 0x0000000007a3e462 processBuffer(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, mlir::MlirOptMainConfig const&, mlir::DialectRegistry&, llvm::ThreadPool*) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:459:12
#37 0x0000000007a3e25c mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, llvm::raw_ostream&) const /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:530:12
#38 0x0000000007a3e1f6 mlir::LogicalResult llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, llvm::raw_ostream&)>::callback_fn<mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&)::$_0>(long, std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, llvm::raw_ostream&) /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
#39 0x000000000a9e6ff2 llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, llvm::raw_ostream&)>::operator()(std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, llvm::raw_ostream&) const /scratch/patrick/Stream-HLS/extern/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
#40 0x000000000a9e6639 mlir::splitAndProcessBuffer(std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, llvm::function_ref<mlir::LogicalResult (std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, llvm::raw_ostream&)>, llvm::raw_ostream&, bool, bool) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Support/ToolUtilities.cpp:28:12
#41 0x0000000007a3b21d mlir::MlirOptMain(llvm::raw_ostream&, std::unique_ptr<llvm::MemoryBuffer, std::default_deletellvm::MemoryBuffer>, mlir::DialectRegistry&, mlir::MlirOptMainConfig const&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:533:10
#42 0x0000000007a3b4af mlir::MlirOptMain(int, char**, llvm::StringRef, llvm::StringRef, mlir::DialectRegistry&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:568:14
#43 0x0000000007a3b678 mlir::MlirOptMain(int, char**, llvm::StringRef, mlir::DialectRegistry&) /scratch/patrick/Stream-HLS/extern/llvm-project/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp:584:10
#44 0x0000000003cbae96 main /scratch/patrick/Stream-HLS/tools/streamhls-opt/streamhls-opt.cpp:17:17
#45 0x00007feb938b17e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)
#46 0x0000000003cbad6e _start (/scratch/patrick/Stream-HLS/build/bin/streamhls-opt+0x3cbad6e)
/bin/sh: line 1: 1546687 Aborted (core dumped) streamhls-opt /scratch/patrick/Stream-HLS/examples/designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/mlir/input/MultiHeadSelfAttention.mlir -streamhls-kernel-pipeline="top-func=forward graph-file=/scratch/patrick/Stream-HLS/examples/designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/mlir/graphs/graph report-file=/scratch/patrick/Stream-HLS/examples/designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/mlir/intermediates/MultiHeadSelfAttention optimize-schedule=true parallelize-nodes=true combined-optimization=true board-dsps=357 tiling-limit=1 time-limit-minutes=1 bufferize-func-args=0 optimize-conv-reuse=0 minimize-on-chip-buffers=0 debug-point=14" > /scratch/patrick/Stream-HLS/examples/designs/transformers/opt5/MultiHeadSelfAttention_357/MultiHeadSelfAttention/mlir/kernel/MultiHeadSelfAttention.mlir

Time taken: 61.96707773208618 seconds
Generated HLS for MultiHeadSelfAttention
Compiling MultiHeadSelfAttention...
/tmp/ccIUYTLT.o: In function main': MultiHeadSelfAttention_tb.cpp:(.text+0x66f): undefined reference to forward(float () [64][128], float, float () [128], float, float () [128], float, float () [128], float, float () [128], float () [64][128])'
collect2: error: ld returned 1 exit status
/bin/sh: line 2: ./MultiHeadSelfAttention.bin: No such file or directory

Running csim for MultiHeadSelfAttention...
Success!
Finished MultiHeadSelfAttention...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions