iree-org / iree

A retargetable MLIR-based machine learning compiler and runtime toolkit.
http://iree.dev/
Apache License 2.0
2.83k stars 611 forks source link

[compiler] VM translation of Module to bytecode crashes #18300

Open sogartar opened 2 months ago

sogartar commented 2 months ago

What happened?

I got a segfault in mlir::iree_compiler::IREE::VM::translateModuleToBytecode. Here is a vm-translate-to-bytecode-crash.zip.

Steps to reproduce your issue

Use compile.sh in the ZIP.

What component(s) does this issue relate to?

Compiler

Version information

18217

Additional context

No response

sogartar commented 2 months ago

It turned out that I had missing dialect_resources. program-with-dialect-resources.zip has the missing IR. During verification of util.global we should probably check if the referenced resource is missing.

util.global private @__constant_tensor_4x6x5x5xf32 {inlining_policy = #util.inline.never, stream.affinity.default = #hal.device.affinity<@__device_0>} = dense_resource<torch_tensor_4_6_5_5_torch.float32> : tensor<4x6x5x5xf32>
benvanik commented 2 months ago

Ah yeah, someone hit this the other day when they incorrectly deleted required resources. MLIR should be checking this kind of thing, if anything - resources are an MLIR concept. Globals aren't enough to validate as any op or attribute can reference resources and we can't always be exhaustively checking them all.