1 /**
2 * Copyright 2021 Huawei Technologies Co., Ltd
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 #ifndef MINDSPORE_LITE_MICRO_CODER_UTILS_CODER_UTILS_H_
17 #define MINDSPORE_LITE_MICRO_CODER_UTILS_CODER_UTILS_H_
18
19 #include <set>
20 #include <limits>
21 #include <vector>
22 #include <memory>
23 #include <string>
24 #include "include/errorcode.h"
25 #include "securec/include/securec.h"
26 #include "src/tensor.h"
27 #include "coder/opcoders/op_coder.h"
28
29 namespace mindspore::lite::micro {
30
31 constexpr int kWeightPrecision = 9;
32
33 bool CheckConstantTensor(const Tensor *const tensor);
34
35 std::vector<std::string> AddDumpDataInfo(const std::vector<std::string> &blocks,
36 const std::vector<std::unique_ptr<OperatorCoder>> &opcoders);
37
38 void PrintTensorData(const lite::Tensor *tensor, std::ofstream &ofs);
39
40 template <typename T>
ArrayToString(std::vector<T> array)41 std::string ArrayToString(std::vector<T> array) {
42 std::string result;
43 std::for_each(array.begin(), array.end(), [&result](const T &t) { result += std::to_string(t) + ", "; });
44 return "{" + result + "}";
45 }
46
47 } // namespace mindspore::lite::micro
48
49 #endif // MINDSPORE_LITE_MICRO_CODER_UTILS_CODER_UTILS_H_
50