Skip to content

Conversation

@tucan9389
Copy link

@tucan9389 tucan9389 commented Sep 23, 2025

Image

Overview

This PR significantly enhances MLIR visualization by replacing the legacy, handwritten parser with tucan9389/mlir-js-parser. This migration establishes a robust, accurate, and extensible foundation for MLIR support in Netron.

Key Changes and Benefits

  • Migration to the Official C++ MLIR Parser: We have replaced the previous implementation with the official C++ MLIR parser compiled to WebAssembly (Wasm). This ensures greater accuracy and ideal alignment with the MLIR specification.
  • Improved Extensibility: By relying on the upstream C++ implementation, Netron can now more easily support new MLIR dialects and future evolutions of the standard.
  • Reduced Maintenance Burden: While this PR vendors Wasm/JS artifacts, it removes approximately 1200+ lines of complex, handwritten parsing logic (significantly shrinking source/mlir.js), simplifying the maintainable codebase.
  • Practical Coverage: The integrated parser provides meaningful, real-world coverage. As detailed in the StableHLO Coverage Report, it successfully parses 85% of 5449 StableHLO MLIR files.

Tooling and Deployment

  • Dependency Management: A new script, tools/update-mlir-parser.js, has been introduced. This script automates the process of fetching the latest mlir-parser.js and mlir-parser.wasm artifacts from the upstream repository and updating the vendored copies in the third_party/ directory.
  • ⚠️ Deployment Note: The required artifacts are checked into the repository. The deployment pipeline for netron.app must ensure these static assets (.js and .wasm files) are correctly included and served. Please also verify that the web server configuration serves .wasm files with the correct MIME type (application/wasm).

cc. @janpfeifer

@tucan9389 tucan9389 marked this pull request as ready for review September 23, 2025 05:46
@tucan9389 tucan9389 mentioned this pull request Sep 23, 2025
@lutzroeder lutzroeder force-pushed the main branch 3 times, most recently from 93446b7 to 17f9a5f Compare October 12, 2025 02:20
@lutzroeder
Copy link
Owner

lutzroeder commented Oct 20, 2025

@tucan9389 thank you so much for digging into this. main now has a quick exploration what it would take to bring basic TableGen and dialects into JavaScript and see how far that approach can go. The WASM route looks promising too, so let's keep this open. How much can the .wasm size be trimmed and how would we handle dependency management and security if we went that way?

@lutzroeder lutzroeder force-pushed the main branch 18 times, most recently from 740830f to e97c3bf Compare October 27, 2025 16:16
@lutzroeder lutzroeder force-pushed the main branch 4 times, most recently from 5d7b523 to 6a9e9ba Compare October 28, 2025 02:33
@lutzroeder lutzroeder force-pushed the main branch 26 times, most recently from e70ae37 to 988ef66 Compare October 31, 2025 15:07
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