Skip to content

Commit 7b86da7

Browse files
abhinavarorawangkuiyi
authored andcommitted
Fix CPPLint errors in operators (#9826)
* Fix CPPLint errors in operators * Fix cast in softmax * Fix softmax_mkldnn * Fix send_recv_op_test * Send_recv * Fix softmax mkldnn
1 parent f22da58 commit 7b86da7

16 files changed

+48
-33
lines changed

paddle/fluid/operators/scale_op.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#include "paddle/fluid/operators/scale_op.h"
16-
1716
#include <string>
1817

1918
namespace paddle {

paddle/fluid/operators/scatter_op.cu

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15-
#include "gather.cu.h"
15+
#include "paddle/fluid/operators/gather.cu.h"
1616
#include "paddle/fluid/operators/gather_op.h"
17-
#include "scatter.cu.h"
17+
#include "paddle/fluid/operators/scatter.cu.h"
18+
#include "paddle/fluid/operators/scatter_op.h"
1819

1920
namespace paddle {
2021
namespace operators {

paddle/fluid/operators/scatter_op.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#pragma once
16-
#include "gather.h"
1716
#include "paddle/fluid/framework/eigen.h"
1817
#include "paddle/fluid/framework/op_registry.h"
19-
#include "scatter.h"
18+
#include "paddle/fluid/operators/gather.h"
19+
#include "paddle/fluid/operators/scatter.h"
2020

2121
namespace paddle {
2222
namespace operators {

paddle/fluid/operators/scatter_test.cc

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,48 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#include "paddle/fluid/operators/scatter.h"
16-
#include "paddle/fluid/framework/ddim.h"
17-
#include "paddle/fluid/framework/tensor.h"
18-
#include "paddle/fluid/platform/place.h"
19-
2016
#include <gtest/gtest.h>
2117
#include <iostream>
2218
#include <string>
19+
#include "paddle/fluid/framework/ddim.h"
20+
#include "paddle/fluid/framework/tensor.h"
21+
#include "paddle/fluid/platform/place.h"
2322

2423
TEST(scatter, ScatterUpdate) {
25-
using namespace paddle::framework;
26-
using namespace paddle::platform;
27-
using namespace paddle::operators;
24+
// using namespace paddle::framework;
25+
// using namespace paddle::platform;
26+
// using namespace paddle::operators;
2827

29-
Tensor* src = new Tensor();
30-
Tensor* index = new Tensor();
31-
Tensor* output = new Tensor();
28+
paddle::framework::Tensor* src = new paddle::framework::Tensor();
29+
paddle::framework::Tensor* index = new paddle::framework::Tensor();
30+
paddle::framework::Tensor* output = new paddle::framework::Tensor();
3231

3332
float* p_src = nullptr;
3433
int* p_index = nullptr;
35-
p_src = src->mutable_data<float>(make_ddim({1, 4}), CPUPlace());
36-
p_index = index->mutable_data<int>(make_ddim({1}), CPUPlace());
34+
p_src = src->mutable_data<float>(paddle::framework::make_ddim({1, 4}),
35+
paddle::platform::CPUPlace());
36+
p_index = index->mutable_data<int>(paddle::framework::make_ddim({1}),
37+
paddle::platform::CPUPlace());
3738

38-
for (size_t i = 0; i < 4; ++i) p_src[i] = float(i);
39+
for (size_t i = 0; i < 4; ++i) p_src[i] = static_cast<float>(i);
3940
p_index[0] = 1;
4041

41-
float* p_output = output->mutable_data<float>(make_ddim({4, 4}), CPUPlace());
42+
float* p_output = output->mutable_data<float>(
43+
paddle::framework::make_ddim({4, 4}), paddle::platform::CPUPlace());
4244

4345
auto* cpu_place = new paddle::platform::CPUPlace();
4446
paddle::platform::CPUDeviceContext ctx(*cpu_place);
45-
ScatterAssign<float>(ctx, *src, *index, output);
47+
paddle::operators::ScatterAssign<float>(ctx, *src, *index, output);
4648

47-
for (size_t i = 0; i < 4; ++i) EXPECT_EQ(p_output[i], float(0));
48-
for (size_t i = 0; i < 4; ++i) EXPECT_EQ(output->data<float>()[i], float(0));
49-
for (size_t i = 4; i < 8; ++i) EXPECT_EQ(p_output[i], float(i - 4));
49+
for (size_t i = 0; i < 4; ++i) EXPECT_EQ(p_output[i], 0.0f);
50+
for (size_t i = 0; i < 4; ++i) EXPECT_EQ(output->data<float>()[i], 0.0f);
51+
for (size_t i = 4; i < 8; ++i) {
52+
EXPECT_EQ(p_output[i], static_cast<float>(i - 4));
53+
}
5054
for (size_t i = 4; i < 8; ++i)
51-
EXPECT_EQ(output->data<float>()[i], float(i - 4));
52-
for (size_t i = 8; i < 16; ++i) EXPECT_EQ(p_output[i], float(0));
53-
for (size_t i = 8; i < 16; ++i) EXPECT_EQ(output->data<float>()[i], float(0));
55+
EXPECT_EQ(output->data<float>()[i], static_cast<float>(i - 4));
56+
for (size_t i = 8; i < 16; ++i) EXPECT_EQ(p_output[i], 0.0f);
57+
for (size_t i = 8; i < 16; ++i) EXPECT_EQ(output->data<float>()[i], 0.0f);
5458

5559
delete src;
5660
delete index;

paddle/fluid/operators/send_barrier_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15+
#include <future> // NOLINT
1516
#include <ostream>
1617

1718
#include "paddle/fluid/framework/data_type.h"
1819
#include "paddle/fluid/framework/framework.pb.h"
1920
#include "paddle/fluid/framework/lod_tensor.h"
2021
#include "paddle/fluid/framework/op_registry.h"
2122

22-
#include <future>
2323
#include "paddle/fluid/operators/detail/grpc_client.h"
2424

2525
namespace paddle {

paddle/fluid/operators/send_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15-
#include <future>
15+
#include <future> // NOLINT
1616
#include <ostream>
1717

1818
#include "paddle/fluid/framework/data_type.h"

paddle/fluid/operators/send_recv_util.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

15+
#pragma once
16+
#include <string>
17+
1518
namespace paddle {
1619
namespace operators {
1720

paddle/fluid/operators/sequence_concat_op.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#pragma once
16+
#include <vector>
1617
#include "paddle/fluid/framework/op_registry.h"
1718
#include "paddle/fluid/operators/strided_memcpy.h"
1819

paddle/fluid/operators/sequence_conv_op.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#pragma once
16+
#include <algorithm>
1617
#include "paddle/fluid/framework/op_registry.h"
1718
#include "paddle/fluid/operators/math/context_project.h"
1819
#include "paddle/fluid/operators/math/math_function.h"

paddle/fluid/operators/sequence_erase_op.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License. */
1414

1515
#include "paddle/fluid/operators/sequence_erase_op.h"
16+
#include <vector>
1617

1718
namespace paddle {
1819
namespace operators {

0 commit comments

Comments
 (0)