summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2017-09-01 13:03:18 -0700
committerYang Ni <yangni@google.com>2017-09-06 10:04:42 -0700
commit0831219b2763e7906d0f42bd15351a8e05c6f0ab (patch)
tree8715b8a0b826455de907b2b5e013469388f45adb
parente9274aa2ade933ecebf7e8d41ef0b49ff3253bbd (diff)
downloadml-0831219b2763e7906d0f42bd15351a8e05c6f0ab.tar.gz
Move operation files into subdirectory
Bug: 63905942 The convention seems to have all CPU implmentation of OPs in the subdirectory nn/common/operations. This CL moves recently added speech/text related OPs to that directory. Test: unit tests of all moved ops on marlin Change-Id: I026aa94c58f6ee4e57e519781ee92d5792106de6
-rw-r--r--nn/common/Android.bp46
-rw-r--r--nn/common/CpuExecutor.cpp6
-rw-r--r--nn/common/include/ActivationFunctor.h63
-rw-r--r--nn/common/include/Operations.h47
-rw-r--r--nn/common/operations/EmbeddingLookup.cpp (renamed from nn/common/EmbeddingLookup.cpp)0
-rw-r--r--nn/common/operations/EmbeddingLookup.h (renamed from nn/common/EmbeddingLookup.h)0
-rw-r--r--nn/common/operations/EmbeddingLookupTest.cpp (renamed from nn/common/EmbeddingLookupTest.cpp)0
-rw-r--r--nn/common/operations/HashtableLookup.cpp (renamed from nn/common/HashtableLookup.cpp)0
-rw-r--r--nn/common/operations/HashtableLookup.h (renamed from nn/common/HashtableLookup.h)0
-rw-r--r--nn/common/operations/HashtableLookupTest.cpp (renamed from nn/common/HashtableLookupTest.cpp)0
-rw-r--r--nn/common/operations/LSHProjection.cpp (renamed from nn/common/LSHProjection.cpp)0
-rw-r--r--nn/common/operations/LSHProjection.h (renamed from nn/common/LSHProjection.h)0
-rw-r--r--nn/common/operations/LSHProjectionTest.cpp (renamed from nn/common/LSHProjectionTest.cpp)0
-rw-r--r--nn/common/operations/LSTM.cpp (renamed from nn/common/LSTM.cpp)0
-rw-r--r--nn/common/operations/LSTM.h (renamed from nn/common/LSTM.h)2
-rw-r--r--nn/common/operations/LSTMTest.cpp (renamed from nn/common/LSTMTest.cpp)0
-rw-r--r--nn/common/operations/RNN.cpp (renamed from nn/common/RNN.cpp)0
-rw-r--r--nn/common/operations/RNN.h (renamed from nn/common/RNN.h)2
-rw-r--r--nn/common/operations/RNNTest.cpp (renamed from nn/common/RNNTest.cpp)0
-rw-r--r--nn/common/operations/SVDF.cpp (renamed from nn/common/SVDF.cpp)0
-rw-r--r--nn/common/operations/SVDF.h (renamed from nn/common/SVDF.h)2
-rw-r--r--nn/common/operations/SVDFTest.cpp (renamed from nn/common/SVDFTest.cpp)0
22 files changed, 91 insertions, 77 deletions
diff --git a/nn/common/Android.bp b/nn/common/Android.bp
index 74e42076d..15ab87588 100644
--- a/nn/common/Android.bp
+++ b/nn/common/Android.bp
@@ -29,23 +29,23 @@ cc_library_static {
srcs: [
"CpuExecutor.cpp",
- "EmbeddingLookup.cpp",
- "HashtableLookup.cpp",
- "LSHProjection.cpp",
- "LSTM.cpp",
"OperationsUtils.cpp",
- "RNN.cpp",
- "SVDF.cpp",
"Utils.cpp",
"operations/Activation.cpp",
"operations/Concatenation.cpp",
"operations/Conv2D.cpp",
"operations/DepthwiseConv2D.cpp",
+ "operations/EmbeddingLookup.cpp",
"operations/FullyConnected.cpp",
+ "operations/HashtableLookup.cpp",
+ "operations/LSHProjection.cpp",
+ "operations/LSTM.cpp",
"operations/Normalization.cpp",
"operations/Pooling.cpp",
"operations/Reshape.cpp",
+ "operations/RNN.cpp",
"operations/SimpleMath.cpp",
+ "operations/SVDF.cpp",
],
shared_libs: [
"libbase",
@@ -81,89 +81,81 @@ cc_library_static {
cc_test {
name: "embedding_lookup_test",
srcs: [
- "EmbeddingLookupTest.cpp",
+ "operations/EmbeddingLookupTest.cpp",
],
shared_libs: [
- "liblog",
"libneuralnetworks",
],
static_libs: [
"libgmock",
- "libneuralnetworks_common",
],
}
cc_test {
name: "hashtable_lookup_test",
srcs: [
- "HashtableLookupTest.cpp",
+ "operations/HashtableLookupTest.cpp",
],
shared_libs: [
- "liblog",
"libneuralnetworks",
],
static_libs: [
"libgmock",
- "libneuralnetworks_common",
],
}
cc_test {
name: "lsh_projection_test",
srcs: [
- "LSHProjectionTest.cpp",
+ "operations/LSHProjectionTest.cpp",
],
+ local_include_dirs: [ "include" ],
shared_libs: [
"libneuralnetworks",
],
static_libs: [
"libgmock",
- "libneuralnetworks_common",
],
}
cc_test {
name: "lstm_test",
srcs: [
- "LSTMTest.cpp",
+ "operations/LSTMTest.cpp",
],
+ local_include_dirs: [ "include" ],
shared_libs: [
- "liblog",
"libneuralnetworks",
],
static_libs: [
"libgmock",
- "libneuralnetworks_common",
],
}
cc_test {
name: "rnn_test",
srcs: [
- "RNNTest.cpp",
- ],
- static_libs: [
- "libgmock",
- "libneuralnetworks_common",
- ],
- header_libs: [
- "libneuralnetworks_headers",
+ "operations/RNNTest.cpp",
],
+ local_include_dirs: [ "include" ],
shared_libs: [
"libneuralnetworks",
],
+ static_libs: [
+ "libgmock",
+ ],
}
cc_test {
name: "svdf_test",
srcs: [
- "SVDFTest.cpp",
+ "operations/SVDFTest.cpp",
],
+ local_include_dirs: [ "include" ],
shared_libs: [
"libneuralnetworks",
],
static_libs: [
"libgmock",
- "libneuralnetworks_common",
],
}
diff --git a/nn/common/CpuExecutor.cpp b/nn/common/CpuExecutor.cpp
index 7bf84aa8e..2935ff77e 100644
--- a/nn/common/CpuExecutor.cpp
+++ b/nn/common/CpuExecutor.cpp
@@ -18,14 +18,8 @@
#include "CpuExecutor.h"
-#include "EmbeddingLookup.h"
-#include "HashtableLookup.h"
-#include "LSHProjection.h"
-#include "LSTM.h"
#include "NeuralNetworks.h"
#include "Operations.h"
-#include "RNN.h"
-#include "SVDF.h"
namespace android {
namespace nn {
diff --git a/nn/common/include/ActivationFunctor.h b/nn/common/include/ActivationFunctor.h
new file mode 100644
index 000000000..fb966c451
--- /dev/null
+++ b/nn/common/include/ActivationFunctor.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_ML_NN_ACTIVATION_FUNCTOR_H
+#define ANDROID_ML_NN_ACTIVATION_FUNCTOR_H
+
+#include "android/log.h"
+
+#include <algorithm>
+#include <cmath>
+
+enum ActivationFn {
+ kActivationNone = 0,
+ kActivationRelu,
+ kActivationRelu1,
+ kActivationRelu6,
+ kActivationTanh,
+ kActivationSignBit,
+ kActivationSigmoid,
+};
+
+class ActivationFunctor {
+ public:
+ explicit ActivationFunctor(ActivationFn act) : act_(act) {}
+
+ float operator()(float a) const {
+ switch (act_) {
+ case kActivationNone:
+ return a;
+ case kActivationRelu:
+ return a < 0.f ? 0.f : a;
+ case kActivationRelu6:
+ return std::max(0.f, std::min(a, 6.f));
+ case kActivationTanh:
+ return std::tanh(a);
+ case kActivationSigmoid:
+ return 1.0f / (1.0f + std::exp(-a));
+ default:
+ __android_log_print(ANDROID_LOG_ERROR, "NN API",
+ "Invalid enum value for activation function: 0x%0X",
+ act_);
+ exit(1);
+ }
+ }
+
+ private:
+ ActivationFn act_;
+};
+
+#endif // ANDROID_ML_NN_ACTIVATION_FUNCTOR_H
diff --git a/nn/common/include/Operations.h b/nn/common/include/Operations.h
index ecb8fb46e..7b5b54724 100644
--- a/nn/common/include/Operations.h
+++ b/nn/common/include/Operations.h
@@ -17,12 +17,15 @@
#ifndef ANDROID_ML_NN_COMMON_OPERATIONS_H
#define ANDROID_ML_NN_COMMON_OPERATIONS_H
-#include "android/log.h"
+#include "operations/EmbeddingLookup.h"
+#include "operations/HashtableLookup.h"
+#include "operations/LSHProjection.h"
+#include "operations/LSTM.h"
+#include "operations/RNN.h"
+#include "operations/SVDF.h"
#include <stddef.h>
-#include <algorithm>
-#include <cmath>
#include <cstdint>
#include <vector>
@@ -37,44 +40,6 @@ enum PaddingScheme {
kPaddingValid = 2,
};
-enum ActivationFn {
- kActivationNone = 0,
- kActivationRelu,
- kActivationRelu1,
- kActivationRelu6,
- kActivationTanh,
- kActivationSignBit,
- kActivationSigmoid,
-};
-
-class ActivationFunctor {
- public:
- explicit ActivationFunctor(ActivationFn act) : act_(act) {}
-
- float operator()(float a) const {
- switch (act_) {
- case kActivationNone:
- return a;
- case kActivationRelu:
- return a < 0.f ? 0.f : a;
- case kActivationRelu6:
- return std::max(0.f, std::min(a, 6.f));
- case kActivationTanh:
- return std::tanh(a);
- case kActivationSigmoid:
- return 1.0f / (1.0f + std::exp(-a));
- default:
- __android_log_print(ANDROID_LOG_ERROR, "NN API",
- "Invalid enum value for activation function: 0x%0X",
- act_);
- exit(1);
- }
- }
-
- private:
- ActivationFn act_;
-};
-
bool addMulPrepare(const Shape& in1, const Shape& in2, Shape* out1);
bool addFloat32(const float* in1, const Shape& shape1,
const float* in2, const Shape& shape2,
diff --git a/nn/common/EmbeddingLookup.cpp b/nn/common/operations/EmbeddingLookup.cpp
index 4f926a62d..4f926a62d 100644
--- a/nn/common/EmbeddingLookup.cpp
+++ b/nn/common/operations/EmbeddingLookup.cpp
diff --git a/nn/common/EmbeddingLookup.h b/nn/common/operations/EmbeddingLookup.h
index d9a71a279..d9a71a279 100644
--- a/nn/common/EmbeddingLookup.h
+++ b/nn/common/operations/EmbeddingLookup.h
diff --git a/nn/common/EmbeddingLookupTest.cpp b/nn/common/operations/EmbeddingLookupTest.cpp
index 9eafbe483..9eafbe483 100644
--- a/nn/common/EmbeddingLookupTest.cpp
+++ b/nn/common/operations/EmbeddingLookupTest.cpp
diff --git a/nn/common/HashtableLookup.cpp b/nn/common/operations/HashtableLookup.cpp
index 299547fa9..299547fa9 100644
--- a/nn/common/HashtableLookup.cpp
+++ b/nn/common/operations/HashtableLookup.cpp
diff --git a/nn/common/HashtableLookup.h b/nn/common/operations/HashtableLookup.h
index 13cbdf56d..13cbdf56d 100644
--- a/nn/common/HashtableLookup.h
+++ b/nn/common/operations/HashtableLookup.h
diff --git a/nn/common/HashtableLookupTest.cpp b/nn/common/operations/HashtableLookupTest.cpp
index 6f9ce2bbd..6f9ce2bbd 100644
--- a/nn/common/HashtableLookupTest.cpp
+++ b/nn/common/operations/HashtableLookupTest.cpp
diff --git a/nn/common/LSHProjection.cpp b/nn/common/operations/LSHProjection.cpp
index f6cb317fb..f6cb317fb 100644
--- a/nn/common/LSHProjection.cpp
+++ b/nn/common/operations/LSHProjection.cpp
diff --git a/nn/common/LSHProjection.h b/nn/common/operations/LSHProjection.h
index f4e8e9028..f4e8e9028 100644
--- a/nn/common/LSHProjection.h
+++ b/nn/common/operations/LSHProjection.h
diff --git a/nn/common/LSHProjectionTest.cpp b/nn/common/operations/LSHProjectionTest.cpp
index 3b6e3cf76..3b6e3cf76 100644
--- a/nn/common/LSHProjectionTest.cpp
+++ b/nn/common/operations/LSHProjectionTest.cpp
diff --git a/nn/common/LSTM.cpp b/nn/common/operations/LSTM.cpp
index e04f0737a..e04f0737a 100644
--- a/nn/common/LSTM.cpp
+++ b/nn/common/operations/LSTM.cpp
diff --git a/nn/common/LSTM.h b/nn/common/operations/LSTM.h
index 20bcc0853..be6f20678 100644
--- a/nn/common/LSTM.h
+++ b/nn/common/operations/LSTM.h
@@ -17,7 +17,7 @@
#ifndef FRAMEWORKS_ML_NN_LSTMCELL_H
#define FRAMEWORKS_ML_NN_LSTMCELL_H
-#include "Operations.h"
+#include "ActivationFunctor.h"
#include <algorithm>
#include <cmath>
diff --git a/nn/common/LSTMTest.cpp b/nn/common/operations/LSTMTest.cpp
index 7dd3e0c91..7dd3e0c91 100644
--- a/nn/common/LSTMTest.cpp
+++ b/nn/common/operations/LSTMTest.cpp
diff --git a/nn/common/RNN.cpp b/nn/common/operations/RNN.cpp
index 0526eea8e..0526eea8e 100644
--- a/nn/common/RNN.cpp
+++ b/nn/common/operations/RNN.cpp
diff --git a/nn/common/RNN.h b/nn/common/operations/RNN.h
index 7f59bf2e0..9e92c37f0 100644
--- a/nn/common/RNN.h
+++ b/nn/common/operations/RNN.h
@@ -17,7 +17,7 @@
#ifndef FRAMEWORKS_ML_NN_RNN_H
#define FRAMEWORKS_ML_NN_RNN_H
-#include "Operations.h"
+#include "ActivationFunctor.h"
namespace android {
namespace hardware {
diff --git a/nn/common/RNNTest.cpp b/nn/common/operations/RNNTest.cpp
index bb3fdddd5..bb3fdddd5 100644
--- a/nn/common/RNNTest.cpp
+++ b/nn/common/operations/RNNTest.cpp
diff --git a/nn/common/SVDF.cpp b/nn/common/operations/SVDF.cpp
index 7e7f8f2b7..7e7f8f2b7 100644
--- a/nn/common/SVDF.cpp
+++ b/nn/common/operations/SVDF.cpp
diff --git a/nn/common/SVDF.h b/nn/common/operations/SVDF.h
index aa8f4b2f9..8d2c045ed 100644
--- a/nn/common/SVDF.h
+++ b/nn/common/operations/SVDF.h
@@ -17,7 +17,7 @@
#ifndef FRAMEWORKS_ML_NN_SVDF_H
#define FRAMEWORKS_ML_NN_SVDF_H
-#include "Operations.h"
+#include "ActivationFunctor.h"
#include <algorithm>
#include <cmath>
diff --git a/nn/common/SVDFTest.cpp b/nn/common/operations/SVDFTest.cpp
index 361fb8bfc..361fb8bfc 100644
--- a/nn/common/SVDFTest.cpp
+++ b/nn/common/operations/SVDFTest.cpp