Skip to content

Commit

Permalink
verbose: rnn: make benchdnn and mkl verbose match
Browse files Browse the repository at this point in the history
  • Loading branch information
mgouicem committed Dec 20, 2018
1 parent 02e4271 commit e5a4607
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
1 change: 1 addition & 0 deletions include/mkldnn_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const char MKLDNN_API *mkldnn_fmt2str(mkldnn_memory_format_t v);
const char MKLDNN_API *mkldnn_prop_kind2str(mkldnn_prop_kind_t v);
const char MKLDNN_API *mkldnn_prim_kind2str(mkldnn_primitive_kind_t v);
const char MKLDNN_API *mkldnn_alg_kind2str(mkldnn_alg_kind_t v);
const char MKLDNN_API *mkldnn_rnn_direction2str(mkldnn_rnn_direction_t v);

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/generate_mkldnn_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def maybe_skip(enum):
'mkldnn_batch_normalization_flag_t',
'mkldnn_wino_memory_format_t',
'mkldnn_rnn_cell_flags_t',
'mkldnn_rnn_direction_t',
'mkldnn_engine_kind_t',
'mkldnn_query_t',
'mkldnn_stream_kind_t',
Expand All @@ -136,6 +135,7 @@ def enum_abbrev(enum):
'mkldnn_prop_kind_t': 'prop_kind',
'mkldnn_primitive_kind_t': 'prim_kind',
'mkldnn_alg_kind_t': 'alg_kind',
'mkldnn_rnn_direction_t': 'rnn_direction',
}.get(enum, enum)


Expand Down
16 changes: 13 additions & 3 deletions src/common/mkldnn_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@ const char *mkldnn_fmt2str(mkldnn_memory_format_t v) {
if (v == mkldnn_wio) return "wio";
if (v == mkldnn_oihw) return "oihw";
if (v == mkldnn_hwio) return "hwio";
if (v == mkldnn_iohw) return "iohw";
if (v == mkldnn_hwio_s8s8) return "hwio_s8s8";
if (v == mkldnn_ihwo) return "ihwo";
if (v == mkldnn_iohw) return "iohw";
if (v == mkldnn_oidhw) return "oidhw";
if (v == mkldnn_dhwio) return "dhwio";
if (v == mkldnn_goiw) return "goiw";
if (v == mkldnn_goihw) return "goihw";
if (v == mkldnn_hwigo) return "hwigo";
if (v == mkldnn_giohw) return "giohw";
if (v == mkldnn_hwigo_s8s8) return "hwigo_s8s8";
if (v == mkldnn_goidhw) return "goidhw";
if (v == mkldnn_ntc) return "ntc";
if (v == mkldnn_tnc) return "tnc";
Expand All @@ -105,6 +103,7 @@ const char *mkldnn_fmt2str(mkldnn_memory_format_t v) {
if (v == mkldnn_OIw8i16o2i) return "OIw8i16o2i";
if (v == mkldnn_OIw8o16i2o) return "OIw8o16i2o";
if (v == mkldnn_IOw16o16i) return "IOw16o16i";
if (v == mkldnn_hwio_s8s8) return "hwio_s8s8";
if (v == mkldnn_oIhw8i) return "oIhw8i";
if (v == mkldnn_oIhw16i) return "oIhw16i";
if (v == mkldnn_OIhw8i8o) return "OIhw8i8o";
Expand Down Expand Up @@ -141,6 +140,7 @@ const char *mkldnn_fmt2str(mkldnn_memory_format_t v) {
if (v == mkldnn_gOIw8i16o2i) return "gOIw8i16o2i";
if (v == mkldnn_gOIw8o16i2o) return "gOIw8o16i2o";
if (v == mkldnn_gIOw16o16i) return "gIOw16o16i";
if (v == mkldnn_hwigo_s8s8) return "hwigo_s8s8";
if (v == mkldnn_gOIhw8i8o) return "gOIhw8i8o";
if (v == mkldnn_gOIhw16i16o) return "gOIhw16i16o";
if (v == mkldnn_gOIhw4i16o4i) return "gOIhw4i16o4i";
Expand Down Expand Up @@ -239,4 +239,14 @@ const char *mkldnn_alg_kind2str(mkldnn_alg_kind_t v) {
return "unknown alg_kind";
}

const char *mkldnn_rnn_direction2str(mkldnn_rnn_direction_t v) {
if (v == mkldnn_unidirectional_left2right) return "unidirectional_left2right";
if (v == mkldnn_unidirectional_right2left) return "unidirectional_right2left";
if (v == mkldnn_bidirectional_concat) return "bidirectional_concat";
if (v == mkldnn_bidirectional_sum) return "bidirectional_sum";
if (v == mkldnn_unidirectional) return "unidirectional";
assert(!"unknown rnn_direction");
return "unknown rnn_direction";
}


19 changes: 13 additions & 6 deletions src/common/verbose.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,15 +300,22 @@ template <typename pd_t> static void init_info_softmax(pd_t *s, char *buffer) {
template <typename pd_t> static void init_info_rnn(pd_t *s, char *buffer) {
DECL_DAT_AUX_PRB_STRS();

alg_kind_t alg_kind = s->desc()->cell_desc.cell_kind;
auto fmt_src = (s->desc()->prop_kind == prop_kind::backward_data
? s->diff_src_pd() : s->src_pd())->desc()->format;
auto fmt_wei = (s->desc()->prop_kind == prop_kind::backward_weights
? s->diff_weights_pd(0) : s->weights_pd(0))->desc()->format;

alg_kind_t alg_kind = s->cell_kind();
rnn_direction_t rnn_dir = s->direction();
snprintf(aux_str, MKLDNN_VERBOSE_AUX_LEN,
"alg:%s", mkldnn_alg_kind2str(alg_kind));
"alg:%s_%s", mkldnn_alg_kind2str(alg_kind), mkldnn_rnn_direction2str(rnn_dir));
snprintf(dat_str, MKLDNN_VERBOSE_DAT_LEN, "fdata:%s fwei:%s",
mkldnn_fmt2str(fmt_src), mkldnn_fmt2str(fmt_wei));

snprintf(prb_str, MKLDNN_VERBOSE_PRB_LEN,
"l%dd%dmb%dt%d_ic%dsc%doc%d_wi%dws%d",
s->L(), s->D(), s->MB(), s->T(),
s->SLC(), s->DIC(), s->DIC(),
s->SLC(), s->SIC());
"l%dt%dmb%dsic%dslc%ddic%ddlc%d",
s->L(), s->T(), s->MB(),
s->SIC(), s->SLC(), s->DIC(), s->DLC());

verbose_templ(buffer, s->kind(), s->name(), s->desc()->prop_kind, dat_str,
aux_str, prb_str);
Expand Down

0 comments on commit e5a4607

Please sign in to comment.