Skip to content

PR #129186: Validate that LoopCond nodes are inside a while loop frame - #129461

Draft
copybara-service[bot] wants to merge 1 commit into
masterfrom
exported_pr_1005356514
Draft

copybara-service[bot] wants to merge 1 commit into
masterfrom
exported_pr_1005356514

Conversation

@copybara-service

Copy link
Copy Markdown

PR #129186: Validate that LoopCond nodes are inside a while loop frame

Imported from GitHub PR #129186

Calling tf.raw_ops.LoopCond(input=True) outside of a while loop frame aborts in debug builds (--config=dbg) with:

F tensorflow/core/graph/graph_partition.cc:649] Check failed: !frame_name.empty()
Aborted (core dumped)

Cause

A LoopCond op placed directly in the graph outside of an Enter op has an empty frame_name (""). In AddControlFlow (tensorflow/core/graph/graph_partition.cc), debug builds assert DCHECK(!frame_name.empty()) when populating frame_cond_map.

Solution

  • Replaced DCHECK(!frame_name.empty()) in AddControlFlow (tensorflow/core/graph/graph_partition.cc) with an explicit InvalidArgumentError return.
  • Added unit tests in tensorflow/core/graph/graph_partition_test.cc and tensorflow/python/kernel_tests/control_flow/control_flow_ops_py_test.py.

Fixes #62982.
Copybara import of the project:

--
13bd94f by bodapatisaikrishna [email protected]:

Validate that LoopCond nodes are inside a while loop frame

--
67e499f by bodapatisaikrishna [email protected]:

Validate LoopCond frame in AddControlFlow and drop ValidateControlFlowInfo check

Revert the empty frame check in ValidateControlFlowInfo to preserve
incomplete graph handling in XLA compilation passes, keep the validation
in AddControlFlow, and add a C++ partition regression test along with
pinned Python test assertions under deprecated v1.

--
1a2b45d by bodapatisaikrishna [email protected]:

Add direct status and str_cat includes to graph_partition.cc

Include absl/status/status.h and absl/strings/str_cat.h directly for
absl::InvalidArgumentError and absl::StrCat.

Merging this change closes #129186

Reverts 7f20bc9

FUTURE_COPYBARA_INTEGRATE_REVIEW=#129186 from bodapatisaikrishna:fix/62982-loopcond-empty-frame 1a2b45d

Imported from GitHub PR #129186

Calling `tf.raw_ops.LoopCond(input=True)` outside of a while loop frame aborts in debug builds (`--config=dbg`) with:

```
F tensorflow/core/graph/graph_partition.cc:649] Check failed: !frame_name.empty()
Aborted (core dumped)
```

### Cause
A `LoopCond` op placed directly in the graph outside of an `Enter` op has an empty `frame_name` (`""`). In `AddControlFlow` (`tensorflow/core/graph/graph_partition.cc`), debug builds assert `DCHECK(!frame_name.empty())` when populating `frame_cond_map`.

### Solution
- Replaced `DCHECK(!frame_name.empty())` in `AddControlFlow` (`tensorflow/core/graph/graph_partition.cc`) with an explicit `InvalidArgumentError` return.
- Added unit tests in `tensorflow/core/graph/graph_partition_test.cc` and `tensorflow/python/kernel_tests/control_flow/control_flow_ops_py_test.py`.

Fixes #62982.
Copybara import of the project:

--
13bd94f by bodapatisaikrishna <[email protected]>:

Validate that LoopCond nodes are inside a while loop frame

--
67e499f by bodapatisaikrishna <[email protected]>:

Validate LoopCond frame in AddControlFlow and drop ValidateControlFlowInfo check

Revert the empty frame check in ValidateControlFlowInfo to preserve
incomplete graph handling in XLA compilation passes, keep the validation
in AddControlFlow, and add a C++ partition regression test along with
pinned Python test assertions under deprecated v1.

--
1a2b45d by bodapatisaikrishna <[email protected]>:

Add direct status and str_cat includes to graph_partition.cc

Include absl/status/status.h and absl/strings/str_cat.h directly for
absl::InvalidArgumentError and absl::StrCat.

Merging this change closes #129186

Reverts 7f20bc9

FUTURE_COPYBARA_INTEGRATE_REVIEW=#129186 from bodapatisaikrishna:fix/62982-loopcond-empty-frame 1a2b45d
PiperOrigin-RevId: 1005356514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tf.raw_ops.LoopCond aborts in Debug build

1 participant