Register design modules in sys.modules to fix path wrangling (#42)#121
Open
masteryi-0018 wants to merge 1 commit into
Open
Register design modules in sys.modules to fix path wrangling (#42)#121masteryi-0018 wants to merge 1 commit into
masteryi-0018 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Close #42
Summary
Remove the path wrangling in
compilation.pyby registering design modules insys.modulesunder their fully-qualified package names.Before
DesignGenerator.__call__loaded design modules withspec_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 samespec_from_file_locationdance.get_child_mlir_moduleinfusion.pyduplicated the same 3-linespec_from_file_location+module_from_spec+exec_modulepattern.After
DesignGenerator.__call__derives a proper dotted module name from the file path (e.g.iron.operators.axpy.design), registers the loaded module insys.modules, and loads it.get_child_mlir_modulenow simply callsimportlib.import_module(gen.module_name)to retrieve the already-registered module.Changes
iron/common/compilation/base.pymodule_nameproperty, +sys.modules[module_name] = moduleiron/common/compilation/fusion.pyZero changes to operator callers.
🤖 Generated with Claude Code