@@ -31,10 +31,10 @@ class SoftmaxWithCrossEntropyKernel : public framework::OpKernel<T> {
31
31
PADDLE_ENFORCE_EQ (
32
32
platform::is_cpu_place (context.GetPlace ()), true ,
33
33
platform::errors::Unimplemented (" This kernel only runs on CPU." ));
34
- const bool softmax_switch = context.Attr <bool >(" softmax_switch " );
34
+ const bool use_softmax = context.Attr <bool >(" use_softmax " );
35
35
36
36
// do not with softmax op, and input is softmax
37
- if (!softmax_switch ) {
37
+ if (!use_softmax ) {
38
38
const Tensor* softmax = context.Input <Tensor>(" Logits" );
39
39
const Tensor* labels = context.Input <Tensor>(" Label" );
40
40
Tensor* softmax_out = context.Output <Tensor>(" Softmax" );
@@ -113,9 +113,9 @@ class SoftmaxWithCrossEntropyGradKernel : public framework::OpKernel<T> {
113
113
context.Output <Tensor>(framework::GradVarName (" Logits" ));
114
114
115
115
const Tensor* softmax = context.Input <Tensor>(" Softmax" );
116
- const bool softmax_switch = context.Attr <bool >(" softmax_switch " );
116
+ const bool use_softmax = context.Attr <bool >(" use_softmax " );
117
117
118
- if (logit_grad != softmax || !softmax_switch ) {
118
+ if (logit_grad != softmax || !use_softmax ) {
119
119
framework::TensorCopy (*softmax, context.GetPlace (),
120
120
context.device_context (), logit_grad);
121
121
}
@@ -138,8 +138,8 @@ class SoftmaxWithCrossEntropyGradKernel : public framework::OpKernel<T> {
138
138
auto logit_grad_mat = framework::EigenMatrix<T>::From (logit_grad_2d);
139
139
auto & place = *context.template device_context <platform::CPUDeviceContext>()
140
140
.eigen_device ();
141
- if (!softmax_switch ) {
142
- // softmax_switch step1
141
+ if (!use_softmax ) {
142
+ // use_softmax step1
143
143
if (soft_label) {
144
144
auto lbl_mat = framework::EigenMatrix<T>::From (labels_2d);
145
145
logit_grad_mat.device (place) =
@@ -148,7 +148,7 @@ class SoftmaxWithCrossEntropyGradKernel : public framework::OpKernel<T> {
148
148
out_grad_mat.broadcast (Eigen::DSizes<int , 2 >(1 , axis_dim)) *
149
149
logit_grad_mat;
150
150
}
151
- // softmax_switch step2
151
+ // use_softmax step2
152
152
else {
153
153
const int64_t * label_data = labels->data <int64_t >();
154
154
T* logit_grad_data = logit_grad->data <T>();
@@ -181,7 +181,7 @@ class SoftmaxWithCrossEntropyGradKernel : public framework::OpKernel<T> {
181
181
return ;
182
182
}
183
183
184
- // for softmax_switch =False, continue
184
+ // for use_softmax =False, continue
185
185
186
186
if (soft_label) {
187
187
// when soft_label = True, ignore_index is not supported
0 commit comments