Implement Compiilation_setPreference
authorHanjoung Lee <hanjoung.lee@samsung.com>
Thu, 22 Mar 2018 10:17:29 +0000 (19:17 +0900)
committer최형규/동작제어Lab(SR)/Senior Engineer/삼성전자 <hk0110.choi@samsung.com>
Thu, 22 Mar 2018 10:34:54 +0000 (19:34 +0900)
Basically the same as android NN implementation.
One global constant defined from Utils.h but it is temporarily defined by
the method until we import that file.

src/runtime/ref/nn/runtime/CompilationBuilder.cpp
src/runtime/ref/nn/runtime/NeuralNetworks.cpp

index 9d78a3f..76f1e35 100644 (file)
@@ -17,6 +17,7 @@
 #define LOG_TAG "CompilationBuilder"
 
 #include "CompilationBuilder.h"
+#include "Log.h"
 
 // TODO Include these files once availible
 #if 0
@@ -64,11 +65,9 @@ int CompilationBuilder::finish() {
 }
 
 int CompilationBuilder::setPreference(int32_t preference) {
-    // Dummy Implementation
-    return ANEURALNETWORKS_NO_ERROR;
+    // TODO-NNRT Import common/Utils.h and remove this definition
+    static const int kNumberOfPreferences = 3;
 
-    // Original code for reference
-#if 0
     if (mFinished) {
         LOG(ERROR) <<
                 "ANeuralNetworksCompilation_setPreference can't modify after compilation finished";
@@ -81,7 +80,6 @@ int CompilationBuilder::setPreference(int32_t preference) {
 
     mPreference = preference;
     return ANEURALNETWORKS_NO_ERROR;
-#endif
 }
 
 int CompilationBuilder::createExecution(ExecutionBuilder **execution) {
index 8dc0cc8..12b2490 100644 (file)
@@ -400,18 +400,12 @@ void ANeuralNetworksCompilation_free(ANeuralNetworksCompilation* compilation) {
 
 int ANeuralNetworksCompilation_setPreference(ANeuralNetworksCompilation* compilation,
                                              int32_t preference) {
-    // Dummy Implementation
-    return ANEURALNETWORKS_NO_ERROR;
-
-    // Original code for reference
-#if 0
     if (!compilation) {
         LOG(ERROR) << "ANeuralNetworksCompilation_setPreference passed a nullptr";
         return ANEURALNETWORKS_UNEXPECTED_NULL;
     }
     CompilationBuilder* c = reinterpret_cast<CompilationBuilder*>(compilation);
     return c->setPreference(preference);
-#endif
 }
 
 int ANeuralNetworksCompilation_finish(ANeuralNetworksCompilation* compilation) {