summaryrefslogtreecommitdiff
path: root/libs/kernel/acl/src/support.h
diff options
context:
space:
mode:
authorChunseok Lee <chunseok.lee@samsung.com>2018-05-04 17:57:16 +0900
committerChunseok Lee <chunseok.lee@samsung.com>2018-05-04 17:57:16 +0900
commit07659ccd9fe7b1cf1547cc6cad78bcf489f0a361 (patch)
treecf3a123812b7f1ad8b50d7d0ace891e0c03c6110 /libs/kernel/acl/src/support.h
parentda6f7a3e8360a49fd073a6e0031a4da134d9d984 (diff)
downloadnnfw-07659ccd9fe7b1cf1547cc6cad78bcf489f0a361.tar.gz
nnfw-07659ccd9fe7b1cf1547cc6cad78bcf489f0a361.tar.bz2
nnfw-07659ccd9fe7b1cf1547cc6cad78bcf489f0a361.zip
Imported Upstream version 0.1upstream/0.1submit/tizen/20180504.091146
Diffstat (limited to 'libs/kernel/acl/src/support.h')
-rw-r--r--libs/kernel/acl/src/support.h93
1 files changed, 93 insertions, 0 deletions
diff --git a/libs/kernel/acl/src/support.h b/libs/kernel/acl/src/support.h
new file mode 100644
index 000000000..751d2c6cb
--- /dev/null
+++ b/libs/kernel/acl/src/support.h
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+#ifndef __NNFW_KERNEL_SUPPORT_H_TEMPORARY__
+#define __NNFW_KERNEL_SUPPORT_H_TEMPORARY__
+
+// NOTE these are not decided yet but need to be moved out from Conv2D
+// to separate NEON implementation to it's folder
+// TODO move to some folder where it should be
+
+#include <cassert>
+
+#include "util/feature/Shape.h"
+
+#include <OperationsUtils.h>
+
+namespace nnfw
+{
+namespace support
+{
+namespace nnapi
+{
+namespace feature
+{
+
+// TODO Extract this function as utility function
+// NOTE It is not a good design to access nnfw::rt::Shape nnfw_support_nnapi lib
+nnfw::util::feature::Shape asFeatureShape(const nnfw::rt::Shape& shape);
+
+} // namespace feature
+} // namespace nnapi
+} // namespace support
+} // namespace nnfw
+
+#include <arm_compute/core/ITensor.h>
+
+#include "util/feature/Reader.h"
+
+namespace nnfw
+{
+namespace support
+{
+namespace acl
+{
+namespace feature
+{
+
+template<typename T> class Reader;
+
+template<> class Reader<float> final : public nnfw::util::feature::Reader<float>
+{
+public:
+ Reader(arm_compute::ITensor *tensor) : _tensor{tensor}
+ {
+ assert(tensor->info()->data_type() == arm_compute::DataType::F32);
+ }
+
+public:
+ float at(uint32_t ch, uint32_t row, uint32_t col) const override
+ {
+ return *ptr_to_element(ch, row, col);
+ }
+
+private:
+ float *ptr_to_element(uint32_t ch, uint32_t row, uint32_t col) const
+ {
+ // ARM Compute uses CHW ordering
+ return reinterpret_cast<float *>(_tensor->ptr_to_element(arm_compute::Coordinates{col, row, ch}));
+ }
+
+private:
+ arm_compute::ITensor *_tensor;
+};
+
+} // namespace feature
+} // namespace acl
+} // namespace support
+} // namespace nnfw
+
+#endif // __NNFW_KERNEL_SUPPORT_H_TEMPORARY__