Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions onnxscript/ir/passes/_pass_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import dataclasses
import logging
from typing import Sequence
from typing import Literal, Sequence, final

__all__ = [
"PassBase",
Expand Down Expand Up @@ -180,23 +180,31 @@ class InPlacePass(PassBase):
"""A pass that modifies the input model in place and returns it."""

@property
def in_place(self) -> bool:
@final
def in_place(self) -> Literal[True]:
"""An in-place pass is in place."""
return True

@property
def changes_input(self) -> bool:
@final
def changes_input(self) -> Literal[True]:
"""An in-place pass changes the input model."""
return True


class FunctionalPass(PassBase):
"""A pass that returns a new model but does not modify the input model."""

@property
def in_place(self) -> bool:
@final
def in_place(self) -> Literal[False]:
"""A functional pass is not in place."""
return False

@property
def changes_input(self) -> bool:
@final
def changes_input(self) -> Literal[False]:
"""A functional pass does not change the input model."""
return False


Expand Down
Loading