diff options
Diffstat (limited to 'runtime/libs/misc/include/misc')
-rw-r--r-- | runtime/libs/misc/include/misc/EnvConfigSource.h | 41 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/GeneralConfigSource.h | 44 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/IConfigSource.h | 46 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/RandomGenerator.h | 1 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/feature/Index.h | 2 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/feature/Shape.h | 2 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/kernel/Shape.h | 2 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/polymorphic_downcast.h | 2 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/string_helpers.h | 2 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/tensor/Object.h | 5 | ||||
-rw-r--r-- | runtime/libs/misc/include/misc/tensor/Zipper.h | 4 |
11 files changed, 140 insertions, 11 deletions
diff --git a/runtime/libs/misc/include/misc/EnvConfigSource.h b/runtime/libs/misc/include/misc/EnvConfigSource.h new file mode 100644 index 000000000..63c8ae9c0 --- /dev/null +++ b/runtime/libs/misc/include/misc/EnvConfigSource.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 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_MISC_ENV_CONFIG_SOURCE_H__ +#define __NNFW_MISC_ENV_CONFIG_SOURCE_H__ + +#include "GeneralConfigSource.h" + +#include <unordered_map> + +namespace nnfw +{ +namespace misc +{ + +class EnvConfigSource final : public GeneralConfigSource +{ +public: + std::string get(const std::string &key) const override; + +private: + std::unordered_map<std::string, std::string> _default_attributes; +}; + +} // namespace misc +} // namespace nnfw + +#endif // __NNFW_MISC_ENV_CONFIG_SOURCE_H__ diff --git a/runtime/libs/misc/include/misc/GeneralConfigSource.h b/runtime/libs/misc/include/misc/GeneralConfigSource.h new file mode 100644 index 000000000..a3de66e81 --- /dev/null +++ b/runtime/libs/misc/include/misc/GeneralConfigSource.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2019 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_MISC_GENERAL_CONFIG_SOURCE_H__ +#define __NNFW_MISC_GENERAL_CONFIG_SOURCE_H__ + +#include "IConfigSource.h" + +#include <unordered_map> + +namespace nnfw +{ +namespace misc +{ + +class GeneralConfigSource : public IConfigSource +{ +public: + GeneralConfigSource() = default; + + std::string get(const std::string &key) const override; + void set(const std::string &key, const std::string &val); + +private: + std::unordered_map<std::string, std::string> _map; +}; + +} // namespace misc +} // namespace nnfw + +#endif // __NNFW_MISC_GENERAL_CONFIG_SOURCE_H__ diff --git a/runtime/libs/misc/include/misc/IConfigSource.h b/runtime/libs/misc/include/misc/IConfigSource.h new file mode 100644 index 000000000..fe2c48ecf --- /dev/null +++ b/runtime/libs/misc/include/misc/IConfigSource.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2019 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_MISC_I_CONFIG_SOURCE_H__ +#define __NNFW_MISC_I_CONFIG_SOURCE_H__ + +#include <string> + +namespace nnfw +{ +namespace misc +{ + +struct IConfigSource +{ + /** + * @brief Destroy the IConfigSource object + */ + virtual ~IConfigSource() = default; + + /** + * @brief get the value for the matching key + * + * @param key string key to search + * @return string value associated with the key + */ + virtual std::string get(const std::string &key) const = 0; +}; + +} // namespace misc +} // namespace nnfw + +#endif // __NNFW_MISC_I_CONFIG_SOURCE_H__ diff --git a/runtime/libs/misc/include/misc/RandomGenerator.h b/runtime/libs/misc/include/misc/RandomGenerator.h index 8d26b8c74..8da4f7f20 100644 --- a/runtime/libs/misc/include/misc/RandomGenerator.h +++ b/runtime/libs/misc/include/misc/RandomGenerator.h @@ -76,6 +76,7 @@ private: std::normal_distribution<float> _dist; }; +template <> int8_t RandomGenerator::generate<int8_t>(void); template <> uint8_t RandomGenerator::generate<uint8_t>(void); template <> bool RandomGenerator::generate<bool>(void); template <> int32_t RandomGenerator::generate<int32_t>(void); diff --git a/runtime/libs/misc/include/misc/feature/Index.h b/runtime/libs/misc/include/misc/feature/Index.h index a361d8dd2..09d65a59a 100644 --- a/runtime/libs/misc/include/misc/feature/Index.h +++ b/runtime/libs/misc/include/misc/feature/Index.h @@ -62,7 +62,7 @@ public: * @param[in] col The width index */ Index(int32_t batch, int32_t ch, int32_t row, int32_t col) - : _batch{batch}, _ch{ch}, _row{row}, _col{col} + : _batch{batch}, _ch{ch}, _row{row}, _col{col} { // DO NOTHING } diff --git a/runtime/libs/misc/include/misc/feature/Shape.h b/runtime/libs/misc/include/misc/feature/Shape.h index 09881f58b..2c31b457c 100644 --- a/runtime/libs/misc/include/misc/feature/Shape.h +++ b/runtime/libs/misc/include/misc/feature/Shape.h @@ -64,7 +64,7 @@ struct Shape * @param[in] width The width value */ Shape(int32_t batch, int32_t depth, int32_t height, int32_t width) - : N{batch}, C{depth}, H{height}, W{width} + : N{batch}, C{depth}, H{height}, W{width} { // DO NOTHING } diff --git a/runtime/libs/misc/include/misc/kernel/Shape.h b/runtime/libs/misc/include/misc/kernel/Shape.h index 27d6a8bf0..176db0a11 100644 --- a/runtime/libs/misc/include/misc/kernel/Shape.h +++ b/runtime/libs/misc/include/misc/kernel/Shape.h @@ -55,7 +55,7 @@ struct Shape * @param[in] width The width index */ Shape(int32_t count, int32_t depth, int32_t height, int32_t width) - : N{count}, C{depth}, H{height}, W{width} + : N{count}, C{depth}, H{height}, W{width} { // DO NOTHING } diff --git a/runtime/libs/misc/include/misc/polymorphic_downcast.h b/runtime/libs/misc/include/misc/polymorphic_downcast.h index 412b864e6..ee885eb70 100644 --- a/runtime/libs/misc/include/misc/polymorphic_downcast.h +++ b/runtime/libs/misc/include/misc/polymorphic_downcast.h @@ -27,9 +27,7 @@ namespace misc template <typename DstType, typename SrcType> inline DstType polymorphic_downcast(SrcType *x) { -#ifndef __ANDROID__ assert(dynamic_cast<DstType>(x) == x); -#endif return static_cast<DstType>(x); } diff --git a/runtime/libs/misc/include/misc/string_helpers.h b/runtime/libs/misc/include/misc/string_helpers.h index 46fecca71..c9d72034f 100644 --- a/runtime/libs/misc/include/misc/string_helpers.h +++ b/runtime/libs/misc/include/misc/string_helpers.h @@ -50,7 +50,7 @@ inline std::vector<std::string> split(const std::string &s, char delim) std::vector<std::string> elems; while (std::getline(ss, item, delim)) { - elems.push_back(std::move(item)); + elems.push_back(item); } return elems; } diff --git a/runtime/libs/misc/include/misc/tensor/Object.h b/runtime/libs/misc/include/misc/tensor/Object.h index cba4f1baf..15ad6da4f 100644 --- a/runtime/libs/misc/include/misc/tensor/Object.h +++ b/runtime/libs/misc/include/misc/tensor/Object.h @@ -74,9 +74,8 @@ public: _values.resize(_shape.dim(0) * _stride.at(0)); // Set 'value' - iterate(_shape) << [this, &fn](const Index &index) { - _values.at(_stride.offset(index)) = fn(_shape, index); - }; + iterate(_shape) << + [this, &fn](const Index &index) { _values.at(_stride.offset(index)) = fn(_shape, index); }; } } diff --git a/runtime/libs/misc/include/misc/tensor/Zipper.h b/runtime/libs/misc/include/misc/tensor/Zipper.h index 8f0ec4ab6..b1ca3d003 100644 --- a/runtime/libs/misc/include/misc/tensor/Zipper.h +++ b/runtime/libs/misc/include/misc/tensor/Zipper.h @@ -48,7 +48,7 @@ public: * @param[in] rhs @c Reader object of a tensor */ Zipper(const Shape &shape, const Reader<T> &lhs, const Reader<T> &rhs) - : _shape{shape}, _lhs{lhs}, _rhs{rhs} + : _shape{shape}, _lhs{lhs}, _rhs{rhs} { // DO NOTHING } @@ -63,7 +63,7 @@ public: template <typename Callable> void zip(Callable cb) const { iterate(_shape) << - [this, &cb](const Index &index) { cb(index, _lhs.at(index), _rhs.at(index)); }; + [this, &cb](const Index &index) { cb(index, _lhs.at(index), _rhs.at(index)); }; } private: |