diff --git a/paddle/fluid/operators/softmax_with_cross_entropy_op.h b/paddle/fluid/operators/softmax_with_cross_entropy_op.h index 2220d77e8a269d5e9136de0fba61cec19a9c3a0d..1042cbdcf5e96f0dd3780793cf1f233dc32c3eec 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 8d97396fdae56748054036bfaf3882e7e402ab47..2a744f66f1cef8090ae433270be5e5fede0eaa38 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