1 /*******************************************************************************
2 * Copyright 2017-2018 Intel Corporation
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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 *******************************************************************************/
17 #include "mkldnn_debug.hpp"
18 #include "reorder/reorder.hpp"
20 #define DPRINT(...) do { \
21 int l = snprintf(buffer, rem_len, __VA_ARGS__); \
22 buffer += l; rem_len -= l; \
27 dims_t str2dims(const char *str) {
31 int scan = sscanf(str, "%d%n", &dim, &len);
32 SAFE_V(scan == 1 ? OK : FAIL);
35 SAFE_V(*str == 'x' || *str == '\0' ? OK : FAIL);
36 } while (*str++ != '\0');
40 void dims2str(const dims_t &dims, char *buffer) {
41 int rem_len = max_dims_len;
42 for (size_t d = 0; d < dims.size() - 1; ++d)
43 DPRINT("%tdx", dims[d]);
44 DPRINT("%td", dims[dims.size() - 1]);
47 void prb2str(const prb_t *p, const res_t *res, char *buffer) {
48 char dims_buf[max_dims_len] = {0};
49 dims2str(p->reorder.dims, dims_buf);
51 char attr_buf[max_attr_len] = {0};
52 bool is_attr_def = p->attr.is_def();
54 int len = snprintf(attr_buf, max_attr_len, "--attr=\"");
55 SAFE_V(len >= 0 ? OK : FAIL);
56 attr2str(&p->attr, attr_buf + len);
57 len = (int)strnlen(attr_buf, max_attr_len);
58 snprintf(attr_buf + len, max_attr_len - len, "\" ");
61 int rem_len = max_prb_len;
62 DPRINT("--idt=%s --odt=%s --ifmt=%s --ofmt=%s %s%s",
63 dt2str(cfg2dt(p->conf_in)), dt2str(cfg2dt(p->conf_out)),
64 fmt2str(p->reorder.fmt_in), fmt2str(p->reorder.fmt_out),