summaryrefslogtreecommitdiff
path: root/runtimes/pure_arm_compute/src/internal/arm_compute/feature/View.h
diff options
context:
space:
mode:
Diffstat (limited to 'runtimes/pure_arm_compute/src/internal/arm_compute/feature/View.h')
-rw-r--r--runtimes/pure_arm_compute/src/internal/arm_compute/feature/View.h61
1 files changed, 59 insertions, 2 deletions
diff --git a/runtimes/pure_arm_compute/src/internal/arm_compute/feature/View.h b/runtimes/pure_arm_compute/src/internal/arm_compute/feature/View.h
index 9d19021ae..c989ef4c2 100644
--- a/runtimes/pure_arm_compute/src/internal/arm_compute/feature/View.h
+++ b/runtimes/pure_arm_compute/src/internal/arm_compute/feature/View.h
@@ -14,10 +14,15 @@
* limitations under the License.
*/
+/**
+ * @file View.h
+ * @ingroup COM_AI_RUNTIME
+ * @brief This file defines internal::arm_compute::feature::View class
+ */
#ifndef __INTERNAL_ARM_COMPUTE_FEATURE_VIEW_H__
#define __INTERNAL_ARM_COMPUTE_FEATURE_VIEW_H__
-#include "util/feature/Reader.h"
+#include "misc/feature/Reader.h"
#include <arm_compute/core/ITensor.h>
@@ -28,15 +33,29 @@ namespace arm_compute
namespace feature
{
-template <typename T> class View final : public nnfw::util::feature::Reader<T>
+/**
+ * @brief Class to access feature's element
+ */
+template <typename T> class View final : public nnfw::misc::feature::Reader<T>
{
public:
+ /**
+ * @brief Construct a new View object
+ * @param[in] tensor Feature to support access
+ */
View(::arm_compute::ITensor *tensor) : _tensor{tensor}
{
// DO NOTHING
}
public:
+ /**
+ * @brief Get value of element in 3D feature using channel, row and column
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Value of element
+ */
T at(uint32_t ch, uint32_t row, uint32_t col) const override
{
const auto offset = feature_index_to_byte_offset(ch, row, col);
@@ -46,6 +65,14 @@ public:
return *ptr;
}
+ /**
+ * @brief Get value of element in 4D feature using batch, channel, row and column
+ * @param[in] batch Batch index
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Value of element
+ */
T at(uint32_t batch, uint32_t ch, uint32_t row, uint32_t col) const override
{
const auto offset = feature_index_to_byte_offset(batch, ch, row, col);
@@ -56,6 +83,13 @@ public:
}
public:
+ /**
+ * @brief Get reference of element in 3D feature using channel, row and column
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Reference of element
+ */
T &at(uint32_t ch, uint32_t row, uint32_t col)
{
const auto offset = feature_index_to_byte_offset(ch, row, col);
@@ -65,6 +99,14 @@ public:
return *ptr;
}
+ /**
+ * @brief Get reference of element in 4D feature using batch, channel, row and column
+ * @param[in] batch Batch index
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Reference of element
+ */
T &at(uint32_t batch, uint32_t ch, uint32_t row, uint32_t col)
{
const auto offset = feature_index_to_byte_offset(batch, ch, row, col);
@@ -75,12 +117,27 @@ public:
}
private:
+ /**
+ * @brief Get offset of element in 3D feature
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Offset of element
+ */
size_t feature_index_to_byte_offset(uint32_t ch, uint32_t row, uint32_t col) const
{
// ARM Compute uses CHW ordering
return _tensor->info()->offset_element_in_bytes(::arm_compute::Coordinates{col, row, ch});
}
+ /**
+ * @brief Get offset of element in 4D feature
+ * @param[in] batch Batch index
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Offset of element
+ */
size_t feature_index_to_byte_offset(uint32_t batch, uint32_t ch, uint32_t row, uint32_t col) const
{
// ARM Compute uses CHW ordering