Skip to content

Commit bc95391

Browse files
metascroyfacebook-github-bot
authored andcommitted
Handle case when native_schema is None (#9377)
Summary: https://fb.workplace.com/groups/pytorch.edge.users/posts/1714672769403009/?comment_id=1721960698674216 Reviewed By: larryliu0820 Differential Revision: D71413713
1 parent 3bb28ba commit bc95391

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

exir/program/_program.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -995,17 +995,24 @@ def keep(op):
995995

996996
schema = op._schema
997997
native_schema = _pybind_schema_to_native_schema(schema)
998-
if native_schema.is_mutable:
998+
if native_schema is None:
999999
logging.warn(
1000-
f"Op {op} was requested for preservation by partitioner. This request is ignored because it is mutable."
1000+
f"Op {op} was requested for preservation by partitioner."
1001+
+ f"This request is ignored because Torchgen is not able to parse the schema of {op._schema}, which is necessary to determine if the op is mutable or aliases output."
10011002
)
10021003
return False
1004+
else:
1005+
if native_schema.is_mutable:
1006+
logging.warn(
1007+
f"Op {op} was requested for preservation by partitioner. This request is ignored because it is mutable."
1008+
)
1009+
return False
10031010

1004-
if native_schema.aliased_return_names() != [None]:
1005-
logging.warn(
1006-
f"Op {op} was requested for preservation by partitioner. This request is ignored because it aliases output."
1007-
)
1008-
return False
1011+
if native_schema.aliased_return_names() != [None]:
1012+
logging.warn(
1013+
f"Op {op} was requested for preservation by partitioner. This request is ignored because it aliases output."
1014+
)
1015+
return False
10091016

10101017
# Explicit block list of ops that don't work if asked for
10111018
# preservation

0 commit comments

Comments
 (0)