Skip to content

Commit 943e4de

Browse files
authored
Merge pull request #13750 from panyx0718/fix
clean unused code and small optimize
2 parents 25262ed + d2079b1 commit 943e4de

File tree

3 files changed

+6
-30
lines changed

3 files changed

+6
-30
lines changed

paddle/fluid/framework/operator.cc

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,13 @@ class RuntimeInferShapeContext : public InferShapeContext {
544544

545545
void ShareLoD(const std::string& in, const std::string& out, size_t i = 0,
546546
size_t j = 0) const override {
547-
PADDLE_ENFORCE_LT(i, Inputs(in).size());
548-
PADDLE_ENFORCE_LT(j, Outputs(out).size());
549-
Variable* in_var = scope_.FindVar(Inputs(in)[i]);
550-
Variable* out_var = scope_.FindVar(Outputs(out)[j]);
547+
const std::vector<std::string>& inputs = Inputs(in);
548+
const std::vector<std::string>& outputs = Outputs(out);
549+
PADDLE_ENFORCE_LT(i, inputs.size());
550+
PADDLE_ENFORCE_LT(j, outputs.size());
551+
Variable* in_var = scope_.FindVar(inputs.at(i));
551552
if (!in_var->IsType<LoDTensor>()) return;
553+
Variable* out_var = scope_.FindVar(outputs.at(j));
552554
PADDLE_ENFORCE(out_var->IsType<LoDTensor>(),
553555
"The %d-th output of Output(%s) must be LoDTensor.", j, out);
554556
auto in_tensor = in_var->Get<LoDTensor>();
@@ -576,20 +578,6 @@ class RuntimeInferShapeContext : public InferShapeContext {
576578
out_tensor->set_layout(in_tensor.layout());
577579
}
578580

579-
void ShareLayout(const std::string& in, const std::string& out, size_t i = 0,
580-
size_t j = 0) const {
581-
PADDLE_ENFORCE_LT(i, Inputs(in).size());
582-
PADDLE_ENFORCE_LT(j, Outputs(out).size());
583-
Variable* in_var = scope_.FindVar(Inputs(in)[i]);
584-
Variable* out_var = scope_.FindVar(Outputs(out)[j]);
585-
if (!in_var->IsType<LoDTensor>()) return;
586-
PADDLE_ENFORCE(out_var->IsType<LoDTensor>(),
587-
"The %d-th output of Output(%s) must be LoDTensor.", j, out);
588-
auto in_tensor = in_var->Get<LoDTensor>();
589-
auto* out_tensor = out_var->GetMutable<LoDTensor>();
590-
out_tensor->set_layout(in_tensor.layout());
591-
}
592-
593581
bool IsRuntime() const override { return true; }
594582

595583
protected:

paddle/fluid/framework/shape_inference.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,6 @@ std::vector<DDim> InferShapeContext::GetReaderDims(
4646
return this->GetRepeatedDims(arg_names[0]);
4747
}
4848

49-
void InferShapeContext::ShareLoDs(const std::string &in,
50-
const std::string &out) const {
51-
PADDLE_ENFORCE_EQ(Inputs(in).size(), Outputs(out).size(),
52-
"The number of arguments in %s and %s is not equal.", in,
53-
out);
54-
for (size_t i = 0; i < in.size(); ++i) {
55-
ShareLoD(in, out, i, i);
56-
}
57-
}
58-
5949
DDim InferShapeContext::GetInputsElementDim(const std::string &name,
6050
int idx) const {
6151
const std::vector<std::string> &names = Inputs(name);

paddle/fluid/framework/shape_inference.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ class InferShapeContext {
5656
virtual const std::vector<std::string> &Outputs(
5757
const std::string &name) const = 0;
5858

59-
void ShareLoDs(const std::string &in, const std::string &out) const;
60-
6159
virtual void ShareLoD(const std::string &in, const std::string &out,
6260
size_t i = 0, size_t j = 0) const = 0;
6361

0 commit comments

Comments
 (0)