Repository navigation
Macro refactor - #291
Merged
Merged
Macro refactor#291
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors FX converters to route MIGraphX op creation through the new core “macro/kit” builders (when available), reducing torch-migraphx’s direct dependency on individual MIGraphX op semantics and centralizing op lowering behavior in core MIGraphX.
Changes:
- Introduces a new
mgx_builder.pyabstraction (add_op,add_common_op, andbuild_*helpers) to prefertm::kit builders with raw-op fallbacks. - Updates multiple converters to use the builder layer (including elementwise ops, reductions, pooling, conv/linear, norms, LSTM, and quant helpers).
- Simplifies several converter implementations by delegating composite behavior (e.g., batchnorm/instance_norm/std/scatter_reduce) into builder helpers.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| py/torch_migraphx/fx/converters/utils.py | Switches selected utility instruction construction to the new builder helpers. |
| py/torch_migraphx/fx/converters/quant_ops_converters.py | Routes a quant helper op through add_op. |
| py/torch_migraphx/fx/converters/module_converters.py | Moves LSTM lowering to build_lstm and uses add_op for supporting ops. |
| py/torch_migraphx/fx/converters/mgx_builder.py | Adds the new op-building layer and composite builder helpers with kit probing. |
| py/torch_migraphx/fx/converters/aten_ops_converters.py | Uses add_op for dtype conversion in _to_copy-family ops. |
| py/torch_migraphx/fx/converters/acc_ops_converters.py | Broad adoption of add_op/add_common_op and delegation to build_* helpers across many acc_ops converters. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+857
to
860
| # Empty axes squeezes every size-1 dim, matching torch.squeeze() with no dim. | ||
| axes = [] if dim is None else [dim] | ||
| out = add_op(mgx_module, 'squeeze', [inp_ref], axes=axes) | ||
|
|
Comment on lines
660
to
+664
| def acc_ops_log_softmax(mgx_module, node, _args, kwargs): | ||
| inp = kwargs['input'] | ||
| assert not inp.is_quantized() | ||
| softmax_ins = mgx_module.add_instruction( | ||
| migraphx.op('softmax', axis=kwargs['dim']), [inp.instr_ref]) | ||
| return MGXInstruction( | ||
| mgx_module.add_instruction(migraphx.op('log'), [softmax_ins])) | ||
| add_op(mgx_module, 'logsoftmax', [inp.instr_ref], axis=kwargs['dim'])) |
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.
Use the new macro objects provided by core MIGraphX. This allows torch-migraphx to be less prone to regressions caused by changes to migraphx operations. The ownership of the semantic conversion of torch ops moves to the core repo.