diff options
Diffstat (limited to 'runtimes/pure_arm_compute/src/internal/nnapi/tensor/View.h')
-rw-r--r-- | runtimes/pure_arm_compute/src/internal/nnapi/tensor/View.h | 49 |
1 files changed, 41 insertions, 8 deletions
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; |