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 <assert.h>
18#include <stdlib.h>
19#include "lnorm/lnorm.hpp"
20
21namespace lnorm {
22
23flags_t str2flags(const char *str) {
24 flags_t flags = bnorm::str2flags(str);
25 assert(flags <= (GLOB_STATS | USE_SCALE | USE_SHIFT));
26 return flags;
27}
28
29std::ostream &operator<<(std::ostream &s, const prb_t &prb) {
30 dump_global_params(s);
31 settings_t def;
32
33 bool has_default_dts = true;
34 for (const auto &i_dt : prb.dt)
35 has_default_dts = has_default_dts && i_dt == dnnl_f32;
36
37 if (canonical || prb.dir != def.dir[0]) s << "--dir=" << prb.dir << " ";
38 if (canonical || !has_default_dts) s << "--dt=" << prb.dt << " ";
39 if (canonical || prb.tag != def.tag[0]) {
40 s << "--tag=";
41 if (prb.tag[1] != def.tag[0][1])
42 s << prb.tag[0] << ":" << prb.tag[1] << " ";
43 else
44 s << prb.tag[0] << " ";
45 }
46 if (canonical || prb.stat_tag != def.stat_tag[0])
47 s << "--stat_tag=" << prb.stat_tag << " ";
48 if (canonical || prb.flags != def.flags[0])
49 s << "--flags=" << flags2str(prb.flags) << " ";
50 if (canonical || prb.inplace != def.inplace[0])
51 s << "--inplace=" << bool2str(prb.inplace) << " ";
52
53 s << prb.attr;
54 if (canonical || prb.ctx_init != def.ctx_init[0])
55 s << "--ctx-init=" << prb.ctx_init << " ";
56 if (canonical || prb.ctx_exe != def.ctx_exe[0])
57 s << "--ctx-exe=" << prb.ctx_exe << " ";
58
59 s << static_cast<prb_dims_t>(prb);
60
61 return s;
62}
63} // namespace lnorm
64