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

Fix the condition check in LayerNorm #15094

Merged
merged 2 commits into from
May 30, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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