Skip to content

Commit

Permalink
Allow rewriter input/output to be IR (#1639)
Browse files Browse the repository at this point in the history
Allow rewriter input/output to be IR.

Eventually, we will keep all intermediate form in IR (switching to proto
only at end).

Issue #1401
  • Loading branch information
gramalingam authored Jun 19, 2024
1 parent 523e466 commit c332202
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions onnxscript/rewriter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.
from __future__ import annotations

from typing import Sequence, Union, TypeVar
from typing import Sequence, TypeVar, Union

__all__ = [
# Modules
Expand All @@ -22,7 +22,8 @@
PatternRewriteRule = pattern.RewriteRule
FunctionRewriteRule = function_rule.FunctionRewriteRule

ModelProtoOrIr = TypeVar('ModelProtoOrIr', onnx.ModelProto, ir.Model)
ModelProtoOrIr = TypeVar("ModelProtoOrIr", onnx.ModelProto, ir.Model)


def rewrite(
model: ModelProtoOrIr,
Expand Down Expand Up @@ -51,4 +52,4 @@ def rewrite(
if proto:
model = ir.serde.serialize_model(model_ir)
return model
return model_ir
return model_ir # type: ignore[return-value]

0 comments on commit c332202

Please sign in to comment.