Implement Event_wait Event_free
authorsjsujinkim <sjsujin.kim@samsung.com>
Thu, 29 Mar 2018 04:53:44 +0000 (13:53 +0900)
committer최형규/동작제어Lab(SR)/Senior Engineer/삼성전자 <hk0110.choi@samsung.com>
Thu, 29 Mar 2018 05:13:38 +0000 (14:13 +0900)
This commit implements Event_wait, Event_free and enables android::sp in NeuralNetworks.cpp.

Signed-off-by: sjsujinkim <sjsujin.kim@samsung.com>
src/runtime/ref/nn/runtime/ExecutionBuilder.h
src/runtime/ref/nn/runtime/NeuralNetworks.cpp

index f3fa138..08299b8 100644 (file)
@@ -17,9 +17,7 @@
 #ifndef ANDROID_ML_NN_RUNTIME_EXECUTION_BUILDER_H
 #define ANDROID_ML_NN_RUNTIME_EXECUTION_BUILDER_H
 
-#if 0 // REF-ANN
 #include "Callbacks.h"
-#endif
 #include "HalInterfaces.h"
 #include "Memory.h"
 #include "ModelBuilder.h"
@@ -31,9 +29,9 @@
 #include <vector>
 
 #if 0 // REF-ANN
-using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
 using ::android::hardware::neuralnetworks::V1_0::implementation::PreparedModelCallback;
 #endif
+using ::android::hardware::neuralnetworks::V1_0::implementation::ExecutionCallback;
 
 namespace android {
 namespace nn {
index bbf6a2e..5cad954 100644 (file)
@@ -19,7 +19,7 @@
 // that implements the functionality.
 
 #include "NeuralNetworks.h"
-
+#include "Callbacks.h"
 #include "CompilationBuilder.h"
 #include "ExecutionBuilder.h"
 #include "ModelBuilder.h"
@@ -220,8 +220,8 @@ static_assert(static_cast<int32_t>(FusedActivationFunc::RELU1) == ANEURALNETWORK
 static_assert(static_cast<int32_t>(FusedActivationFunc::RELU6) == ANEURALNETWORKS_FUSED_RELU6,
               "FusedActivationFunc::RELU6 != ANEURALNETWORKS_FUSED_RELU6");
 
-using android::sp;
 #endif
+using android::sp;
 using namespace android::nn;
 
 int ANeuralNetworksMemory_createFromFd(size_t size, int prot, int fd, size_t offset,
@@ -503,11 +503,6 @@ int ANeuralNetworksExecution_startCompute(ANeuralNetworksExecution* execution,
 }
 
 int ANeuralNetworksEvent_wait(ANeuralNetworksEvent* event) {
-    // Dummy Implementation
-    return ANEURALNETWORKS_NO_ERROR;
-
-    // Original code for reference
-#if 0
     if (event == nullptr) {
         LOG(ERROR) << "ANeuralNetworksEvent_wait passed a nullptr";
         return ANEURALNETWORKS_UNEXPECTED_NULL;
@@ -516,17 +511,13 @@ int ANeuralNetworksEvent_wait(ANeuralNetworksEvent* event) {
     sp<ExecutionCallback>* e = reinterpret_cast<sp<ExecutionCallback>*>(event);
     (*e)->wait();
     return ANEURALNETWORKS_NO_ERROR;
-#endif
 }
 
 void ANeuralNetworksEvent_free(ANeuralNetworksEvent* event) {
-    // Original code for reference
-#if 0
     // No validation.  Free of nullptr is valid.
     if (event) {
         sp<ExecutionCallback>* e = reinterpret_cast<sp<ExecutionCallback>*>(event);
         (*e)->wait();
         delete e;
     }
-#endif
 }