Skip to content

Commit 6ba2b22

Browse files
authored
Merge pull request #13096 from JiabinYang/fix_mac
Fix Mac compile error
2 parents 9142213 + cceffca commit 6ba2b22

File tree

5 files changed

+20
-9
lines changed

5 files changed

+20
-9
lines changed

paddle/fluid/framework/ir/attention_lstm_fuse_pass.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,11 @@ void PrepareLSTMWeight(const LoDTensor& W_forget_w0,
216216

217217
float* out_data = out->mutable_data<float>(platform::CPUPlace());
218218
std::array<const float*, 4> tensors(
219-
{W_forget_w0.data<float>(), W_input_w0.data<float>(),
220-
W_output_w0.data<float>(), W_cell_w0.data<float>()});
219+
{{W_forget_w0.data<float>(), W_input_w0.data<float>(),
220+
W_output_w0.data<float>(), W_cell_w0.data<float>()}});
221221
std::array<const float*, 4> tensors1(
222-
{W_forget_w1.data<float>(), W_input_w1.data<float>(),
223-
W_output_w1.data<float>(), W_cell_w1.data<float>()});
222+
{{W_forget_w1.data<float>(), W_input_w1.data<float>(),
223+
W_output_w1.data<float>(), W_cell_w1.data<float>()}});
224224

225225
for (int row = 0; row < D; row++) {
226226
for (int col = 0; col < 4; col++) {
@@ -243,8 +243,8 @@ void PrepareLSTMBias(const LoDTensor& B_forget, const LoDTensor& B_input,
243243
const LoDTensor& B_output, const LoDTensor& B_cell,
244244
LoDTensor* out) {
245245
std::array<const float*, 4> tensors(
246-
{B_forget.data<float>(), B_input.data<float>(), B_output.data<float>(),
247-
B_cell.data<float>()});
246+
{{B_forget.data<float>(), B_input.data<float>(), B_output.data<float>(),
247+
B_cell.data<float>()}});
248248

249249
PADDLE_ENFORCE_EQ(B_forget.dims().size(), 1);
250250
int D = B_forget.dims()[0];

paddle/fluid/inference/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ get_property(fluid_modules GLOBAL PROPERTY FLUID_MODULES)
1717
# paddle_fluid_origin exclude inference api interface
1818
cc_library(paddle_fluid_origin DEPS ${fluid_modules} paddle_fluid_api)
1919

20-
if(NOT APPLE)
20+
#if(APPLE)
2121
add_subdirectory(api)
22-
endif()
22+
#endif()
2323

2424
# Create static library
2525
cc_library(paddle_fluid DEPS ${fluid_modules} paddle_fluid_api paddle_inference_api)

paddle/fluid/inference/analysis/argument.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct Argument {
6767
PADDLE_ENFORCE(!attrs_.count(key), "Duplicate set Argument's attr [%s]",
6868
key);
6969
attrs_[key] = data;
70-
attr_deleters_[key] = [data, key, this]() {
70+
attr_deleters_[key] = [data, key]() {
7171
VLOG(3) << "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
7272
VLOG(3) << "argument delete attr: " << key;
7373
delete data;

paddle/fluid/inference/api/api_impl.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,13 @@ std::unique_ptr<PaddlePredictor> NativePaddlePredictor::Clone() {
179179
LOG(ERROR) << "fail to call Init";
180180
return nullptr;
181181
}
182+
#ifdef __clang__
183+
// fix clang compile error
184+
return cls;
185+
#else
182186
// fix manylinux compile error.
183187
return std::move(cls);
188+
#endif
184189
}
185190

186191
bool NativePaddlePredictor::SetFeed(const std::vector<PaddleTensor> &inputs,
@@ -329,7 +334,12 @@ std::unique_ptr<PaddlePredictor> CreatePaddlePredictor<
329334
if (!dynamic_cast<NativePaddlePredictor *>(predictor.get())->Init(nullptr)) {
330335
return nullptr;
331336
}
337+
#ifdef __clang__
338+
// fix clang compile error
339+
return predictor;
340+
#else
332341
return std::move(predictor);
342+
#endif
333343
}
334344

335345
} // namespace paddle

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>

0 commit comments

Comments
 (0)