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

Compiler hitting assert for several "shape" ONNX tests #16814

Open
ScottTodd opened this issue Mar 18, 2024 · 1 comment
Open

Compiler hitting assert for several "shape" ONNX tests #16814

ScottTodd opened this issue Mar 18, 2024 · 1 comment
Labels
bug 🐞 Something isn't working integrations/pytorch PyTorch integration work

Comments

@ScottTodd
Copy link
Collaborator

ScottTodd commented Mar 18, 2024

Misc background:

Noticed these failures while looking at #16811 (comment). Haven't been able to determine if this is a regression / find a culprit. Probably an issue in upstream torch-mlir, but might already be fixed. IREE CI is running these tests without LLVM asserts, so something is slipping through the test suite.

General info

Building at ee32fc7

Seeing test failures from compiler crashes here:

FAILED onnx/node/generated/test_shape_end_1/model.mlir::cpu_llvm_sync
FAILED onnx/node/generated/test_shape_start_1_end_negative_1/model.mlir::cpu_llvm_sync
FAILED onnx/node/generated/test_shape_start_1/model.mlir::cpu_llvm_sync
FAILED onnx/node/generated/test_shape_start_negative_1/model.mlir::cpu_llvm_sync
FAILED onnx/node/generated/test_shape_start_1_end_2/model.mlir::cpu_llvm_sync
FAILED onnx/node/generated/test_shape_end_negative_1/model.mlir::cpu_llvm_sync

Sample test case source: https://github.com/nod-ai/SHARK-TestSuite/blob/main/iree_tests/onnx/node/generated/test_shape_start_1/model.mlir

Repro command:
iree-compile model.mlir --iree-hal-target-backends=llvm-cpu -o /dev/null

Logs

Callstack from Windows (click to expand)


iree-compile.exe!HandleAbort(int Sig) Line 424 (d:\dev\projects\iree\third_party\llvm-project\llvm\lib\Support\Windows\Signals.inc:424)
ucrtbase.dll!00007ffe72681881() (Unknown Source:0)
ucrtbase.dll!00007ffe72682851() (Unknown Source:0)
ucrtbase.dll!00007ffe726841b5() (Unknown Source:0)
ucrtbase.dll!00007ffe726844f1() (Unknown Source:0)
iree-compile.exe!mlir::DenseElementsAttr::get(mlir::ShapedType type, llvm::ArrayRef values) Line 898 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\IR\BuiltinAttributes.cpp:898)
iree-compile.exe!mlir::torch::Torch::Aten_ShapeAsTensorOp::fold(mlir::torch::Torch::Aten_ShapeAsTensorOpGenericAdaptor> adaptor) Line 3381 (d:\dev\projects\iree\third_party\torch-mlir\lib\Dialect\Torch\IR\TorchOps.cpp:3381)
[Inline Frame] iree-compile.exe!mlir::Op::Impl,mlir::OpTrait::ZeroSuccessors,mlir::OpTrait::OneOperand,mlir::OpTrait::OpInvariants,mlir::torch::Torch::OpTrait::AllowsTypeRefinement,mlir::torch::Torch::OpTrait::HasValueSemantics,mlir::torch::Torch::OpTrait::ReadOnly>::foldSingleResultHook(mlir::Operation *) Line 1903 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\OpDefinition.h:1903)
iree-compile.exe!mlir::Op::Impl,mlir::OpTrait::ZeroSuccessors,mlir::OpTrait::OneOperand,mlir::OpTrait::OpInvariants,mlir::torch::Torch::OpTrait::AllowsTypeRefinement,mlir::torch::Torch::OpTrait::HasValueSemantics,mlir::torch::Torch::OpTrait::ReadOnly>::getFoldHookFn::__l5::(mlir::Operation * op, llvm::ArrayRef operands, llvm::SmallVectorImpl & results) Line 1879 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\OpDefinition.h:1879)
iree-compile.exe!llvm::detail::UniqueFunctionBase,llvm::SmallVectorImpl &>::CallImpl(mlir::Operation *, llvm::ArrayRef, llvm::SmallVectorImpl &) const>(void * CallableAddr, mlir::Operation * , llvm::ArrayRef , llvm::SmallVectorImpl & ) Line 221 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\FunctionExtras.h:221)
iree-compile.exe!llvm::unique_function,llvm::SmallVectorImpl &)const>::operator()(mlir::Operation * , llvm::ArrayRef , llvm::SmallVectorImpl & ) Line 411 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\FunctionExtras.h:411)
iree-compile.exe!mlir::RegisteredOperationName::Model::foldHook(mlir::Operation * op, llvm::ArrayRef attrs, llvm::SmallVectorImpl & results) Line 539 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\OperationSupport.h:539)
[Inline Frame] iree-compile.exe!mlir::OperationName::foldHook(mlir::Operation *) Line 266 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\OperationSupport.h:266)
iree-compile.exe!mlir::Operation::fold(llvm::ArrayRef operands, llvm::SmallVectorImpl & results) Line 636 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\IR\Operation.cpp:636)
iree-compile.exe!mlir::Operation::fold(llvm::SmallVectorImpl & results) Line 666 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\IR\Operation.cpp:666)
iree-compile.exe!`anonymous namespace'::GreedyPatternRewriteDriver::processWorklist() Line 490 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Transforms\Utils\GreedyPatternRewriteDriver.cpp:490)
[Inline Frame] iree-compile.exe!`anonymous-namespace'::RegionPatternRewriteDriver::simplify::__l4::::operator()() Line 839 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Transforms\Utils\GreedyPatternRewriteDriver.cpp:839)
iree-compile.exe!llvm::function_ref::callback_fn<>(__int64 callable) Line 45 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:45)
[Inline Frame] iree-compile.exe!llvm::function_ref::operator()() Line 68 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:68)
[Inline Frame] iree-compile.exe!mlir::MLIRContext::executeAction(llvm::function_ref) Line 275 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\MLIRContext.h:275)
iree-compile.exe!`anonymous namespace'::RegionPatternRewriteDriver::simplify(bool * changed) Line 837 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Transforms\Utils\GreedyPatternRewriteDriver.cpp:837)
iree-compile.exe!mlir::applyPatternsAndFoldGreedily(mlir::Region & region, const mlir::FrozenRewritePatternSet & patterns, mlir::GreedyRewriteConfig config, bool * changed) Line 880 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Transforms\Utils\GreedyPatternRewriteDriver.cpp:880)
[Inline Frame] iree-compile.exe!mlir::applyPatternsAndFoldGreedily(mlir::Operation *) Line 147 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\Transforms\GreedyPatternRewriteDriver.h:147)
iree-compile.exe!`anonymous namespace'::Canonicalizer::runOnOperation() Line 63 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Transforms\Canonicalizer.cpp:63)
[Inline Frame] iree-compile.exe!mlir::detail::OpToOpPassAdaptor::run::__l2::::operator()() Line 519 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:519)
iree-compile.exe!llvm::function_ref::callback_fn<>(__int64 callable) Line 45 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:45)
[Inline Frame] iree-compile.exe!llvm::function_ref::operator()() Line 68 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:68)
[Inline Frame] iree-compile.exe!mlir::MLIRContext::executeAction(llvm::function_ref) Line 275 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\MLIRContext.h:275)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::run(mlir::Pass * pass, mlir::Operation * op, mlir::AnalysisManager am, bool verifyPasses, unsigned int parentInitGeneration) Line 525 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:525)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager & pm, mlir::Operation * op, mlir::AnalysisManager am, bool verifyPasses, unsigned int parentInitGeneration, mlir::PassInstrumentor * instrumentor, const mlir::PassInstrumentation::PipelineParentInfo * parentInfo) Line 585 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:585)
[Inline Frame] iree-compile.exe!mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl::__l2::::operator()(mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl::__l2::OpPMInfo & opInfo) Line 805 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:805)
iree-compile.exe!mlir::failableParallelForEach>>, &>(mlir::MLIRContext * context, std::_Vector_iterator>> begin, std::_Vector_iterator>> end, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl::__l2:: & func) Line 46 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\Threading.h:46)
iree-compile.exe!mlir::failableParallelForEach> &, &>(mlir::MLIRContext * context, std::vector<`mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl'::`2'::OpPMInfo,std::allocator<`mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl'::`2'::OpPMInfo>> & range, mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl::__l2:: & func) Line 92 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\Threading.h:92)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::runOnOperationAsyncImpl(bool verifyPasses) Line 815 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:815)
[Inline Frame] iree-compile.exe!mlir::detail::OpToOpPassAdaptor::run::__l2::::operator()() Line 517 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:517)
iree-compile.exe!llvm::function_ref::callback_fn<>(__int64 callable) Line 45 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:45)
[Inline Frame] iree-compile.exe!llvm::function_ref::operator()() Line 68 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:68)
[Inline Frame] iree-compile.exe!mlir::MLIRContext::executeAction(llvm::function_ref) Line 275 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\MLIRContext.h:275)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::run(mlir::Pass * pass, mlir::Operation * op, mlir::AnalysisManager am, bool verifyPasses, unsigned int parentInitGeneration) Line 525 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:525)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager & pm, mlir::Operation * op, mlir::AnalysisManager am, bool verifyPasses, unsigned int parentInitGeneration, mlir::PassInstrumentor * instrumentor, const mlir::PassInstrumentation::PipelineParentInfo * parentInfo) Line 585 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:585)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::run::__l2::(mlir::OpPassManager & pipeline, mlir::Operation * root) Line 502 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:502)
iree-compile.exe!llvm::function_ref::callback_fn(mlir::OpPassManager &, mlir::Operation *)>(__int64 callable, mlir::OpPassManager & , mlir::Operation * ) Line 45 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:45)
[Inline Frame] iree-compile.exe!llvm::function_ref::operator()(mlir::OpPassManager &) Line 68 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:68)
[Inline Frame] iree-compile.exe!mlir::Pass::runPipeline(mlir::OpPassManager &) Line 199 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\Pass\Pass.h:199)
iree-compile.exe!mlir::iree_compiler::`anonymous namespace'::AutoInputConversionPipelinePass::runOnOperation() Line 64 (d:\dev\projects\iree\compiler\src\iree\compiler\InputConversion\Common\AutoInputConversionPipeline.cpp:64)
[Inline Frame] iree-compile.exe!mlir::detail::OpToOpPassAdaptor::run::__l2::::operator()() Line 519 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:519)
iree-compile.exe!llvm::function_ref::callback_fn<>(__int64 callable) Line 45 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:45)
[Inline Frame] iree-compile.exe!llvm::function_ref::operator()() Line 68 (d:\dev\projects\iree\third_party\llvm-project\llvm\include\llvm\ADT\STLFunctionalExtras.h:68)
[Inline Frame] iree-compile.exe!mlir::MLIRContext::executeAction(llvm::function_ref) Line 275 (d:\dev\projects\iree\third_party\llvm-project\mlir\include\mlir\IR\MLIRContext.h:275)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::run(mlir::Pass * pass, mlir::Operation * op, mlir::AnalysisManager am, bool verifyPasses, unsigned int parentInitGeneration) Line 525 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:525)
iree-compile.exe!mlir::detail::OpToOpPassAdaptor::runPipeline(mlir::OpPassManager & pm, mlir::Operation * op, mlir::AnalysisManager am, bool verifyPasses, unsigned int parentInitGeneration, mlir::PassInstrumentor * instrumentor, const mlir::PassInstrumentation::PipelineParentInfo * parentInfo) Line 585 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:585)
iree-compile.exe!mlir::PassManager::runPasses(mlir::Operation * op, mlir::AnalysisManager am) Line 896 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:896)
iree-compile.exe!mlir::PassManager::run(mlir::Operation * op) Line 875 (d:\dev\projects\iree\third_party\llvm-project\mlir\lib\Pass\Pass.cpp:875)
iree-compile.exe!mlir::iree_compiler::embed::`anonymous namespace'::Invocation::runPipeline(iree_compiler_pipeline_t pipeline) Line 961 (d:\dev\projects\iree\compiler\src\iree\compiler\API\Internal\CompilerDriver.cpp:961)
iree-compile.exe!mlir::iree_compiler::runIreecMain::__l2::(iree_compiler_source_t * source) Line 247 (d:\dev\projects\iree\compiler\src\iree\compiler\Tools\iree_compile_lib.cc:247)
iree-compile.exe!mlir::iree_compiler::runIreecMain(int argc, char * * argv) Line 348 (d:\dev\projects\iree\compiler\src\iree\compiler\Tools\iree_compile_lib.cc:348)
[Inline Frame] iree-compile.exe!invoke_main() Line 78 (d:\a01\_work\43\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78)
iree-compile.exe!__scrt_common_main_seh() Line 288 (d:\a01\_work\43\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288)
kernel32.dll!00007ffe742e7344() (Unknown Source:0)
ntdll.dll!00007ffe74a026b1() (Unknown Source:0)

Tail of --mlir-print-ir-before-all --debug:

// -----// IR Dump Before Canonicalizer (canonicalize) //----- //
mlir-asm-printer: Verifying operation: func.func
func.func @test_shape_start_1(%arg0: !torch.vtensor<[3,4,5],f32>) -> !torch.vtensor<[2],si64> attributes {torch.assume_strict_symbolic_shapes, torch.onnx_meta.ir_version = 10 : si64, torch.onnx_meta.opset_version = 21 : si64, torch.onnx_meta.producer_name = "backend-test", torch.onnx_meta.producer_version = ""} {
  %none = torch.constant.none
  %0 = torch.aten._shape_as_tensor %arg0 : !torch.vtensor<[3,4,5],f32> -> !torch.vtensor<[2],si64>
  return %0 : !torch.vtensor<[2],si64>
}

ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OneTypedResult<class mlir::Type>::Impl<struct `public: static class mlir::TypeID __cdecl mlir::TypeID::get<class mlir::OpTrait::OneTypedResult<class mlir::Type>::Impl>(void)'::`2'::Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::OneOperand<struct `public: static class mlir::TypeID __cdecl mlir::TypeID::get<class mlir::OpTrait::OneOperand>(void)'::`2'::Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::torch::Torch::OpTrait::HasValueSemantics<struct `public: static class mlir::TypeID __cdecl mlir::TypeID::get<class mlir::torch::Torch::OpTrait::HasValueSemantics>(void)'::`2'::Empty>)
ImplicitTypeIDRegistry::lookupOrInsert(mlir::torch::Torch::OpTrait::ReadOnly<struct `public: static class mlir::TypeID __cdecl mlir::TypeID::get<class mlir::torch::Torch::OpTrait::ReadOnly>(void)'::`2'::Empty>)

//===-------------------------------------------===//
Processing operation : 'torch.constant.none'(0x2296da19400) {
  %0 = "torch.constant.none"() : () -> !torch.none

ImplicitTypeIDRegistry::lookupOrInsert(mlir::OpTrait::HasRecursiveMemoryEffects<struct `public: static class mlir::TypeID __cdecl mlir::TypeID::get<class mlir::OpTrait::HasRecursiveMemoryEffects>(void)'::`2'::Empty>)
  ** Erase   : 'torch.constant.none'(0x2296da19400)
} -> success : operation is trivially dead
//===-------------------------------------------===//

//===-------------------------------------------===//
Processing operation : 'torch.aten._shape_as_tensor'(0x2296e262750) {
  %0 = "torch.aten._shape_as_tensor"(%arg0) : (!torch.vtensor<[3,4,5],f32>) -> !torch.vtensor<[2],si64>

Assertion failed: hasSameElementsOrSplat(type, values), file D:\dev\projects\iree\third_party\llvm-project\mlir\lib\IR\BuiltinAttributes.cpp, line 896

full output: https://gist.github.com/ScottTodd/6710e616b80385e6836811324dfbe560

@ScottTodd ScottTodd added bug 🐞 Something isn't working integrations/pytorch PyTorch integration work labels Mar 18, 2024
@ScottTodd
Copy link
Collaborator Author

Still seeing these, and it's making updating XFAIL lists between local builds and CI builds slightly tricky. Should

  • Fix the crash
  • Enable asserts on pkgci

This was referenced May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working integrations/pytorch PyTorch integration work
Projects
None yet
Development

No branches or pull requests

1 participant