From 35c12774241f4d2b6fea0bcc7288dda973045709 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EB=B0=95=EC=A2=85=ED=98=84/=EB=8F=99=EC=9E=91=EC=A0=9C?= =?utf8?q?=EC=96=B4Lab=28SR=29/Staff=20Engineer/=EC=82=BC=EC=84=B1?= =?utf8?q?=EC=A0=84=EC=9E=90?= Date: Fri, 16 Nov 2018 08:07:52 +0900 Subject: [PATCH] [enco] Set subnet output correctly on branching (#2309) The current implementation specifies a bag as a subnet output if the subnet accesses it and this bag is accessed outside of this subnet. It turns out that this algorithm may specify a network input as a subnet output as it does not consider this bag is updated by this subnet. This commit fixes this bug and adds a related test. Signed-off-by: Jonghyun Park --- contrib/enco/core/src/Transforms/Split.cpp | 9 +++ contrib/enco/test/tflite/Regression_0000/INFERENCE | 0 .../enco/test/tflite/Regression_0000/test.recipe | 84 ++++++++++++++++++++++ 3 files changed, 93 insertions(+) create mode 100644 contrib/enco/test/tflite/Regression_0000/INFERENCE create mode 100644 contrib/enco/test/tflite/Regression_0000/test.recipe diff --git a/contrib/enco/core/src/Transforms/Split.cpp b/contrib/enco/core/src/Transforms/Split.cpp index 86881fa..677506d 100644 --- a/contrib/enco/core/src/Transforms/Split.cpp +++ b/contrib/enco/core/src/Transforms/Split.cpp @@ -922,10 +922,19 @@ std::set ANNModuleBuilder::outputs(ANNBinder *binder) const for (auto bag : binder->bags()) { + auto u = enco::updaters(bag); auto r = enco::readers(bag); r.erase(binder->block()); /** + * Only a bag that this block updates can be the output of this block + */ + if (u.find(binder->block()) == u.end()) + { + continue; + } + + /** * A bag is the output of this block if * 1. it is an output of the whole network, or * 2. it is read by following blocks during execution diff --git a/contrib/enco/test/tflite/Regression_0000/INFERENCE b/contrib/enco/test/tflite/Regression_0000/INFERENCE new file mode 100644 index 0000000..e69de29 diff --git a/contrib/enco/test/tflite/Regression_0000/test.recipe b/contrib/enco/test/tflite/Regression_0000/test.recipe new file mode 100644 index 0000000..c0b2dbe --- /dev/null +++ b/contrib/enco/test/tflite/Regression_0000/test.recipe @@ -0,0 +1,84 @@ +operand { + name: "ifm" + type: FLOAT32 + shape { dim: 1 dim: 8 dim: 8 dim: 2 } +} +operand { + name: "ker_0" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias_0" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "0.1" + } +} +operand { + name: "ofm_0" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + activation: NONE + } + input: "ifm" + input: "ker_0" + input: "bias_0" + output: "ofm_0" +} +operand { + name: "ker_1" + type: FLOAT32 + shape { dim: 1 dim: 1 dim: 1 dim: 2 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "1.0" + } +} +operand { + name: "bias_1" + type: FLOAT32 + shape { dim: 1 } + filler { + tag: "gaussian" + arg: "0.0" + arg: "0.1" + } +} +operand { + name: "ofm_1" + type: FLOAT32 + shape { dim: 1 dim: 7 dim: 7 dim: 1 } +} +operation { + type: "Conv2D" + conv2d_options { + padding: VALID + stride_w: 1 + stride_h: 1 + activation: NONE + } + input: "ifm" + input: "ker_1" + input: "bias_1" + output: "ofm_1" +} +input: "ifm" +output: "ofm_0" +output: "ofm_1" -- 2.7.4