ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Object.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
23#ifndef __NNFW_MISC_VECTOR_OBJECT_H__
24#define __NNFW_MISC_VECTOR_OBJECT_H__
25
26#include "misc/vector/Reader.h"
27
28#include <vector>
29#include <functional>
30
31namespace nnfw
32{
33namespace misc
34{
35namespace vector
36{
37
41template <typename T> class Object final : public Reader<T>
42{
43public:
44 using Generator = std::function<T(int32_t size, int32_t offset)>;
45
46public:
52 Object(int32_t size, const Generator &gen) : _size{size}
53 {
54 _value.resize(_size);
55
56 for (int32_t offset = 0; offset < size; ++offset)
57 {
58 _value.at(offset) = gen(size, offset);
59 }
60 }
61
62public:
67 int32_t size(void) const { return _size; }
68
69public:
75 T at(uint32_t nth) const override { return _value.at(nth); }
76
77private:
81 const int32_t _size;
85 std::vector<T> _value;
86};
87
88} // namespace vector
89} // namespace misc
90} // namespace nnfw
91
92#endif // __NNFW_MISC_VECTOR_OBJECT_H__
Class to have information of the operand for vector.
Definition Object.h:42
T at(uint32_t nth) const override
Get the value used by index.
Definition Object.h:75
Object(int32_t size, const Generator &gen)
Construct Object object with size of vector and set value used by Generator.
Definition Object.h:52
std::function< T(int32_t size, int32_t offset)> Generator
Definition Object.h:44
int32_t size(void) const
Get size of vector.
Definition Object.h:67
__global uchar * offset(const Image *img, int x, int y)
Definition helpers.h:540
Definition topk_v2.h:30
This file contains Reader class.
Class reads values of vector The interface class.
Definition Reader.h:40