Skip to content

Fix dialect registration in neura interpreter#317

Open
TimJZ wants to merge 2 commits into
coredac:mainfrom
TimJZ:fix-neura-interpreter-issue
Open

Fix dialect registration in neura interpreter#317
TimJZ wants to merge 2 commits into
coredac:mainfrom
TimJZ:fix-neura-interpreter-issue

Conversation

@TimJZ

@TimJZ TimJZ commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes a dialect registration issue in neura-interpreter.

Previously, neura-interpreter could not parse Neura MLIR files generated from the normal LLVM-import/e2e flow because the imported module may contain dlti.dl_spec metadata. This caused the interpreter to fail before it could execute the Neura dataflow IR.

The failure looked like:

'dlti' attribute created with unregistered dialect
[neura-interpreter] Failed to parse MLIR input file

After this fix, neura-interpreter can parse the mapped ReLU IR generated by the existing mlir-neura-opt pipeline and proceed into dataflow execution.

Testing

Tested manually on the ReLU e2e lowering flow.

1. Rebuild the updated tools

cd ~/dev/neura
ninja -C build neura-interpreter mlir-neura-opt

2. Generate LLVM IR for the ReLU kernel

mkdir -p /tmp/neura-step2-relu
cd /tmp/neura-step2-relu

clang++ -S -emit-llvm -O3 \
  -fno-vectorize -fno-unroll-loops \
  -std=c++17 \
  -o relu_kernel_full.ll \
  ~/dev/neura/test/benchmark/CGRA-Bench/kernels/relu/relu_int.cpp

3. Extract the kernel function and import it into MLIR

llvm-extract --rfunc=".*kernel.*" \
  relu_kernel_full.ll \
  -o relu_kernel_only.ll

mlir-translate --import-llvm \
  relu_kernel_only.ll \
  -o relu_kernel_imported.mlir

mlir-translate may print warnings such as:

warning: unhandled data layout token: m:e
warning: unhandled data layout token: n8:16:32:64

These warnings are not fatal; relu_kernel_imported.mlir is still generated.

4. Lower and map the imported MLIR to Neura IR

mlir-neura-opt relu_kernel_imported.mlir \
  --assign-accelerator \
  --lower-llvm-to-neura \
  --promote-input-arg-to-const \
  --fold-constant \
  --canonicalize-return \
  --canonicalize-live-in \
  --leverage-predicated-value \
  --transform-ctrl-to-data-flow \
  --fold-constant \
  --insert-data-mov \
  --map-to-accelerator="mapping-strategy=heuristic" \
  --architecture-spec=$HOME/dev/neura/test/arch_spec/architecture.yaml \
  -o relu_neura_mapped.mlir

Confirmed that the mapped IR was generated:

ls -lh relu_neura_mapped.mlir

Observed:

-rw-r--r-- 1 gnahzmit gnahzmit 15K May 19 18:18 relu_neura_mapped.mlir

5. Verify the interpreter behavior

Before this fix, running the interpreter on the mapped ReLU IR failed during parsing:

neura-interpreter relu_neura_mapped.mlir

Previous error:

'dlti' attribute created with unregistered dialect
[neura-interpreter] Failed to parse MLIR input file

After this fix, the interpreter successfully parses the mapped ReLU IR and begins dataflow execution:

neura-interpreter relu_neura_mapped.mlir --verbose --dataflow

Observed output includes:

[neura-interpreter]  Initial pending operation: %5 = neura.reserve ...
[neura-interpreter]  Initial pending operation: %1 = "neura.grant_once"() ...
[neura-interpreter]  DFG Iteration 0 - Beginning
[neura-interpreter]  Executing operation: %5 = neura.reserve ...

This confirms that the dialect registration issue is fixed.

The interpreter now proceeds past MLIR parsing and exposes the next execution-level issue:

[neura-interpreter]  Executing operation: neura.yield ...
[neura-interpreter]  Unhandled op: neura.yield ...
[neura-interpreter]  Execution failed

That neura.yield handling is a separate follow-up issue and is not addressed by this PR.

@tancheng tancheng left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add

// WIP: https://github.com/coredac/neura/issues/5
// RN: neura-interpreter %t-neura.mlir >> %t-dumped_output.txt

into a e2e test you wanna enable interpreter?

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@TimJZ

TimJZ commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator Author

Added // WIP and // RN markers to test/e2e/relu/relu_kernel.mlir pointing to issue #5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants