summaryrefslogtreecommitdiff
path: root/runtimes/pure_arm_compute/src/internal/nnapi
diff options
context:
space:
mode:
authorChunseok Lee <chunseok.lee@samsung.com>2019-01-08 17:36:34 +0900
committerChunseok Lee <chunseok.lee@samsung.com>2019-01-08 17:36:34 +0900
commitbd11b24234d7d43dfe05a81c520aa01ffad06e42 (patch)
tree57d0d4044977e4fa0e50cd9ba40b32006dff19eb /runtimes/pure_arm_compute/src/internal/nnapi
parent91f4ba45449f700a047a4aeea00b1a7c84e94c75 (diff)
downloadnnfw-bd11b24234d7d43dfe05a81c520aa01ffad06e42.tar.gz
nnfw-bd11b24234d7d43dfe05a81c520aa01ffad06e42.tar.bz2
nnfw-bd11b24234d7d43dfe05a81c520aa01ffad06e42.zip
Imported Upstream version 0.3upstream/0.3
Diffstat (limited to 'runtimes/pure_arm_compute/src/internal/nnapi')
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/feature/Reader.h43
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/feature/Utils.h28
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/feature/View.h61
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/kernel/Reader.h38
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/matrix/Reader.h36
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/tensor/ConstView.h36
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/tensor/Reader.h62
-rw-r--r--runtimes/pure_arm_compute/src/internal/nnapi/tensor/View.h49
8 files changed, 297 insertions, 56 deletions
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/feature/Reader.h b/runtimes/pure_arm_compute/src/internal/nnapi/feature/Reader.h
index 764b9b13a..ac25692a1 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/feature/Reader.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/feature/Reader.h
@@ -14,12 +14,17 @@
* limitations under the License.
*/
+/**
+ * @file Reader.h
+ * @ingroup COM_AI_RUNTIME
+ * @brief This file defines internal::nnapi::feature::Reader
+ */
#ifndef __INTERNAL_NNAPI_FEATURE_READER_H__
#define __INTERNAL_NNAPI_FEATURE_READER_H__
#include "internal/nnapi/feature/Utils.h"
-#include "util/feature/Reader.h"
+#include "misc/feature/Reader.h"
namespace internal
{
@@ -28,20 +33,40 @@ namespace nnapi
namespace feature
{
-template <typename T> class Reader final : public nnfw::util::feature::Reader<T>
+/**
+ * @brief Class to support reading element in feature(3D, 4D)
+ */
+template <typename T> class Reader final : public nnfw::misc::feature::Reader<T>
{
public:
+ /**
+ * @brief Construct a new Reader object
+ * @param[in] shape Shape of feature
+ * @param[in] ptr Pointer to feature data
+ * @param[in] len Size of tensor (byte)
+ */
// NOTE The parameter len denotes the number of bytes.
- Reader(const ::nnfw::util::feature::Shape &shape, const T *ptr, size_t len)
+ Reader(const ::nnfw::misc::feature::Shape &shape, const T *ptr, size_t len)
: _shape{shape}, _ptr{ptr}
{
assert(shape.N * shape.C * shape.H * shape.W * sizeof(T) == len);
}
public:
- const nnfw::util::feature::Shape &shape(void) const { return _shape; }
+ /**
+ * @brief Get shape of feature
+ * @return Shape of feature
+ */
+ const nnfw::misc::feature::Shape &shape(void) const { return _shape; }
public:
+ /**
+ * @brief Get value of element using channel, row, and column index for 3D feature
+ * @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
{
uint32_t index = index_of(_shape, ch, row, col);
@@ -51,6 +76,14 @@ public:
return arr[index];
}
+ /**
+ * @brief Get value of element using batch, channel, row, and column index for 4D feature
+ * @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
{
uint32_t index = index_of(_shape, batch, ch, row, col);
@@ -59,7 +92,7 @@ public:
}
private:
- nnfw::util::feature::Shape _shape;
+ nnfw::misc::feature::Shape _shape;
private:
const T *_ptr;
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/feature/Utils.h b/runtimes/pure_arm_compute/src/internal/nnapi/feature/Utils.h
index a64ff5d63..ee59d217e 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/feature/Utils.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/feature/Utils.h
@@ -14,10 +14,15 @@
* limitations under the License.
*/
+/**
+ * @file Utils.h
+ * @ingroup COM_AI_RUNTIME
+ * @brief This file defines utility functions used in internal::nnapi::feature namespace
+ */
#ifndef __INTERNAL_NNAPI_FEATURE_UTILS_H__
#define __INTERNAL_NNAPI_FEATURE_UTILS_H__
-#include "util/feature/Shape.h"
+#include "misc/feature/Shape.h"
namespace internal
{
@@ -26,7 +31,15 @@ namespace nnapi
namespace feature
{
-inline uint32_t index_of(const ::nnfw::util::feature::Shape &shape, uint32_t ch, uint32_t row,
+/**
+ * @brief Get position of element using channel, row, and column for 3D feature
+ * @param[in] shape Shape of feature
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Position of element
+ */
+inline uint32_t index_of(const ::nnfw::misc::feature::Shape &shape, uint32_t ch, uint32_t row,
uint32_t col)
{
uint32_t res = 0;
@@ -39,7 +52,16 @@ inline uint32_t index_of(const ::nnfw::util::feature::Shape &shape, uint32_t ch,
return res;
}
-inline uint32_t index_of(const ::nnfw::util::feature::Shape &shape, uint32_t batch, uint32_t ch,
+/**
+ * @brief Get position of element using batch, channel, row, and column for 4D feature
+ * @param[in] shape Shape of feature
+ * @param[in] batch Batch index
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Position of element
+ */
+inline uint32_t index_of(const ::nnfw::misc::feature::Shape &shape, uint32_t batch, uint32_t ch,
uint32_t row, uint32_t col)
{
uint32_t res = 0;
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/feature/View.h b/runtimes/pure_arm_compute/src/internal/nnapi/feature/View.h
index 083b6b055..965e42f1c 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/feature/View.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/feature/View.h
@@ -14,12 +14,17 @@
* limitations under the License.
*/
+/**
+ * @file View.h
+ * @ingroup COM_AI_RUNTIME
+ * @brief This file defines internal::nnapi::feature::View class
+ */
#ifndef __INTERNAL_NNAPI_FEATURE_VIEW_H__
#define __INTERNAL_NNAPI_FEATURE_VIEW_H__
#include "internal/nnapi/feature/Utils.h"
-#include "util/feature/Reader.h"
+#include "misc/feature/Reader.h"
namespace internal
{
@@ -28,25 +33,55 @@ namespace nnapi
namespace feature
{
-template <typename T> class View final : public nnfw::util::feature::Reader<T>
+/**
+ * @brief Class to access feature's element information using index
+ */
+template <typename T> class View final : public nnfw::misc::feature::Reader<T>
{
public:
+ /**
+ * @brief Construct a new View object
+ * @param[in] shape Shape of feature
+ * @param[in] ptr Pointer to feature data
+ * @param[in] len Size of feature (byte)
+ * @return
+ */
// NOTE The parameter len denotes the number of bytes.
- View(const ::nnfw::util::feature::Shape &shape, T *ptr, size_t len) : _shape{shape}, _ptr{ptr}
+ View(const ::nnfw::misc::feature::Shape &shape, T *ptr, size_t len) : _shape{shape}, _ptr{ptr}
{
assert(shape.N * shape.C * shape.H * shape.W * sizeof(T) == len);
}
public:
- const nnfw::util::feature::Shape &shape(void) const { return _shape; }
+ /**
+ * @brief Get shape of feature
+ * @return Shape of feature
+ */
+ const nnfw::misc::feature::Shape &shape(void) const { return _shape; }
public:
+ /**
+ * @brief Get value of element in 3D feature using channel, row, and column index
+ * @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
{
uint32_t index = index_of(_shape, ch, row, col);
return _ptr[index];
}
+
+ /**
+ * @brief Get value of element in 4D feature using batch, channel, row and column index
+ * @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
{
uint32_t index = index_of(_shape, batch, ch, row, col);
@@ -54,12 +89,28 @@ public:
return _ptr[index];
}
+ /**
+ * @brief Get reference of element in 3D feature using channel, row, and column index
+ * @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)
{
uint32_t index = index_of(_shape, ch, row, col);
return _ptr[index];
}
+
+ /**
+ * @brief Get reference of element in 4D feature using batch, channel, row and column index
+ * @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)
{
uint32_t index = index_of(_shape, batch, ch, row, col);
@@ -68,7 +119,7 @@ public:
}
private:
- nnfw::util::feature::Shape _shape;
+ nnfw::misc::feature::Shape _shape;
private:
T *_ptr;
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/kernel/Reader.h b/runtimes/pure_arm_compute/src/internal/nnapi/kernel/Reader.h
index 0853a8c89..ae964f74c 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/kernel/Reader.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/kernel/Reader.h
@@ -14,11 +14,16 @@
* limitations under the License.
*/
+/**
+ * @file Reader.h
+ * @ingroup COM_AI_RUNTIME
+ * @brief This file defines internal::nnapi::kernel::Reader class
+ */
#ifndef __INTERNAL_NNAPI_KERNEL_READER_H__
#define __INTERNAL_NNAPI_KERNEL_READER_H__
-#include "util/kernel/Shape.h"
-#include "util/kernel/Reader.h"
+#include "misc/kernel/Shape.h"
+#include "misc/kernel/Reader.h"
namespace internal
{
@@ -27,20 +32,41 @@ namespace nnapi
namespace kernel
{
-template <typename T> class Reader final : public nnfw::util::kernel::Reader<T>
+/**
+ * @brief Class to support reading element in kernel
+ */
+template <typename T> class Reader final : public nnfw::misc::kernel::Reader<T>
{
public:
+ /**
+ * @brief Construct a new Reader object
+ * @param[in] shape Shape of kernel
+ * @param[in] ptr Pointer to kernel data
+ * @param[in] len Size of kernel (byte)
+ */
// NOTE The parameter len denotes the number of bytes.
- Reader(const ::nnfw::util::kernel::Shape &shape, const T *ptr, size_t len)
+ Reader(const ::nnfw::misc::kernel::Shape &shape, const T *ptr, size_t len)
: _shape{shape}, _ptr{ptr}
{
assert(shape.N * shape.C * shape.H * shape.W * sizeof(T) == len);
}
public:
- const nnfw::util::kernel::Shape &shape(void) const { return _shape; }
+ /**
+ * @brief Get shape of kernel
+ * @return Shape of kernel
+ */
+ const nnfw::misc::kernel::Shape &shape(void) const { return _shape; }
public:
+ /**
+ * @brief Get value of element for kernel
+ * @param[in] nth Kernel index
+ * @param[in] ch Channel index
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Value of element
+ */
T at(uint32_t nth, uint32_t ch, uint32_t row, uint32_t col) const override
{
// NNAPI uses NHWC ordering
@@ -55,7 +81,7 @@ public:
}
private:
- nnfw::util::kernel::Shape _shape;
+ nnfw::misc::kernel::Shape _shape;
private:
const T *_ptr;
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/matrix/Reader.h b/runtimes/pure_arm_compute/src/internal/nnapi/matrix/Reader.h
index f6f0f3908..f03a4be31 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/matrix/Reader.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/matrix/Reader.h
@@ -14,11 +14,16 @@
* limitations under the License.
*/
+/**
+ * @file Reader.h
+ * @ingroup COM_AI_RUNTIME
+ * @brief This file defines internal::nnapi::matrix::Reader class
+ */
#ifndef __INTERNAL_NNAPI_MATRIX_READER_H__
#define __INTERNAL_NNAPI_MATRIX_READER_H__
-#include "util/matrix/Shape.h"
-#include "util/matrix/Reader.h"
+#include "misc/matrix/Shape.h"
+#include "misc/matrix/Reader.h"
namespace internal
{
@@ -27,20 +32,39 @@ namespace nnapi
namespace matrix
{
-template <typename T> class Reader final : public nnfw::util::matrix::Reader<T>
+/**
+ * @brief Class to support reading element in matrix
+ */
+template <typename T> class Reader final : public nnfw::misc::matrix::Reader<T>
{
public:
+ /**
+ * @brief Construct a new Reader object
+ * @param[in] shape Shape of matrix
+ * @param[in] ptr Pointer to matrix data
+ * @param[in] len Size of matrix (byte)
+ */
// NOTE The parameter len denotes the number of bytes.
- Reader(const ::nnfw::util::matrix::Shape &shape, const T *ptr, size_t len)
+ Reader(const ::nnfw::misc::matrix::Shape &shape, const T *ptr, size_t len)
: _shape{shape}, _ptr{ptr}
{
assert(shape.H * shape.W * sizeof(T) == len);
}
public:
- const nnfw::util::matrix::Shape &shape(void) const { return _shape; }
+ /**
+ * @brief Get shape of matrix
+ * @return Shape of matrix
+ */
+ const nnfw::misc::matrix::Shape &shape(void) const { return _shape; }
public:
+ /**
+ * @brief Get value of element for matrix
+ * @param[in] row Row index
+ * @param[in] col Column index
+ * @return Value of element
+ */
T at(uint32_t row, uint32_t col) const override
{
// NNAPI uses NHWC ordering
@@ -53,7 +77,7 @@ public:
}
private:
- nnfw::util::matrix::Shape _shape;
+ nnfw::misc::matrix::Shape _shape;
private:
const T *_ptr;
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/tensor/ConstView.h b/runtimes/pure_arm_compute/src/internal/nnapi/tensor/ConstView.h
index 38d1b291b..6a3fff646 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/tensor/ConstView.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/tensor/ConstView.h
@@ -14,6 +14,12 @@
* limitations under the License.
*/
+/**
+ * @file        ConstView.h
+ * @brief       This file contains ConstView class
+ * @ingroup     COM_AI_RUNTIME
+ */
+
#ifndef __INTERNAL_NNAPI_TENSOR_CONST_VIEW_H__
#define __INTERNAL_NNAPI_TENSOR_CONST_VIEW_H__
@@ -27,21 +33,36 @@ namespace nnapi
namespace tensor
{
+/**
+ * @brief Wrapper class to read tensor values
+ * @tparam T The tensor element type
+ */
template <typename T> class ConstView
{
public:
- ConstView(const ::nnfw::util::tensor::Shape &shape, const uint8_t *ptr, size_t len)
+ /**
+ * @brief Construct a ConstView class
+ * @param[in] shape Tensor shape
+ * @param[in] ptr The base pointer of actual data
+ * @param[in] len The number of bytes
+ */
+ ConstView(const ::nnfw::misc::tensor::Shape &shape, const uint8_t *ptr, size_t len)
: _shape{shape}, _ptr{ptr}, _len{len}
{
// DO NOTHING
}
public:
- const nnfw::util::tensor::Shape &shape(void) const { return _shape; }
+ const nnfw::misc::tensor::Shape &shape(void) const { return _shape; }
private:
// TODO Make this as a helper function, and share it for both View<T> and ConstView<T>
- uint32_t offset_of(const nnfw::util::tensor::Index &index) const
+ /**
+ * @brief Calculate offset for the given tensor index
+ * @param[in] index Tensor index
+ * @return The calculated offset
+ */
+ uint32_t offset_of(const nnfw::misc::tensor::Index &index) const
{
if (_shape.rank() == 0)
{
@@ -61,7 +82,12 @@ private:
}
public:
- T at(const nnfw::util::tensor::Index &index) const
+ /**
+ * @brief Get the value on the given index
+ * @param[in] index Flattened tensor index
+ * @return The value on the given index
+ */
+ T at(const nnfw::misc::tensor::Index &index) const
{
const auto offset = offset_of(index);
@@ -71,7 +97,7 @@ public:
}
private:
- const nnfw::util::tensor::Shape _shape;
+ const nnfw::misc::tensor::Shape _shape;
private:
const uint8_t *const _ptr;
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/tensor/Reader.h b/runtimes/pure_arm_compute/src/internal/nnapi/tensor/Reader.h
index fe89e572e..cc51db594 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/tensor/Reader.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/tensor/Reader.h
@@ -14,11 +14,17 @@
* limitations under the License.
*/
+/**
+ * @file        Reader.h
+ * @brief       This file contains Reader class
+ * @ingroup     COM_AI_RUNTIME
+ */
+
#ifndef __INTERNAL_NNAPI_TENSOR_READER_H__
#define __INTERNAL_NNAPI_TENSOR_READER_H__
#include <vector>
-#include "util/tensor/Reader.h"
+#include "misc/tensor/Reader.h"
namespace internal
{
@@ -27,11 +33,20 @@ namespace nnapi
namespace tensor
{
-template <typename T> class Reader final : public nnfw::util::tensor::Reader<T>
+/**
+ * @brief Wrapper class to read tensor values
+ * @tparam T The tensor element type
+ */
+template <typename T> class Reader final : public nnfw::misc::tensor::Reader<T>
{
public:
- // NOTE The parameter len denotes the number of bytes.
- Reader(const ::nnfw::util::tensor::Shape &shape, const T *ptr, size_t len)
+ /**
+ * @brief Construct a Reader class
+ * @param[in] shape Tensor shape
+ * @param[in] ptr The base pointer of actual data
+ * @param[in] len The number of bytes
+ */
+ Reader(const ::nnfw::misc::tensor::Shape &shape, const T *ptr, size_t len)
: _shape{shape}, _ptr{ptr}
{
assert(shape.element_nums() * sizeof(T) == len);
@@ -39,10 +54,19 @@ public:
}
public:
- const nnfw::util::tensor::Shape &shape(void) const { return _shape; }
+ /**
+ * @brief Get shape object
+ * @return The shape as const reference
+ */
+ const nnfw::misc::tensor::Shape &shape(void) const { return _shape; }
public:
- T at(const nnfw::util::tensor::Index &index_nnapi) const override
+ /**
+ * @brief Get the value on the given index
+ * @param[in] index_nnapi Flattened tensor index
+ * @return The value on the given index
+ */
+ T at(const nnfw::misc::tensor::Index &index_nnapi) const override
{
uint32_t offset = 0;
@@ -53,17 +77,19 @@ public:
}
private:
- /*
- Assuming that shape is [d4, .. , d1] and data is stored at a pointer ptr,
- we need to calculate the offset of index [i4, .. i1] as follows:
- offset = i4 * (d3 * d2 * d1) +
- i3 * (d2 * d1) +
- i2 * (d1) +
- i1
- So (d4 * d3 * d2 * d1) or (d3 * d2 * d1) or (d2 * d1) happens whenever offset is calculate.
- To minimize this repetitive calculation,
- _stridess[n] contains _spape[n-1]*_spape[n-2]*_spape[0]
- */
+ /**
+ * @brief Initializes @c _stridess
+ * @return N/A
+ * @note Assuming that shape is [d4, .. , d1] and data is stored at a pointer ptr,
+ we need to calculate the offset of index [i4, .. i1] as follows:
+ offset = i4 * (d3 * d2 * d1) +
+ i3 * (d2 * d1) +
+ i2 * (d1) +
+ i1
+ So (d4 * d3 * d2 * d1) or (d3 * d2 * d1) or (d2 * d1) happens whenever offset is
+ calculate. To minimize this repetitive calculation,
+ _stridess[n] contains _spape[n-1]*_spape[n-2]*_spape[0]
+ */
void initialize(void)
{
for (int r = 0; r < _shape.rank(); r++)
@@ -76,7 +102,7 @@ private:
}
private:
- nnfw::util::tensor::Shape _shape;
+ nnfw::misc::tensor::Shape _shape;
private:
const T *_ptr;
diff --git a/runtimes/pure_arm_compute/src/internal/nnapi/tensor/View.h b/runtimes/pure_arm_compute/src/internal/nnapi/tensor/View.h
index 80e1bb057..f8f297f97 100644
--- a/runtimes/pure_arm_compute/src/internal/nnapi/tensor/View.h
+++ b/runtimes/pure_arm_compute/src/internal/nnapi/tensor/View.h
@@ -14,11 +14,16 @@
* limitations under the License.
*/
+/**
+ * @file View.h
+ * @ingroup COM_AI_RUNTIME
+ * @brief This file defines internal::nnapi::tensor::View class
+ */
#ifndef __INTERNAL_NNAPI_TENSOR_VIEW_H__
#define __INTERNAL_NNAPI_TENSOR_VIEW_H__
-#include "util/tensor/Shape.h"
-#include "util/tensor/Index.h"
+#include "misc/tensor/Shape.h"
+#include "misc/tensor/Index.h"
namespace internal
{
@@ -27,20 +32,38 @@ namespace nnapi
namespace tensor
{
+/**
+ * @brief Class to access tensor's element information using index
+ */
template <typename T> class View
{
public:
+ /**
+ * @brief Construct a new View object
+ * @param[in] shape Shape of tensor
+ * @param[in] ptr Pointer to tensor data
+ * @param[in] len Size of tensor (byte)
+ */
// NOTE The parameter len denotes the number of bytes.
- View(const ::nnfw::util::tensor::Shape &shape, T *ptr, size_t len) : _shape{shape}, _ptr{ptr}
+ View(const ::nnfw::misc::tensor::Shape &shape, T *ptr, size_t len) : _shape{shape}, _ptr{ptr}
{
assert(shape.element_nums() * sizeof(T) == len);
}
public:
- const nnfw::util::tensor::Shape &shape(void) const { return _shape; }
+ /**
+ * @brief Get shape of tensor
+ * @return Shape of tensor
+ */
+ const nnfw::misc::tensor::Shape &shape(void) const { return _shape; }
private:
- uint32_t offset_of(const nnfw::util::tensor::Index &index) const
+ /**
+ * @brief Get position of element using index in tensor
+ * @param[in] index Index of element
+ * @return Position of element
+ */
+ uint32_t offset_of(const nnfw::misc::tensor::Index &index) const
{
if (_shape.rank() == 0)
{
@@ -60,14 +83,24 @@ private:
}
public:
- T at(const nnfw::util::tensor::Index &index) const
+ /**
+ * @brief Get value of element at index
+ * @param[in] index Index of element
+ * @return Value of element at index
+ */
+ T at(const nnfw::misc::tensor::Index &index) const
{
const auto offset = offset_of(index);
return _ptr[offset];
}
- T &at(const nnfw::util::tensor::Index &index)
+ /**
+ * @brief Get reference of element at index
+ * @param[in] index Index of element
+ * @return Reference of element at index
+ */
+ T &at(const nnfw::misc::tensor::Index &index)
{
const auto offset = offset_of(index);
@@ -75,7 +108,7 @@ public:
}
private:
- nnfw::util::tensor::Shape _shape;
+ nnfw::misc::tensor::Shape _shape;
private:
T *_ptr;