summaryrefslogtreecommitdiff
path: root/libs/kernel/acl/src/neon/Softmax.test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libs/kernel/acl/src/neon/Softmax.test.cpp')
-rw-r--r--libs/kernel/acl/src/neon/Softmax.test.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/libs/kernel/acl/src/neon/Softmax.test.cpp b/libs/kernel/acl/src/neon/Softmax.test.cpp
new file mode 100644
index 000000000..988f55078
--- /dev/null
+++ b/libs/kernel/acl/src/neon/Softmax.test.cpp
@@ -0,0 +1,105 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * 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.
+ */
+
+#include <gtest/gtest.h>
+#include <OperationsUtils.h>
+#include <kernel/acl/nnfw_kernel_acl.h>
+#include <arm_compute/core/Types.h>
+#include <kernel/acl/Softmax.h>
+
+#include "../util.h"
+
+using namespace nnfw::kernel::acl;
+
+TEST(KernelACL_TC, neon_softmaxFloat32_1xn)
+{
+ float inputData[4];
+ const nnfw::rt::Shape inputShape = { OperandType::FLOAT32, {1,4}, 1.0, 0 };
+ float outputData[4];
+ const nnfw::rt::Shape outputShape = { OperandType::FLOAT32, {1,4}, 1.0, 0 };
+ const float beta = 1.0f;
+ bool bret;
+
+ util::initData(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0);
+ util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0);
+
+ bret = neon::softmaxFloat32(inputData, inputShape, beta, outputData, outputShape);
+ EXPECT_EQ(bret, true);
+
+ float expectData[] = { 0.25f, 0.25f, 0.25f, 0.25f };
+ bret = util::compareData(outputData, expectData, outputShape);
+ EXPECT_EQ(bret, true);
+}
+
+TEST(KernelACL_TC, neon_softmaxFloat32_4d)
+{
+ float inputData[4];
+ const nnfw::rt::Shape inputShape = { OperandType::FLOAT32, {1,1,4,1}, 1.0, 0 };
+ float outputData[4];
+ const nnfw::rt::Shape outputShape = { OperandType::FLOAT32, {1,1,4,1}, 1.0, 0 };
+ const float beta = 1.0f;
+ bool bret;
+
+ util::initData(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0);
+ util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0);
+
+ bret = neon::softmaxFloat32(inputData, inputShape, beta, outputData, outputShape);
+ EXPECT_EQ(bret, true);
+
+ float expectData[] = { 0.25f, 0.25f, 0.25f, 0.25f };
+ bret = util::compareData(outputData, expectData, outputShape);
+ EXPECT_EQ(bret, true);
+}
+
+TEST(KernelACL_TC, neon_softmaxFloat32_1xn_seq)
+{
+ float inputData[4];
+ const nnfw::rt::Shape inputShape = { OperandType::FLOAT32, {1,1,4,1}, 1.0, 0 };
+ float outputData[4];
+ const nnfw::rt::Shape outputShape = { OperandType::FLOAT32, {1,1,4,1}, 1.0, 0 };
+ const float beta = 1.0f;
+ bool bret;
+
+ util::initData_Increasing(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0);
+ util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0);
+
+ bret = neon::softmaxFloat32(inputData, inputShape, beta, outputData, outputShape);
+ EXPECT_EQ(bret, true);
+
+ float expectData[] = {0.032058603280085, 0.0871443187420326, 0.23688281808991, 0.643914259887972};
+ bret = util::compareData(outputData, expectData, outputShape);
+ EXPECT_EQ(bret, true);
+}
+
+TEST(KernelACL_TC, neon_softmaxFloat32_4d_seq)
+{
+ float inputData[4];
+ const nnfw::rt::Shape inputShape = { OperandType::FLOAT32, {1,1,4,1}, 1.0, 0 };
+ float outputData[4];
+ const nnfw::rt::Shape outputShape = { OperandType::FLOAT32, {1,1,4,1}, 1.0, 0 };
+ const float beta = 1.0f;
+ bool bret;
+
+ util::initData_Increasing(inputData, sizeof(inputData) / sizeof(inputData[0]), 1.0);
+ util::initData(outputData, sizeof(outputData) / sizeof(outputData[0]), 0.0);
+
+ bret = neon::softmaxFloat32(inputData, inputShape, beta, outputData, outputShape);
+ EXPECT_EQ(bret, true);
+
+ float expectData[] = {0.032058603280085, 0.0871443187420326, 0.23688281808991, 0.643914259887972};
+ bret = util::compareData(outputData, expectData, outputShape);
+ EXPECT_EQ(bret, true);
+}