Skip to content

Commit 8cbb3c0

Browse files
committed
refine lac ut and fix fetch
1 parent 620392e commit 8cbb3c0

File tree

2 files changed

+1
-29
lines changed

2 files changed

+1
-29
lines changed

paddle/fluid/inference/api/api_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ void NativePaddlePredictor::GetFetchOne(const framework::LoDTensor &fetch,
262262
if (buffer.empty() || buffer.length() < sizeof(T) * data.size()) {
263263
buffer.Resize(sizeof(T) * data.size());
264264
}
265-
std::memcpy(buffer.data(), data.data(), buffer.length());
265+
std::memcpy(buffer.data(), data.data(), sizeof(T) * data.size());
266266
// copy LoD
267267
for (const auto &level : fetch.lod()) {
268268
output->lod.emplace_back(level);

paddle/fluid/inference/tests/api/analyzer_lac_tester.cc

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -117,34 +117,6 @@ void GetOneBatch(std::vector<PaddleTensor> *input_slots, DataRecord *data,
117117
input_slots->assign({input_tensor});
118118
}
119119

120-
void BenchAllData(const std::string &model_path, const std::string &data_file,
121-
const int batch_size, const int repeat) {
122-
NativeConfig config;
123-
config.model_dir = model_path;
124-
config.use_gpu = false;
125-
config.device = 0;
126-
config.specify_input_name = true;
127-
std::vector<PaddleTensor> input_slots, outputs_slots;
128-
DataRecord data(data_file, batch_size);
129-
auto predictor =
130-
CreatePaddlePredictor<NativeConfig, PaddleEngineKind::kNative>(config);
131-
GetOneBatch(&input_slots, &data, batch_size);
132-
for (int i = 0; i < FLAGS_burning; i++) {
133-
predictor->Run(input_slots, &outputs_slots);
134-
}
135-
Timer timer;
136-
double sum = 0;
137-
for (int i = 0; i < repeat; i++) {
138-
for (size_t bid = 0; bid < data.batched_datas.size(); ++bid) {
139-
GetOneBatch(&input_slots, &data, batch_size);
140-
timer.tic();
141-
predictor->Run(input_slots, &outputs_slots);
142-
sum += timer.toc();
143-
}
144-
}
145-
PrintTime(batch_size, repeat, 1, 0, sum / repeat);
146-
}
147-
148120
const int64_t lac_ref_data[] = {24, 25, 25, 25, 38, 30, 31, 14, 15, 44, 24, 25,
149121
25, 25, 25, 25, 44, 24, 25, 25, 25, 36, 42, 43,
150122
44, 14, 15, 44, 14, 15, 44, 14, 15, 44, 38, 39,

0 commit comments

Comments
 (0)