Skip to content

Register design modules in sys.modules to fix path wrangling (#42)#121

Open
masteryi-0018 wants to merge 1 commit into
amd:develfrom
masteryi-0018:fix/issue-42-cleanup-operator-paths
Open

Register design modules in sys.modules to fix path wrangling (#42)#121
masteryi-0018 wants to merge 1 commit into
amd:develfrom
masteryi-0018:fix/issue-42-cleanup-operator-paths

Conversation

@masteryi-0018

Copy link
Copy Markdown

Close #42

Summary

Remove the path wrangling in compilation.py by registering design modules in sys.modules under their fully-qualified package names.

Before

  • DesignGenerator.__call__ loaded design modules with spec_from_file_location(filename, path) using only the file basename as the module name -- the module was not registered, so code that needed the design later had to duplicate the same spec_from_file_location dance.
  • get_child_mlir_module in fusion.py duplicated the same 3-line spec_from_file_location + module_from_spec + exec_module pattern.

After

  • DesignGenerator.__call__ derives a proper dotted module name from the file path (e.g. iron.operators.axpy.design), registers the loaded module in sys.modules, and loads it.
  • get_child_mlir_module now simply calls importlib.import_module(gen.module_name) to retrieve the already-registered module.

Changes

File Change
iron/common/compilation/base.py + module_name property, + sys.modules[module_name] = module
iron/common/compilation/fusion.py 3-line spec_from_file_location → 1-line importlib.import_module

Zero changes to operator callers.

🤖 Generated with Claude Code

DesignGenerator.__call__ now registers the loaded module under its
fully-qualified package name (e.g. iron.operators.axpy.design) so that
subsequent code can import it through the standard Python import mechanism
instead of duplicating spec_from_file_location calls.

get_child_mlir_module in fusion.py now uses importlib.import_module to
retrieve the already-registered module.

Closes amd#42

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Clean up test discovery and operator paths

1 participant