Skip to content

Commit ef09862

Browse files
committed
fix analyzer_rnn2_test
test=develop
1 parent a831ecc commit ef09862

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ namespace paddle {
1818
namespace inference {
1919

2020
using namespace framework; // NOLINT
21+
static std::vector<float> result_data;
2122

2223
struct DataRecord {
2324
std::vector<std::vector<std::vector<float>>> link_step_data_all;
2425
std::vector<size_t> lod;
2526
std::vector<std::vector<float>> rnn_link_data;
26-
std::vector<float> result_data;
2727
size_t num_samples; // total number of samples
2828
size_t batch_iter{0};
2929
size_t batch_size{1};
@@ -57,6 +57,7 @@ struct DataRecord {
5757
std::ifstream file(path);
5858
std::string line;
5959
int num_lines = 0;
60+
result_data.clear();
6061
while (std::getline(file, line)) {
6162
num_lines++;
6263
std::vector<std::string> data;
@@ -135,13 +136,12 @@ TEST(Analyzer_rnn2, profile) {
135136

136137
if (FLAGS_num_threads == 1 && !FLAGS_test_all_data) {
137138
// the first inference result
138-
DataRecord data(FLAGS_infer_data, FLAGS_batch_size);
139139
PADDLE_ENFORCE_GT(outputs.size(), 0);
140140
size_t size = GetSize(outputs[0]);
141141
PADDLE_ENFORCE_GT(size, 0);
142142
float *result = static_cast<float *>(outputs[0].data.data());
143143
for (size_t i = 0; i < size; i++) {
144-
EXPECT_NEAR(result[i], data.result_data[i], 1e-3);
144+
EXPECT_NEAR(result[i], result_data[i], 1e-3);
145145
}
146146
}
147147
}

0 commit comments

Comments
 (0)