From ceb31d30f0d0766d27cef928aa5629bc5c92e474 Mon Sep 17 00:00:00 2001 From: dengkaipeng Date: Tue, 26 Mar 2019 10:10:03 +0800 Subject: [PATCH] fix formax. test=develop --- paddle/fluid/operators/softmax_with_cross_entropy_op.h | 2 +- paddle/fluid/operators/warpctc_cudnn_op.cu.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/paddle/fluid/operators/softmax_with_cross_entropy_op.h b/paddle/fluid/operators/softmax_with_cross_entropy_op.h index 2220d77e8a2..1042cbdcf5e 100644 --- a/paddle/fluid/operators/softmax_with_cross_entropy_op.h +++ b/paddle/fluid/operators/softmax_with_cross_entropy_op.h @@ -40,7 +40,7 @@ class SoftmaxWithCrossEntropyKernel : public framework::OpKernel { softmax->mutable_data(context.GetPlace()); loss->mutable_data(context.GetPlace()); - int axis_dim = logits->dims()[logits->dims().size()-1]; + int axis_dim = logits->dims()[logits->dims().size() - 1]; auto& dev_ctx = context.template device_context(); diff --git a/paddle/fluid/operators/warpctc_cudnn_op.cu.cc b/paddle/fluid/operators/warpctc_cudnn_op.cu.cc index 8d97396fdae..2a744f66f1c 100644 --- a/paddle/fluid/operators/warpctc_cudnn_op.cu.cc +++ b/paddle/fluid/operators/warpctc_cudnn_op.cu.cc @@ -67,9 +67,10 @@ class CudnnCTCKernel : public framework::OpKernel { softmax_logits.mutable_data(logits->dims(), ctx.GetPlace()); softmax_logits.set_lod(logits_lod); int rank = logits->dims().size(); + int axis_dim = logits->dims()[rank - 1]; Tensor in_2d = framework::ReshapeToMatrix(*logits, rank - 1); Tensor out_2d = framework::ReshapeToMatrix(softmax_logits, rank - 1); - math::SoftmaxFunctor()(dev_ctx, -1, &in_2d, + math::SoftmaxFunctor()(dev_ctx, axis_dim, &in_2d, &out_2d); // ctc needs sequences data stored in transposed padding format -- GitLab