aboutsummaryrefslogtreecommitdiff
path: root/delegate
diff options
context:
space:
mode:
authorTeresa Charlin <teresa.charlinreyes@arm.com>2023-03-23 15:28:02 +0000
committerTeresaARM <teresa.charlinreyes@arm.com>2023-04-19 08:54:57 +0000
commit93f0ad0016a6450670fbf650568f5724c7bbb63e (patch)
treeefb5f687ff93bf34bae1fe9d218124b57c2681ac /delegate
parentacb3ec51e51542d3011ed87842f87c2261abaaff (diff)
downloadarmnn-93f0ad0016a6450670fbf650568f5724c7bbb63e.tar.gz
GitHub #640 Add support for CEIL operator
* Reference workload * TfLite Delegate * TfLite Parser * Serializer and Deserializer * Changed fallback tests in delegate to use COS instead of CEIL Signed-off-by: Teresa Charlin <teresa.charlinreyes@arm.com> Signed-off-by: Mike Kelly <mike.kelly@arm.com> Change-Id: I36e0dbff33694182d1dba0c95d463506428e2f04
Diffstat (limited to 'delegate')
-rw-r--r--delegate/classic/src/armnn_delegate.cpp6
-rw-r--r--delegate/test/DelegateOptionsTest.cpp2
-rw-r--r--delegate/test/DelegateOptionsTestHelper.hpp18
-rw-r--r--delegate/test/ElementwiseUnaryTest.cpp20
4 files changed, 36 insertions, 10 deletions
diff --git a/delegate/classic/src/armnn_delegate.cpp b/delegate/classic/src/armnn_delegate.cpp
index b494a36769..9b4a7d3b86 100644
--- a/delegate/classic/src/armnn_delegate.cpp
+++ b/delegate/classic/src/armnn_delegate.cpp
@@ -602,6 +602,12 @@ TfLiteStatus ArmnnSubgraph::VisitNode(DelegateData& delegateData,
tfLiteNode,
nodeIndex,
kTfLiteBuiltinCast);
+ case kTfLiteBuiltinCeil:
+ return VisitElementwiseUnaryOperator(delegateData,
+ tfLiteContext,
+ tfLiteNode,
+ nodeIndex,
+ armnn::UnaryOperation::Ceil);
case kTfLiteBuiltinConcatenation:
return VisitControlOperator(delegateData,
tfLiteContext,
diff --git a/delegate/test/DelegateOptionsTest.cpp b/delegate/test/DelegateOptionsTest.cpp
index fd1ef88645..349e5d0692 100644
--- a/delegate/test/DelegateOptionsTest.cpp
+++ b/delegate/test/DelegateOptionsTest.cpp
@@ -177,7 +177,7 @@ TEST_CASE ("ArmnnDelegateStringParsingOptionEnableTfLiteRuntimeFallback")
std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
std::vector<int32_t> tensorShape { 1, 2, 2, 1 };
std::vector<float> inputData = { 0.1f, -2.1f, 3.0f, -4.6f };
- std::vector<float> expectedResult = { 1.0f, -2.0f, 3.0f, -4.0f };
+ std::vector<float> expectedResult = { 0.995004177f, -0.504846036f, -0.989992499f, -0.112152621f };
// Create options_keys and options_values char array
size_t num_options = keys.size();
diff --git a/delegate/test/DelegateOptionsTestHelper.hpp b/delegate/test/DelegateOptionsTestHelper.hpp
index b6974c9fb6..148a6d2c22 100644
--- a/delegate/test/DelegateOptionsTestHelper.hpp
+++ b/delegate/test/DelegateOptionsTestHelper.hpp
@@ -152,10 +152,10 @@ std::vector<char> CreateAddDivTfLiteModel(tflite::TensorType tensorType,
flatBufferBuilder.GetBufferPointer() + flatBufferBuilder.GetSize());
}
-std::vector<char> CreateCeilTfLiteModel(tflite::TensorType tensorType,
- const std::vector <int32_t>& tensorShape,
- float quantScale = 1.0f,
- int quantOffset = 0)
+std::vector<char> CreateCosTfLiteModel(tflite::TensorType tensorType,
+ const std::vector <int32_t>& tensorShape,
+ float quantScale = 1.0f,
+ int quantOffset = 0)
{
using namespace tflite;
flatbuffers::FlatBufferBuilder flatBufferBuilder;
@@ -199,7 +199,7 @@ std::vector<char> CreateCeilTfLiteModel(tflite::TensorType tensorType,
flatbuffers::Offset<flatbuffers::String> modelDescription =
flatBufferBuilder.CreateString("ArmnnDelegate: CEIL Operator Model");
flatbuffers::Offset<OperatorCode> operatorCode =
- CreateOperatorCode(flatBufferBuilder, tflite::BuiltinOperator_CEIL);
+ CreateOperatorCode(flatBufferBuilder, tflite::BuiltinOperator_COS);
const std::vector<int32_t> subgraphInputs({0});
const std::vector<int32_t> subgraphOutputs({1});
@@ -277,10 +277,10 @@ void DelegateOptionNoFallbackTest(tflite::TensorType tensorType,
int quantOffset = 0)
{
using namespace delegateTestInterpreter;
- std::vector<char> modelBuffer = CreateCeilTfLiteModel(tensorType,
- tensorShape,
- quantScale,
- quantOffset);
+ std::vector<char> modelBuffer = CreateCosTfLiteModel(tensorType,
+ tensorShape,
+ quantScale,
+ quantOffset);
// Setup interpreter with just TFLite Runtime.
auto tfLiteInterpreter = DelegateTestInterpreter(modelBuffer);
diff --git a/delegate/test/ElementwiseUnaryTest.cpp b/delegate/test/ElementwiseUnaryTest.cpp
index 6331436308..b4bdd295e1 100644
--- a/delegate/test/ElementwiseUnaryTest.cpp
+++ b/delegate/test/ElementwiseUnaryTest.cpp
@@ -295,6 +295,26 @@ TEST_CASE ("Abs_Float32_CpuRef_Test")
ElementwiseUnaryFP32Test(tflite::BuiltinOperator_ABS, backends, inputValues, expectedOutputValues);
}
+TEST_CASE ("Ceil_Float32_CpuRef_Test")
+{
+ // Create the ArmNN Delegate
+ std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
+ // Set input data
+ std::vector<float> inputValues
+ {
+ 0.0f, 1.1f, -16.1f,
+ 0.5f, -0.5f, -1.3f
+ };
+ // Set output data
+ std::vector<float> expectedOutputValues
+ {
+ 0.0f, 2.0f, -16.0f,
+ 1.0f, 0.0f, -1.0f
+ };
+
+ ElementwiseUnaryFP32Test(tflite::BuiltinOperator_CEIL, backends, inputValues, expectedOutputValues);
+}
+
TEST_CASE ("Exp_Float32_CpuRef_Test")
{
// Create the ArmNN Delegate