Skip to content

Commit d091dd0

Browse files
JiabinYangdzhwinter
authored andcommitted
fix mac compile error 0903 (#13184)
1 parent 2ef34c6 commit d091dd0

File tree

3 files changed

+17
-14
lines changed

3 files changed

+17
-14
lines changed

paddle/fluid/framework/ir/graph_pattern_detector.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,22 +339,22 @@ PDNode& PDNode::LinksFrom(const std::vector<PDNode*>& others) {
339339
}
340340

341341
PDNode* PDNode::assert_is_op() {
342-
asserts_.emplace_back([this](Node* x) { return x && x->IsOp(); });
342+
asserts_.emplace_back([](Node* x) { return x && x->IsOp(); });
343343
return this;
344344
}
345345
PDNode* PDNode::assert_is_op(const std::string& op_type) {
346-
asserts_.emplace_back([this, op_type](Node* x) {
346+
asserts_.emplace_back([op_type](Node* x) {
347347
return x && x->IsOp() && x->Op()->Type() == op_type;
348348
});
349349
return this;
350350
}
351351
PDNode* PDNode::assert_is_var() {
352-
asserts_.emplace_back([this](Node* x) { return x && x->IsVar(); });
352+
asserts_.emplace_back([](Node* x) { return x && x->IsVar(); });
353353
return this;
354354
}
355355
PDNode* PDNode::assert_var_not_persistable() {
356356
assert_is_var();
357-
asserts_.emplace_back([this](Node* x) { return !x->Var()->Persistable(); });
357+
asserts_.emplace_back([](Node* x) { return !x->Var()->Persistable(); });
358358
return this;
359359
}
360360
PDNode* PDNode::assert_is_persistable_var() {
@@ -496,14 +496,16 @@ void GraphSafeRemoveNodes(Graph* graph,
496496
for (auto it = node->inputs.begin(); it != node->inputs.end();) {
497497
if (nodes.count(*it)) {
498498
it = const_cast<Node*>(node)->inputs.erase(it);
499-
} else
499+
} else {
500500
it++;
501+
}
501502
}
502503
for (auto it = node->outputs.begin(); it != node->outputs.end();) {
503504
if (nodes.count(*it)) {
504505
it = const_cast<Node*>(node)->outputs.erase(it);
505-
} else
506+
} else {
506507
it++;
508+
}
507509
}
508510
}
509511
}

paddle/fluid/inference/api/helper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <sys/time.h>
1818
#include <algorithm>
19+
#include <numeric>
1920
#include <sstream>
2021
#include <string>
2122
#include <vector>

paddle/fluid/operators/gru_unit_op.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ class GRUUnitKernel : public framework::OpKernel<T> {
9292
gate_data, frame_size * 3);
9393

9494
// calculate activited gate
95-
Eigen::array<int, 2> extents = {batch_size, frame_size};
96-
Eigen::array<int, 2> u_offsets = {0, 0};
95+
Eigen::array<int, 2> extents{{batch_size, frame_size}};
96+
Eigen::array<int, 2> u_offsets{{0, 0}};
9797
ActCompute(context.Attr<int>("gate_activation"), place,
9898
g.slice(u_offsets, extents), g.slice(u_offsets, extents));
9999
auto u = g.slice(u_offsets, extents); // update gate
100-
Eigen::array<int, 2> r_offsets = {0, frame_size};
100+
Eigen::array<int, 2> r_offsets{{0, frame_size}};
101101
ActCompute(context.Attr<int>("gate_activation"), place,
102102
g.slice(r_offsets, extents), g.slice(r_offsets, extents));
103103
auto r = g.slice(r_offsets, extents); // reset gate
@@ -107,7 +107,7 @@ class GRUUnitKernel : public framework::OpKernel<T> {
107107
weight_data + frame_size * frame_size * 2, frame_size, 1,
108108
gate_data + frame_size * 2, frame_size * 3);
109109

110-
Eigen::array<int, 2> c_offsets = {0, frame_size * 2};
110+
Eigen::array<int, 2> c_offsets{{0, frame_size * 2}};
111111
ActCompute(context.Attr<int>("activation"), place,
112112
g.slice(c_offsets, extents), g.slice(c_offsets, extents));
113113
auto c = g.slice(c_offsets, extents); // output candidate
@@ -171,12 +171,12 @@ class GRUUnitGradKernel : public framework::OpKernel<T> {
171171
int batch_size = input->dims()[0];
172172
int frame_size = hidden_prev->dims()[1];
173173

174-
Eigen::array<int, 2> extents = {batch_size, frame_size};
175-
Eigen::array<int, 2> u_offsets = {0, 0};
174+
Eigen::array<int, 2> extents{{batch_size, frame_size}};
175+
Eigen::array<int, 2> u_offsets{{0, 0}};
176176
auto u = g.slice(u_offsets, extents); // update gate
177-
Eigen::array<int, 2> r_offsets = {0, frame_size};
177+
Eigen::array<int, 2> r_offsets{{0, frame_size}};
178178
auto r = g.slice(r_offsets, extents); // reset gate
179-
Eigen::array<int, 2> c_offsets = {0, frame_size * 2};
179+
Eigen::array<int, 2> c_offsets{{0, frame_size * 2}};
180180
auto c = g.slice(c_offsets, extents); // output candidate
181181

182182
// backward for unactivated update gate

0 commit comments

Comments
 (0)