1/*******************************************************************************
2* Copyright 2019-2022 Intel Corporation
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 "dnnl_debug.hpp"
18#include "sum/sum.hpp"
19
20namespace sum {
21
22std::ostream &operator<<(
23 std::ostream &s, const std::vector<float> &input_scales) {
24 bool has_single_scale = true;
25 for (size_t d = 0; d < input_scales.size() - 1; ++d)
26 has_single_scale
27 = has_single_scale && input_scales[d] == input_scales[d + 1];
28
29 s << input_scales[0];
30 if (!has_single_scale)
31 for (size_t d = 1; d < input_scales.size(); ++d)
32 s << ":" << input_scales[d];
33 return s;
34}
35
36std::ostream &operator<<(std::ostream &s, const prb_t &prb) {
37 using ::operator<<;
38 using sum::operator<<;
39
40 dump_global_params(s);
41 settings_t def;
42
43 bool has_default_tags = true;
44 for (const auto &i_stag : prb.stag)
45 has_default_tags = has_default_tags && i_stag == tag::abx;
46
47 if (canonical || prb.sdt != def.sdt[0]) s << "--sdt=" << prb.sdt << " ";
48 if (canonical || prb.ddt != def.ddt[0]) s << "--ddt=" << prb.ddt << " ";
49 if (canonical || !has_default_tags) s << "--stag=" << prb.stag << " ";
50 if (canonical || prb.dtag != def.dtag[0]) s << "--dtag=" << prb.dtag << " ";
51 s << "--scales=" << prb.input_scales << " ";
52 if (canonical || prb.inplace != def.inplace[0])
53 s << "--inplace=" << bool2str(prb.inplace) << " ";
54
55 s << prb.attr;
56 if (canonical || prb.ctx_init != def.ctx_init[0])
57 s << "--ctx-init=" << prb.ctx_init << " ";
58 if (canonical || prb.ctx_exe != def.ctx_exe[0])
59 s << "--ctx-exe=" << prb.ctx_exe << " ";
60
61 s << static_cast<prb_dims_t>(prb);
62
63 return s;
64}
65
66} // namespace sum
67