Verify IslandOp body has no block arguments

Also, removed explicit check on empty body which is already verified by trait
SingleBlockImplicitTerminator.

PiperOrigin-RevId: 322222883
Change-Id: Id9344905328a5680a02b8c95fe2805e230780e77
This commit is contained in:
Smit Hinsu 2020-07-20 14:15:14 -07:00 committed by TensorFlower Gardener
parent 365edbfd59
commit b7fb764f9f
2 changed files with 16 additions and 2 deletions

View File

@ -301,8 +301,8 @@ bool IslandOp::WrapsSingleOp() {
namespace {
LogicalResult Verify(IslandOp island) {
if (island.GetBody().empty())
return island.emitOpError() << "expects a non-empty body";
if (!island.GetBody().args_empty())
return island.emitOpError() << "expects body without any arguments";
Operation &yield = island.GetBody().back();
if (!isa<YieldOp>(yield))

View File

@ -232,6 +232,20 @@ func @invalid_island(%arg0: tensor<*xf32>, %ctl: !tf_executor.control) {
// -----
// Check that an island body doesn't have any block arguments.
func @invalid_island(%arg0: tensor<*xf32>, %ctl: !tf_executor.control) {
tf_executor.graph {
"tf_executor.island"() ({
// expected-error@-1 {{expects body without any arguments}}
^entry(%arg: tensor<2xi32>):
tf_executor.yield
}) : () -> (!tf_executor.control)
}
return
}
// -----
// Check that an island body can't be empty.
func @invalid_island(%arg0: tensor<*xf32>, %ctl: !tf_executor.control) {
tf_executor.graph {