Skip to content

Commit

Permalink
src: common: lnorm: work around for msvc compiler bug
Browse files Browse the repository at this point in the history
  • Loading branch information
dzarukin committed Jun 18, 2024
1 parent 060df4e commit 4ccc6d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/common/layer_normalization_pd.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,19 @@ struct layer_normalization_fwd_pd_t : public layer_normalization_pd_t {
return 1 + 2 * stats_are_src() + use_scale() + use_shift()
+ n_binary_po_inputs();
}

// Work around for MSVC 19.40.33811 which over-optimizes the expression and
// would make `n_training_outs` return `0` even when both functions return `1`.
#if defined(_MSC_VER)
#pragma optimize("", off)
#endif
int n_outputs() const override {
return 1 + 2 * (!stats_are_src()) * is_training();
int n_training_outs = 2 * (!stats_are_src()) * is_training();
return 1 + n_training_outs;
}
#if defined(_MSC_VER)
#pragma optimize("", on)
#endif

protected:
memory_desc_t dst_md_;
Expand Down

0 comments on commit 4ccc6d2

Please sign in to comment.