Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix the if condition for LayerNorm (#15094)
Browse files Browse the repository at this point in the history
  • Loading branch information
TaoLv authored and eric-haibin-lin committed May 30, 2019
1 parent e9a5a0a commit 6b8e107
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 6b8e107

Please sign in to comment.