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 *******************************************************************************/
25 #include "mkldnn_common.hpp"
26 #include "mkldnn_memory.hpp"
28 #include "conv/conv.hpp"
32 /* global driver parameters */
33 const dt_conf_t *cfg = conf_f32;
34 const char *pattern = NULL;
39 const char *skip_impl = "";
40 bool allow_unimpl = false;
41 const char *perf_template = "perf,%n,%d,%GO,%GF,%-t,%-Gp,%0t,%0Gp";
43 void reset_parameters() {
54 void check_correctness(const desc_t *c) {
55 const prb_t p(*c, dir, cfg, alg, attr, mb);
56 char pstr[max_prb_len];
59 if (pattern && !match_regex(pstr, pattern))
61 print(1, "run: %s\n", pstr);
64 const int status = conv::doit(&p, &res);
67 bool want_perf_report = false;
69 parse_result(res, want_perf_report, allow_unimpl, status, pstr);
71 if (want_perf_report && bench_mode & PERF)
72 perf_report(&p, &res, pstr);
74 benchdnn_stat.tests++;
77 int bench(int argc, char **argv, bool main_bench) {
78 for (int arg = 0; arg < argc; ++arg) {
79 if (!strncmp("--batch=", argv[arg], 8))
80 SAFE(batch(argv[arg] + 8, bench), CRIT);
81 else if (!strncmp("--cfg=", argv[arg], 6))
82 cfg = str2cfg(argv[arg] + 6);
83 else if (!strncmp("--match=", argv[arg], 8))
84 pattern = argv[arg] + 8;
85 else if (!strncmp("--mb=", argv[arg], 5))
86 mb = atoi(argv[arg] + 5);
87 else if (!strncmp("--dir=", argv[arg], 6))
88 dir = str2dir(argv[arg] + 6);
89 else if (!strncmp("--alg=", argv[arg], 6))
90 alg = str2alg(argv[arg] + 6);
91 else if (!strncmp("--attr=", argv[arg], 7))
92 SAFE(str2attr(&attr, argv[arg] + 7), CRIT);
93 else if (!strncmp("--skip-impl=", argv[arg], 12))
94 skip_impl = argv[arg] + 12;
95 else if (!strncmp("--allow-unimpl=", argv[arg], 15))
96 allow_unimpl = str2bool(argv[arg] + 15);
97 else if (!strncmp("--perf-template=", argv[arg], 16))
98 perf_template = argv[arg] + 16;
99 else if (!strcmp("--reset", argv[arg]))
101 else if (!strncmp("--mode=", argv[arg], 7))
102 bench_mode = str2bench_mode(argv[arg] + 7);
103 else if (!strncmp("-v", argv[arg], 2))
104 verbose = atoi(argv[arg] + 2);
105 else if (!strncmp("--verbose=", argv[arg], 10))
106 verbose = atoi(argv[arg] + 10);
110 if (str2desc(&c, argv[arg], is_deconv) == FAIL) {
111 fprintf(stderr, "driver: unknown option: `%s`, exiting...\n",
115 check_correctness(&c);