Skip to content

Commit

Permalink
fix the if condition for LayerNorm (apache#15094)
Browse files Browse the repository at this point in the history
  • Loading branch information
TaoLv authored and haohuw committed Jun 23, 2019
1 parent 32f176e commit 7b4dd4b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/operator/nn/layer_norm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ void LayerNormComputeMKL(const nnvm::NodeAttrs& attrs,
CHECK_EQ(inputs.size(), 3U);
int axis = GetRealAxis(param.axis, inputs[0].ndim());

if (axis == (inputs[layernorm::kData].ndim() - 1) ||
(inputs[0].type_flag_ != kFloat32 && inputs[0].type_flag_ != kFloat64)) {
// This optimization only applys for LayerNorm on the last dimension with dtype FP32 or FP64.
if (axis == (inputs[layernorm::kData].ndim() - 1) &&
(inputs[0].type_flag_ == kFloat32 || inputs[0].type_flag_ == kFloat64)) {
// Compute necessary data for the reduce operation.
mxnet::TShape red_src_shape, red_dst_shape;
BroadcastReduceShapeCompact(inputs[layernorm::kData].shape_, outputs[layernorm::kMean].shape_,
Expand Down

0 comments on commit 7b4dd4b

Please sign in to comment.