Skip to content

error: failed to legalize operation 'torch.operator' that was explicitly marked illegal #4575

@rengolin

Description

@rengolin

When lowering some KernelBench programs (level1: 12, 96, 99), I get this error:

error: failed to legalize operation 'torch.operator' that was explicitly marked illegal

Reproducer:

  1. Clone Lighthouse
  2. Init uv as in README
  3. Run: $ uv run examples/end-to-end/KernelBench/test_kernel_bench.py --test level1/12_

Error message:

loc("/home/rengolin/devel/llvm/lighthouse/third_party/KernelBench/KernelBench/level1/12_Matmul_with_diagonal_matrices_.py":23:0): error: failed to legalize operation 'torch.operator' that was explicitly marked illegal
ERROR: got an error converting /home/rengolin/devel/llvm/lighthouse/third_party/KernelBench/KernelBench/level1/12_Matmul_with_diagonal_matrices_.py to MLIR:
...
stack trace
...
torch_mlir.compiler_utils.TorchMlirCompilerError: Lowering TorchFX IR -> Torch Backend IR failed with the following diagnostics:


python exception: Failure while executing pass pipeline

For Torch-MLIR developers, the error can be reproduced with:
$ torch-mlir-opt -pass-pipeline='builtin.module(func.func(torch-match-quantized-custom-ops), torchdynamo-export-to-torch-backend-pipeline{ extra-library=})' /tmp/UnnammedModule.mlir
Add '-mlir-print-ir-after-all -mlir-disable-threading' to get the IR dump for debugging purpose.

Kernel 12, Line 23 is:
return torch.diag(A) @ B

Kernel 96, line 15 is:
return torch.nn.functional.smooth_l1_loss(predictions, targets)

Kernel 99, line 16 is:
return self.loss_fn(anchor, positive, negative)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions