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
17 #include <sstream>
18 #include <string>
19 #include "nnacl/pooling_parameter.h"
20 #include "nnacl/slice_parameter.h"
21 #include "nnacl/softmax_parameter.h"
22 #include "nnacl/int8/add_int8.h"
23 #include "nnacl/int8/quantize.h"
24 #include "coder/opcoders/parallel.h"
25 #include "coder/opcoders/serializers/nnacl_serializer/nnacl_stream_utils.h"
26
27 namespace mindspore::lite::micro {
operator <<(std::ostream & code,const::QuantArg & quant_arg)28 std::ostream &operator<<(std::ostream &code, const ::QuantArg &quant_arg) {
29 code << "{" << static_cast<float>(quant_arg.scale_) << ", " << quant_arg.zp_ << "}";
30 return code;
31 }
32
operator <<(std::ostream & code,const OpParameter & parameter)33 std::ostream &operator<<(std::ostream &code, const OpParameter ¶meter) {
34 code << "{ \"\""
35 << ", " << parameter.type_ << ", " << gThreadNum << ", " << parameter.quant_type_ << "}";
36 return code;
37 }
38
operator <<(std::ostream & code,const AddQuantQrgs & args)39 std::ostream &operator<<(std::ostream &code, const AddQuantQrgs &args) {
40 code << "{" << args.zp_ << ", " << args.left_shift_ << ", " << args.right_shift_ << ", " << args.multiplier_ << "}";
41 return code;
42 }
43
operator <<(std::ostream & code,const SliceQuantArg & arg)44 std::ostream &operator<<(std::ostream &code, const SliceQuantArg &arg) {
45 code << "{" << arg.in_args_ << ", " << arg.out_args_ << ", " << arg.output_activation_min_ << ", "
46 << arg.output_activation_max_ << "}";
47 return code;
48 }
49
operator <<(std::ostream & code,PoolMode pool_mode)50 std::ostream &operator<<(std::ostream &code, PoolMode pool_mode) {
51 code << "(PoolMode)"
52 << "(" << static_cast<int>(pool_mode) << ")";
53 return code;
54 }
55
operator <<(std::ostream & code,RoundMode round_mode)56 std::ostream &operator<<(std::ostream &code, RoundMode round_mode) {
57 code << "(RoundMode)"
58 << "(" << static_cast<int>(round_mode) << ")";
59 return code;
60 }
61
operator <<(std::ostream & code,RoundingMode rounding_mode)62 std::ostream &operator<<(std::ostream &code, RoundingMode rounding_mode) {
63 code << "(RoundingMode)"
64 << "(" << static_cast<int>(rounding_mode) << ")";
65 return code;
66 }
67
operator <<(std::ostream & code,PadMode pad_mode)68 std::ostream &operator<<(std::ostream &code, PadMode pad_mode) {
69 code << "(PadMode)"
70 << "(" << static_cast<int>(pad_mode) << ")";
71 return code;
72 }
73
operator <<(std::ostream & code,ActType act_type)74 std::ostream &operator<<(std::ostream &code, ActType act_type) {
75 code << "(ActType)"
76 << "(" << static_cast<int>(act_type) << ")";
77 return code;
78 }
79
operator <<(std::ostream & code,DataOrder data_order)80 std::ostream &operator<<(std::ostream &code, DataOrder data_order) {
81 if (data_order == RowMajor) {
82 code << "RowMajor";
83 } else {
84 code << "ColMajor";
85 }
86 return code;
87 }
88 } // namespace mindspore::lite::micro
89