Enable to pass ValidationTestModel.AddOperation in pureacl (#2451)
author남궁석/동작제어Lab(SR)/Engineer/삼성전자 <sk.namkoong@samsung.com>
Fri, 24 Aug 2018 02:28:46 +0000 (11:28 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 24 Aug 2018 02:28:46 +0000 (11:28 +0900)
In `ValidationTestModel.AddOperation`, if inputs or outputs are `nullptr`, it is always error even if `inputCount` and `outputCount` is zero.
This commit will modify those conditions, and add some checkings to pass the test.

 - Modify `nullptr` check condition
 - Add checking if building model is finished or not
 - Add checking if type is invalid or not

Signed-off-by: Seok NamKoong <sk.namkoong@samsung.com>
runtimes/pure_arm_compute/src/model.cc

index d93b4ca..7a96038 100644 (file)
@@ -104,12 +104,21 @@ int ANeuralNetworksModel_addOperation(ANeuralNetworksModel *model,
                                       const uint32_t *inputs, uint32_t outputCount,
                                       const uint32_t *outputs)
 {
-  if ((model == nullptr) || ((inputs == nullptr) && (inputCount != 0)) ||
-      ((outputs == nullptr) && (outputCount != 0)))
+  if (model == nullptr || inputs == nullptr || outputs == nullptr)
   {
     return ANEURALNETWORKS_UNEXPECTED_NULL;
   }
 
+  if (model->isFinished())
+  {
+    return ANEURALNETWORKS_BAD_STATE;
+  }
+
+  if (type < ANEURALNETWORKS_ADD || type > ANEURALNETWORKS_TRANSPOSE)
+  {
+    return ANEURALNETWORKS_BAD_DATA;
+  }
+
   switch (type)
   {
     case ANEURALNETWORKS_ADD: