Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gramalingam committed Jan 17, 2025
1 parent 0dfc565 commit 6556646
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions onnxscript/rewriter/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,22 +1567,23 @@ def _apply_to_graph_or_function(
if delta is None or tracer is not None:
continue
assert isinstance(delta, ReplacementSubgraph)
if delta.new_initializers and isinstance(graph_or_function, ir.Function):
# TODO(rama): Can't add initializers to functions. But currently this is not
# an issue, as we apply inlining before applying rewrite rules.
if verbose:
print(
f"Rewrites adding initializers not supported for functions: {rule}"
)
continue
initializers = graph_or_function.initializers
for initializer in delta.new_initializers:
if initializer.name in initializers:
if delta.new_initializers:
if isinstance(graph_or_function, ir.Function):
# TODO(rama): Can't add initializers to functions. But currently this is not
# an issue, as we apply inlining before applying rewrite rules.
if verbose:
print(f"Initializer {initializer.name} already exists.")
print(
f"Rewrites adding initializers not supported for functions: {rule}"
)
continue
for initializer in delta.new_initializers:
initializers[initializer.name] = initializer
initializers = graph_or_function.initializers
for initializer in delta.new_initializers:
if initializer.name in initializers:
if verbose:
print(f"Initializer {initializer.name} already exists.")
continue
for initializer in delta.new_initializers:
initializers[initializer.name] = initializer

Check failure

Code scanning / lintrunner

MYPY/index Error

Invalid index type "str | None" for "dict[str, Value]"; expected type "str" To disable, use # type: ignore[index]
# TODO: This does not yet handle the problem of determining the correct insertion point
# for inserted nodes in the case of patterns with multiple output-nodes. The following
# is sufficient for patterns with a single output-node "node", which can serve as the
Expand Down

0 comments on commit 6556646

Please sign in to comment.