From: Bram Wasti Date: Fri, 21 Dec 2018 22:11:26 +0000 (-0800) Subject: Relax check on outputs (#15458) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~2114 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=235d47760b2dc9e899f488a7d87348adfd9742c6;p=platform%2Fupstream%2Fpytorch.git Relax check on outputs (#15458) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/15458 many nets in the wild seem to have outputs that are never produced by the net. Reviewed By: ZolotukhinM Differential Revision: D13534185 fbshipit-source-id: 2b23b39c28404c53f68868f3bf6df53c5fea9eab --- diff --git a/caffe2/opt/converter.cc b/caffe2/opt/converter.cc index 4d701ed..2f9c8fb 100644 --- a/caffe2/opt/converter.cc +++ b/caffe2/opt/converter.cc @@ -384,10 +384,13 @@ repr::NNModule convertToNNModule( for (const auto& outputName : net.external_output()) { CAFFE_ENFORCE( - blobMap.count(outputName), - "NetDef has ill-formed external_output: \"", - outputName, - "\""); + !strict || blobMap.count(outputName), + "NetDef has ill-formed external_output:", + outputName); + if (!blobMap.count(outputName)) { + LOG(ERROR) << "NetDef has ill-formed external_output: " << outputName; + continue; + } module.outputs.insert(blobMap[outputName]); } diff --git a/caffe2/python/transformations_test.py b/caffe2/python/transformations_test.py index 502c844..567b31e 100644 --- a/caffe2/python/transformations_test.py +++ b/caffe2/python/transformations_test.py @@ -328,16 +328,15 @@ class TestTransformations(tu.TestCase): atol=1e-04 ) - def test_converterEnforceUnusedInputs(self): + def test_converterDontEnforceUnusedInputs(self): net = core.Net("net") net.Relu(["X"], ["Y"]) net.Proto().external_input.extend(["fake"]) # This should now work transformer.AddNNPACK(net) # just testing the converter - def test_converterEnforceUnusedOutputs(self): + def test_converterDontEnforceUnusedOutputs(self): net = core.Net("net") net.Relu(["X"], ["Y"]) net.Proto().external_output.extend(["fake"]) - with self.assertRaises(Exception): - transformer.AddNNPACK(net) # just testing the converter + transformer.AddNNPACK(net) # just testing the converter