Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ pash = 'pash'
unpacket = "unpacket"

# These words need to be fixed
fetchs = 'fetchs'
Indexs = 'Indexs'
indexs = 'indexs'
Infered = 'Infered'
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/inference/api/analysis_predictor.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class AnalysisPredictor : public PaddlePredictor {
/// \param[out] output_data output tensor
///
template <typename T>
void GetFetchOne(const phi::DenseTensor &fetchs, PaddleTensor *output_data);
void GetFetchOne(const phi::DenseTensor &fetches, PaddleTensor *output_data);
///
/// \brief PreSet for Mkldnn multi-thread and dynamic shape input.
///
Expand Down
14 changes: 7 additions & 7 deletions paddle/fluid/inference/api/api_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ void NativePaddlePredictor::PrepareFeedFetch() {
feed_names_[op->Output("Out")[0]] = idx;
} else if (op->Type() == "fetch") {
int idx = PADDLE_GET_CONST(int, op->GetAttr("col"));
if (fetchs_.size() <= static_cast<size_t>(idx)) {
fetchs_.resize(idx + 1);
if (fetches_.size() <= static_cast<size_t>(idx)) {
fetches_.resize(idx + 1);
}
fetchs_[idx] = op;
fetches_[idx] = op;
}
}
}
Expand Down Expand Up @@ -319,9 +319,9 @@ void NativePaddlePredictor::GetFetchOne(const phi::DenseTensor &fetch,
bool NativePaddlePredictor::GetFetch(std::vector<PaddleTensor> *outputs,
framework::Scope *scope) {
VLOG(3) << "Predictor::get_fetch";
outputs->resize(fetchs_.size());
for (size_t i = 0; i < fetchs_.size(); ++i) {
int idx = PADDLE_GET_CONST(int, fetchs_[i]->GetAttr("col"));
outputs->resize(fetches_.size());
for (size_t i = 0; i < fetches_.size(); ++i) {
int idx = PADDLE_GET_CONST(int, fetches_[i]->GetAttr("col"));
PADDLE_ENFORCE_EQ(
static_cast<size_t>(idx),
i,
Expand All @@ -334,7 +334,7 @@ bool NativePaddlePredictor::GetFetch(std::vector<PaddleTensor> *outputs,
auto fetch = PADDLE_GET_CONST(phi::DenseTensor, fetch_var);
auto type = framework::TransToProtoVarType(fetch.dtype());
auto output = &(outputs->at(i));
output->name = fetchs_[idx]->Input("X")[0];
output->name = fetches_[idx]->Input("X")[0];
if (type == framework::DataTypeTrait<float>::DataType()) {
GetFetchOne<float>(fetch, output);
output->dtype = PaddleDType::FLOAT32;
Expand Down
4 changes: 2 additions & 2 deletions paddle/fluid/inference/api/api_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class NativePaddlePredictor : public PaddlePredictor {
bool GetFetch(std::vector<PaddleTensor> *output_data,
framework::Scope *scope);
template <typename T>
void GetFetchOne(const phi::DenseTensor &fetchs, PaddleTensor *output_data);
void GetFetchOne(const phi::DenseTensor &fetches, PaddleTensor *output_data);
void PrepareFeedFetch();

NativeConfig config_;
Expand All @@ -74,7 +74,7 @@ class NativePaddlePredictor : public PaddlePredictor {
std::unique_ptr<framework::ProgramDesc> inference_program_;
std::vector<framework::OpDesc *> feeds_;
std::map<std::string, size_t> feed_names_;
std::vector<framework::OpDesc *> fetchs_;
std::vector<framework::OpDesc *> fetches_;
// Memory buffer for feed inputs. The temporary DenseTensor will cause serious
// concurrency problems, wrong results and memory leak, so cache them.
std::vector<phi::DenseTensor> feed_tensors_;
Expand Down
12 changes: 6 additions & 6 deletions test/cpp/inference/api/api_impl_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ void MainWord2Vec(const ::paddle::PaddlePlace& place) {
cpu_feeds.push_back(&fourth_word);

framework::FetchType output1;
std::vector<::paddle::framework::FetchType*> cpu_fetchs1;
cpu_fetchs1.push_back(&output1);
std::vector<::paddle::framework::FetchType*> cpu_fetches1;
cpu_fetches1.push_back(&output1);

TestInference<phi::CPUPlace>(config.model_dir, cpu_feeds, cpu_fetchs1);
TestInference<phi::CPUPlace>(config.model_dir, cpu_feeds, cpu_fetches1);

auto output1_tensor = PADDLE_GET(phi::DenseTensor, output1);
float* lod_data = output1_tensor.data<float>();
Expand Down Expand Up @@ -142,11 +142,11 @@ void MainImageClassification(const ::paddle::PaddlePlace& place) {
cpu_feeds.push_back(&input);

framework::FetchType output1;
std::vector<framework::FetchType*> cpu_fetchs1;
cpu_fetchs1.push_back(&output1);
std::vector<framework::FetchType*> cpu_fetches1;
cpu_fetches1.push_back(&output1);

TestInference<phi::CPUPlace, false, true>(
config.model_dir, cpu_feeds, cpu_fetchs1, repeat, is_combined);
config.model_dir, cpu_feeds, cpu_fetches1, repeat, is_combined);

auto predictor = CreatePaddlePredictor(config);
std::vector<PaddleTensor> paddle_tensor_feeds;
Expand Down
13 changes: 7 additions & 6 deletions test/cpp/inference/test_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ std::vector<std::vector<int64_t>> GetFeedTargetShapes(
}

template <typename Place, bool CreateVars = true, bool PrepareContext = false>
void TestInference(const std::string& dirname,
const std::vector<phi::DenseTensor*>& cpu_feeds,
const std::vector<paddle::framework::FetchType*>& cpu_fetchs,
const int repeat = 1,
const bool is_combined = false) {
void TestInference(
const std::string& dirname,
const std::vector<phi::DenseTensor*>& cpu_feeds,
const std::vector<paddle::framework::FetchType*>& cpu_fetches,
const int repeat = 1,
const bool is_combined = false) {
// 1. Define place, executor, scope
auto place = Place();
auto executor = paddle::framework::Executor(place);
Expand Down Expand Up @@ -231,7 +232,7 @@ void TestInference(const std::string& dirname,
// 5. Define Tensor to get the outputs: set up maps for fetch targets
std::map<std::string, paddle::framework::FetchType*> fetch_targets;
for (size_t i = 0; i < fetch_target_names.size(); ++i) {
fetch_targets[fetch_target_names[i]] = cpu_fetchs[i];
fetch_targets[fetch_target_names[i]] = cpu_fetches[i];
}

// 6. If export Flags_use_mkldnn=True, use onednn related ops.
Expand Down
4 changes: 2 additions & 2 deletions test/deprecated/ir/pass_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def check_output_with_place(self, place, startup_on_cpu=False, atol=1e-5):
outs, lods = self._run_program(executor, self.main_program)
self.assertTrue(
len(self.fetch_list) == len(outs),
f"Checking the number of fetchs failed. Expected: {len(self.fetch_list)}, Received: {len(outs)}",
f"Checking the number of fetches failed. Expected: {len(self.fetch_list)}, Received: {len(outs)}",
)

# Parameters may be changed in ir passes.
Expand All @@ -154,7 +154,7 @@ def check_output_with_place(self, place, startup_on_cpu=False, atol=1e-5):
outs_opt, lods_opt = self._run_program(executor, opt_program)
self.assertTrue(
len(self.fetch_list) == len(outs_opt),
f"Checking the number of fetchs failed. Expected: {len(self.fetch_list)}, Received: {len(outs_opt)}",
f"Checking the number of fetches failed. Expected: {len(self.fetch_list)}, Received: {len(outs_opt)}",
)
for i in range(len(self.fetch_list)):
is_allclose = np.allclose(outs_opt[i], outs[i], atol=atol)
Expand Down
4 changes: 2 additions & 2 deletions test/ir/pass_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def check_output_with_place(self, place, startup_on_cpu=False, atol=1e-5):
outs, lods = self._run_program(executor, self.main_program)
self.assertTrue(
len(self.fetch_list) == len(outs),
f"Checking the number of fetchs failed. Expected: {len(self.fetch_list)}, Received: {len(outs)}",
f"Checking the number of fetches failed. Expected: {len(self.fetch_list)}, Received: {len(outs)}",
)

# Parameters may be changed in ir passes.
Expand All @@ -154,7 +154,7 @@ def check_output_with_place(self, place, startup_on_cpu=False, atol=1e-5):
outs_opt, lods_opt = self._run_program(executor, opt_program)
self.assertTrue(
len(self.fetch_list) == len(outs_opt),
f"Checking the number of fetchs failed. Expected: {len(self.fetch_list)}, Received: {len(outs_opt)}",
f"Checking the number of fetches failed. Expected: {len(self.fetch_list)}, Received: {len(outs_opt)}",
)
for i in range(len(self.fetch_list)):
is_allclose = np.allclose(outs_opt[i], outs[i], atol=atol)
Expand Down
Loading