diff --git a/onnxruntime/core/providers/cpu/nn/layer_norm_impl.cc b/onnxruntime/core/providers/cpu/nn/layer_norm_impl.cc index 44e1ee9c078bf..2fb53e04f23e4 100644 --- a/onnxruntime/core/providers/cpu/nn/layer_norm_impl.cc +++ b/onnxruntime/core/providers/cpu/nn/layer_norm_impl.cc @@ -170,9 +170,9 @@ Status LayerNormImpl::ComputeImpl(OpKernelContext* p_ctx, int64_t orig_axis, flo } int output_index = 1; - Tensor* mean = p_ctx->Output(output_index++, TensorShape(mean_inv_std_dev_dim)); U* mean_data = nullptr; - if (mean != nullptr) { + if (!simplified) { + Tensor* mean = p_ctx->Output(output_index++, TensorShape(mean_inv_std_dev_dim)); mean_data = mean->MutableData(); }