Remove nested resource access verify

The verification was on all functions in the module. But other functions in module may still use resource variables and only those called from main func is of interest, seeing as ResourceLiftingForFunctionControlFlow would fail if it weren't able to hoist called functions from there, we can retire the verify function.

PiperOrigin-RevId: 306279514
Change-Id: I3cd62268fe99cfcffb33d2cacb5bdaad251c763b
This commit is contained in:
Jacques Pienaar 2020-04-13 11:59:41 -07:00 committed by TensorFlower Gardener
parent 519326041d
commit 31fa451df4
2 changed files with 0 additions and 29 deletions

View File

@ -251,19 +251,6 @@ func @main() {
// -----
// Tests non main function with resource arguments.
func @main() {
return
}
// expected-error@+1 {{potential nested resource accesses in function}}
func @other(%arg0: tensor<!tf.resource<tensor<f32>>>) {
return
}
// -----
// Tests main function with invalid resource argument subtype.
// expected-error@+1 {{expects resource type of argument 0 to have one subtype, got '!tf.resource'}}

View File

@ -70,21 +70,6 @@ struct ResourceInfo {
using ArgOrName = llvm::PointerUnion<BlockArgument, Attribute>;
using ResourceMap = llvm::SmallDenseMap<ArgOrName, ResourceInfo>;
LogicalResult VerifyNoPotentialNestedResourceAccesses(ModuleOp module) {
auto result = module.walk([&](FuncOp func) -> WalkResult {
// Skip main function as resources can be passed in as arguments.
if (func.getName() == "main") return WalkResult::advance();
for (auto type : func.getType().getInputs())
if (getElementTypeOrSelf(type).isa<TF::ResourceType>())
return func.emitError("potential nested resource accesses in function");
return WalkResult::advance();
});
return failure(result.wasInterrupted());
}
LogicalResult PromoteResourcesToArguments(FuncOp function) {
Block& block = function.front();
@ -278,7 +263,6 @@ void PromoteResourcesToArgsPass::runOnOperation() {
}
if (failed(ResourceLiftingForFunctionalControlFlow(main_func)) ||
failed(VerifyNoPotentialNestedResourceAccesses(module)) ||
failed(PromoteResourcesToArguments(main_func)))
return signalPassFailure();
}