Skip to content

Commit

Permalink
[pt2] recursive IR check (#98887)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #98887

IR check needs to be recursive to accommodate Tuple[Tensor, Tuple[Tensor]] schema

Test Plan:
Run the repro cmd and make sure it no longer fails
  TORCH_SHOW_CPP_STACKTRACES=1 TORCH_LOGS="+dynamo,aot,inductor" buck2 run mode/opt scripts/ml_model_exploration/coffee:defi_local -- --baseline_model_entity_id 421946503 --meta_ids '{"union_meta":422685721}' -g -t -l --model_type mimo_ctr_mbl_feed

Differential Revision: D44809096

fbshipit-source-id: 4a1741a7e47619fc0591b6cbacfc13816d990936
  • Loading branch information
xw285cornell authored and facebook-github-bot committed Apr 11, 2023
1 parent a2e0f51 commit fae051a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions torch/_inductor/ir.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,13 @@


def validate_ir(node_or_nodes):
def _check_tensorbox(node):
def _check_tensorbox(node_or_nodes):
# Could expand this to check deeper properties
# (e.g. TensorBox points to View or StorageBox)
if isinstance(node_or_nodes, (List, Tuple)):
for node in node_or_nodes:
_check_tensorbox(node)

assert isinstance(
node,
(
Expand All @@ -103,11 +107,7 @@ def _check_tensorbox(node):
), f"Found {type(node)}, which is not a supported top level IR node. See [Note: Inductor IR]"

# Be picky about the accepted data structure (don't use pytree here)
if isinstance(node_or_nodes, (List, Tuple)):
for node in node_or_nodes:
_check_tensorbox(node)
else:
_check_tensorbox(node_or_nodes)
_check_tensorbox(node_or_nodes)


def inverse_reorder(order):
Expand Down

0 comments on commit fae051a

Please sign in to comment.