Skip to content

Commit f457d5d

Browse files
authored
Fix more CPPLint errors (#10218)
* Fix more CPPLint issues * Fix more CPPLint issues * Fix more CPPLint issues * Fix CPPLint issues in operators/math and operators/reader
1 parent c4af8fa commit f457d5d

File tree

13 files changed

+79
-38
lines changed

13 files changed

+79
-38
lines changed

paddle/fluid/inference/tensorrt/engine.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License. */
1717
#include <NvInfer.h>
1818
#include <cuda.h>
1919
#include <glog/logging.h>
20+
#include <string>
2021
#include "paddle/fluid/inference/tensorrt/helper.h"
2122
#include "paddle/fluid/platform/enforce.h"
2223

paddle/fluid/operators/math/depthwise_conv.cu

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +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 <vector>
1516
#include "paddle/fluid/operators/math/depthwise_conv.h"
1617
#include "paddle/fluid/platform/cuda_helper.h"
1718

paddle/fluid/operators/math/depthwise_conv.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/tensor.h"
1718
#include "paddle/fluid/platform/device_context.h"
1819
#include "paddle/fluid/platform/hostdevice.h"

paddle/fluid/operators/math/detail/activation_functions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ limitations under the License. */
1414

1515
#pragma once
1616
#include <math.h>
17+
#include <string>
1718
#include "paddle/fluid/platform/enforce.h"
1819
#include "paddle/fluid/platform/hostdevice.h"
1920

paddle/fluid/operators/math/im2col_test.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ limitations under the License. */
1414

1515
#include "paddle/fluid/operators/math/im2col.h"
1616
#include <gtest/gtest.h>
17+
#include <vector>
1718

1819
template <typename DeviceContext, typename Place>
1920
void testIm2col() {

paddle/fluid/operators/math/matmul.h

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

1515
#pragma once
16+
#include <algorithm>
17+
#include <vector>
1618
#include "paddle/fluid/operators/math/math_function.h"
1719

1820
namespace paddle {

paddle/fluid/operators/math/sampler.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 "sampler.h"
15+
#include "paddle/fluid/operators/math/sampler.h"
1616

1717
namespace paddle {
1818
namespace random {

paddle/fluid/operators/math/selected_rows_functor_test.cc

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

1515
#include "paddle/fluid/operators/math/selected_rows_functor.h"
16+
#include <vector>
1617
#include "gtest/gtest.h"
1718
#include "paddle/fluid/operators/math/math_function.h"
1819

1920
TEST(selected_rows_functor, cpu_add) {
20-
using namespace paddle::framework;
21-
using namespace paddle::platform;
22-
using namespace paddle::operators::math;
23-
24-
CPUPlace cpu_place;
25-
CPUDeviceContext ctx(cpu_place);
26-
SetConstant<CPUDeviceContext, float> functor;
21+
paddle::platform::CPUPlace cpu_place;
22+
paddle::platform::CPUDeviceContext ctx(cpu_place);
23+
paddle::operators::math::SetConstant<paddle::platform::CPUDeviceContext,
24+
float>
25+
functor;
2726
int64_t height = 10;
2827
int64_t row_numel = 10;
2928

3029
std::vector<int64_t> rows1{0, 4, 7};
31-
std::unique_ptr<SelectedRows> selected_rows1{new SelectedRows(rows1, height)};
30+
std::unique_ptr<paddle::framework::SelectedRows> selected_rows1{
31+
new paddle::framework::SelectedRows(rows1, height)};
3232
auto* in1_value = selected_rows1->mutable_value();
3333
in1_value->mutable_data<float>(
34-
make_ddim({static_cast<int64_t>(rows1.size()), row_numel}), cpu_place);
34+
paddle::framework::make_ddim(
35+
{static_cast<int64_t>(rows1.size()), row_numel}),
36+
cpu_place);
3537
functor(ctx, in1_value, 1.0);
3638

3739
std::vector<int64_t> rows2{0, 5, 7, 9};
38-
std::unique_ptr<SelectedRows> selected_rows2{new SelectedRows(rows2, height)};
40+
std::unique_ptr<paddle::framework::SelectedRows> selected_rows2{
41+
new paddle::framework::SelectedRows(rows2, height)};
3942
auto* in2_value = selected_rows2->mutable_value();
4043
in2_value->mutable_data<float>(
41-
make_ddim({static_cast<int64_t>(rows2.size()), row_numel}), cpu_place);
44+
paddle::framework::make_ddim(
45+
{static_cast<int64_t>(rows2.size()), row_numel}),
46+
cpu_place);
4247
functor(ctx, in2_value, 2.0);
4348

44-
std::unique_ptr<SelectedRows> output{new SelectedRows()};
49+
std::unique_ptr<paddle::framework::SelectedRows> output{
50+
new paddle::framework::SelectedRows()};
4551
auto* out_value = output->mutable_value();
4652

4753
// simplely concat two SelectedRows
48-
out_value->mutable_data<float>(make_ddim({7, 10}), cpu_place);
54+
out_value->mutable_data<float>(paddle::framework::make_ddim({7, 10}),
55+
cpu_place);
4956

50-
SelectedRowsAdd<CPUDeviceContext, float> add_functor;
57+
paddle::operators::math::SelectedRowsAdd<paddle::platform::CPUDeviceContext,
58+
float>
59+
add_functor;
5160
add_functor(ctx, *selected_rows1, *selected_rows2, output.get());
5261

5362
auto out_height = output->height();
@@ -78,14 +87,20 @@ TEST(selected_rows_functor, cpu_add) {
7887
EXPECT_EQ(out_data[5 * row_numel + 7], 2.0);
7988
EXPECT_EQ(out_data[6 * row_numel + 9], 2.0);
8089

81-
std::unique_ptr<Tensor> tensor1{new Tensor()};
82-
tensor1->mutable_data<float>(make_ddim({height, row_numel}), cpu_place);
90+
std::unique_ptr<paddle::framework::Tensor> tensor1{
91+
new paddle::framework::Tensor()};
92+
tensor1->mutable_data<float>(
93+
paddle::framework::make_ddim({height, row_numel}), cpu_place);
8394
functor(ctx, tensor1.get(), 3.0);
8495

85-
std::unique_ptr<Tensor> tensor2{new Tensor()};
86-
tensor2->mutable_data<float>(make_ddim({height, row_numel}), cpu_place);
96+
std::unique_ptr<paddle::framework::Tensor> tensor2{
97+
new paddle::framework::Tensor()};
98+
tensor2->mutable_data<float>(
99+
paddle::framework::make_ddim({height, row_numel}), cpu_place);
87100

88-
SelectedRowsAddTensor<CPUDeviceContext, float> add_tensor_functor;
101+
paddle::operators::math::SelectedRowsAddTensor<
102+
paddle::platform::CPUDeviceContext, float>
103+
add_tensor_functor;
89104
add_tensor_functor(ctx, *output, *tensor1, tensor2.get());
90105

91106
auto* tensor2_data = tensor2->data<float>();
@@ -106,38 +121,46 @@ TEST(selected_rows_functor, cpu_add) {
106121
}
107122

108123
TEST(selected_rows_functor, cpu_add_to) {
109-
using namespace paddle::framework;
110-
using namespace paddle::platform;
111-
using namespace paddle::operators::math;
112-
113-
CPUPlace cpu_place;
114-
CPUDeviceContext ctx(cpu_place);
115-
SetConstant<CPUDeviceContext, float> functor;
124+
paddle::platform::CPUPlace cpu_place;
125+
paddle::platform::CPUDeviceContext ctx(cpu_place);
126+
paddle::operators::math::SetConstant<paddle::platform::CPUDeviceContext,
127+
float>
128+
functor;
116129
int64_t height = 10;
117130
int64_t row_numel = 10;
118131

119132
std::vector<int64_t> rows1{0, 4, 7};
120-
std::unique_ptr<SelectedRows> selected_rows1{new SelectedRows(rows1, height)};
133+
std::unique_ptr<paddle::framework::SelectedRows> selected_rows1{
134+
new paddle::framework::SelectedRows(rows1, height)};
121135
auto* in1_value = selected_rows1->mutable_value();
122136
in1_value->mutable_data<float>(
123-
make_ddim({static_cast<int64_t>(rows1.size()), row_numel}), cpu_place);
137+
paddle::framework::make_ddim(
138+
{static_cast<int64_t>(rows1.size()), row_numel}),
139+
cpu_place);
124140
functor(ctx, in1_value, 1.0);
125141

126142
std::vector<int64_t> rows2{0, 5, 7, 9};
127-
std::unique_ptr<SelectedRows> selected_rows2{new SelectedRows(rows2, height)};
143+
std::unique_ptr<paddle::framework::SelectedRows> selected_rows2{
144+
new paddle::framework::SelectedRows(rows2, height)};
128145
auto* in2_value = selected_rows2->mutable_value();
129146
in2_value->mutable_data<float>(
130-
make_ddim({static_cast<int64_t>(rows2.size()), row_numel}), cpu_place);
147+
paddle::framework::make_ddim(
148+
{static_cast<int64_t>(rows2.size()), row_numel}),
149+
cpu_place);
131150
functor(ctx, in2_value, 2.0);
132151

133-
std::unique_ptr<SelectedRows> output{new SelectedRows()};
152+
std::unique_ptr<paddle::framework::SelectedRows> output{
153+
new paddle::framework::SelectedRows()};
134154
output->set_height(height);
135155
auto* out_value = output->mutable_value();
136156

137157
// simplely concat two SelectedRows
138-
out_value->mutable_data<float>(make_ddim({7, 10}), cpu_place);
158+
out_value->mutable_data<float>(paddle::framework::make_ddim({7, 10}),
159+
cpu_place);
139160

140-
SelectedRowsAddTo<CPUDeviceContext, float> add_to_functor;
161+
paddle::operators::math::SelectedRowsAddTo<paddle::platform::CPUDeviceContext,
162+
float>
163+
add_to_functor;
141164
add_to_functor(ctx, *selected_rows1, 0, output.get());
142165
add_to_functor(ctx, *selected_rows2, in1_value->numel(), output.get());
143166

@@ -169,11 +192,15 @@ TEST(selected_rows_functor, cpu_add_to) {
169192
EXPECT_EQ(out_data[5 * row_numel + 7], 2.0);
170193
EXPECT_EQ(out_data[6 * row_numel + 9], 2.0);
171194

172-
std::unique_ptr<Tensor> tensor1{new Tensor()};
173-
tensor1->mutable_data<float>(make_ddim({height, row_numel}), cpu_place);
195+
std::unique_ptr<paddle::framework::Tensor> tensor1{
196+
new paddle::framework::Tensor()};
197+
tensor1->mutable_data<float>(
198+
paddle::framework::make_ddim({height, row_numel}), cpu_place);
174199
functor(ctx, tensor1.get(), 3.0);
175200

176-
SelectedRowsAddToTensor<CPUDeviceContext, float> add_to_tensor_functor;
201+
paddle::operators::math::SelectedRowsAddToTensor<
202+
paddle::platform::CPUDeviceContext, float>
203+
add_to_tensor_functor;
177204
add_to_tensor_functor(ctx, *output, tensor1.get());
178205

179206
auto* tensor1_data = tensor1->data<float>();

paddle/fluid/operators/math/sequence_pooling.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/math/sequence_pooling.h"
16+
#include <string>
1617
#include "paddle/fluid/operators/math/math_function.h"
1718

1819
namespace paddle {

paddle/fluid/operators/math/vol2col.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/math/vol2col.h"
16+
#include <vector>
1617

1718
namespace paddle {
1819
namespace operators {

0 commit comments

Comments
 (0)