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
14 changes: 14 additions & 0 deletions onnxscript/ir/passes/_pass_infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@
f"The result of the pass '{self.__class__.__name__}' should be type PassResult. "
"Please create one with ir.passes.PassResult()."
)

# Checks that the declared in-place property is respected
if self.in_place and result.model is not model:
raise PassError(

Check warning on line 142 in onnxscript/ir/passes/_pass_infra.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/ir/passes/_pass_infra.py#L142

Added line #L142 was not covered by tests
f"The pass '{self.__class__.__name__}' is declared in-place, "
"but the model returned is *not* the same object as the input model. "
"Pass developer: Pass should return the same model object or the in_place property should return False."
)
if not self.in_place and result.model is model:
raise PassError(

Check warning on line 148 in onnxscript/ir/passes/_pass_infra.py

View check run for this annotation

Codecov / codecov/patch

onnxscript/ir/passes/_pass_infra.py#L148

Added line #L148 was not covered by tests
f"The pass '{self.__class__.__name__}' is declared not in-place, "
"but the model returned *is* the same object as the input model. "
"Pass developer: Pass should return a new model object or the in_place property should return True."
)
return result

@abc.abstractmethod
Expand Down
Loading