How to run bindings test

Hi there,

Reading through the MLIR bindings and the following FileCheck test exists

# RUN: %PYTHON %s | mlir-opt -split-input-file | FileCheck

# TODO: Move to a test utility class once any of this actually exists.
def print_module(f):
  m = f()
  print("// -----")
  print("// TEST_FUNCTION:", f.__name__)
  return f

def create_my_op():
  m =
  builder = m.new_op_builder()
  # CHECK: mydialect.my_operation ...
  return m

How do I go about running this? I tried just running the section at the start (%PYTHON %s | mlir-opt -split-input-file | FileCheck), but get

$ %PYTHON %s | mlir-opt -split-input-file | FileCheck
<check-file> not specified
%PYTHON: command not found


1 Like

Use llvm-lit. For example, $LLVM_DIR/build/bin/llvm-lit mlir/test/python/ It performs the substitution of %PYTHON according to the configuration that you can find in llvm-project/ at main · llvm/llvm-project · GitHub.

1 Like

That’s super helpful thank you!

I ran the example syntax you mentioned above, however the test fails:

-- Testing: 1 tests, 1 workers --
FAIL: MLIR :: python/ (1 of 1)
Failed Tests (1):
  MLIR :: python/

Testing Time: 0.58s
  Failed: 1

Any ideas why?

Never mind, running the test with -v to show a larger description of the error fixed it:)

Thanks for your help!


Hi all, running the mlir binding tests gives me an UNSUPPORTED error message. verbose flag doesn’t provide any further information. Here is the command I run and it’s output:

build/bin/llvm-lit -v mlir/test/python/
-- Testing: 1 tests, 1 workers --
UNSUPPORTED: MLIR :: python/ (1 of 1)

Testing Time: 0.10s
  Unsupported: 1

Does anyone know what causes this and how to fix it?

I suspect you don’t have the bindings enabled? See: MLIR Python Bindings - MLIR

1 Like

that did it, thank you!