未验证 提交 22f14e74 编写于 作者: A Aurelius84 提交者: GitHub

Add const in GetInput/OutputVarPtrs in InferShapeContext (#38066)

上级 f44add7b
...@@ -216,13 +216,13 @@ class EagerInferShapeContext : public paddle::framework::InferShapeContext { ...@@ -216,13 +216,13 @@ class EagerInferShapeContext : public paddle::framework::InferShapeContext {
// TODO(paddle-dev): Can this be template? // TODO(paddle-dev): Can this be template?
std::vector<paddle::framework::InferShapeVarPtr> GetInputVarPtrs( std::vector<paddle::framework::InferShapeVarPtr> GetInputVarPtrs(
const std::string& name) override { const std::string& name) const override {
PADDLE_THROW(paddle::platform::errors::PermissionDenied( PADDLE_THROW(paddle::platform::errors::PermissionDenied(
"GetInputVarPtrs not support in dygraph runtime context")); "GetInputVarPtrs not support in dygraph runtime context"));
} }
std::vector<paddle::framework::InferShapeVarPtr> GetOutputVarPtrs( std::vector<paddle::framework::InferShapeVarPtr> GetOutputVarPtrs(
const std::string& name) override { const std::string& name) const override {
PADDLE_THROW(paddle::platform::errors::PermissionDenied( PADDLE_THROW(paddle::platform::errors::PermissionDenied(
"GetOutputVarPtrs not support in dygraph runtime context")); "GetOutputVarPtrs not support in dygraph runtime context"));
} }
......
...@@ -309,7 +309,7 @@ bool InterpretercoreInferShapeContext::IsRuntime() const { return true; } ...@@ -309,7 +309,7 @@ bool InterpretercoreInferShapeContext::IsRuntime() const { return true; }
// TODO(paddle-dev): Can this be template? // TODO(paddle-dev): Can this be template?
std::vector<InferShapeVarPtr> InterpretercoreInferShapeContext::GetInputVarPtrs( std::vector<InferShapeVarPtr> InterpretercoreInferShapeContext::GetInputVarPtrs(
const std::string& name) { const std::string& name) const {
const std::vector<Variable*>& vars = InputVars(name); const std::vector<Variable*>& vars = InputVars(name);
std::vector<InferShapeVarPtr> res; std::vector<InferShapeVarPtr> res;
res.reserve(vars.size()); res.reserve(vars.size());
...@@ -318,7 +318,8 @@ std::vector<InferShapeVarPtr> InterpretercoreInferShapeContext::GetInputVarPtrs( ...@@ -318,7 +318,8 @@ std::vector<InferShapeVarPtr> InterpretercoreInferShapeContext::GetInputVarPtrs(
} }
std::vector<InferShapeVarPtr> std::vector<InferShapeVarPtr>
InterpretercoreInferShapeContext::GetOutputVarPtrs(const std::string& name) { InterpretercoreInferShapeContext::GetOutputVarPtrs(
const std::string& name) const {
const std::vector<Variable*>& vars = OutputVars(name); const std::vector<Variable*>& vars = OutputVars(name);
std::vector<InferShapeVarPtr> res; std::vector<InferShapeVarPtr> res;
res.reserve(vars.size()); res.reserve(vars.size());
......
...@@ -86,10 +86,10 @@ class InterpretercoreInferShapeContext : public InferShapeContext { ...@@ -86,10 +86,10 @@ class InterpretercoreInferShapeContext : public InferShapeContext {
// TODO(paddle-dev): Can this be template? // TODO(paddle-dev): Can this be template?
std::vector<InferShapeVarPtr> GetInputVarPtrs( std::vector<InferShapeVarPtr> GetInputVarPtrs(
const std::string& name) override; const std::string& name) const override;
std::vector<InferShapeVarPtr> GetOutputVarPtrs( std::vector<InferShapeVarPtr> GetOutputVarPtrs(
const std::string& name) override; const std::string& name) const override;
DDim GetInputDim(const std::string& name) const override; DDim GetInputDim(const std::string& name) const override;
......
...@@ -200,7 +200,7 @@ class CompileTimeInferShapeContext : public InferShapeContext { ...@@ -200,7 +200,7 @@ class CompileTimeInferShapeContext : public InferShapeContext {
} }
std::vector<InferShapeVarPtr> GetInputVarPtrs( std::vector<InferShapeVarPtr> GetInputVarPtrs(
const std::string &name) override { const std::string &name) const override {
const std::vector<std::string> arg_names = Inputs(name); const std::vector<std::string> arg_names = Inputs(name);
std::vector<InferShapeVarPtr> res; std::vector<InferShapeVarPtr> res;
res.reserve(arg_names.size()); res.reserve(arg_names.size());
...@@ -212,7 +212,7 @@ class CompileTimeInferShapeContext : public InferShapeContext { ...@@ -212,7 +212,7 @@ class CompileTimeInferShapeContext : public InferShapeContext {
} }
std::vector<InferShapeVarPtr> GetOutputVarPtrs( std::vector<InferShapeVarPtr> GetOutputVarPtrs(
const std::string &name) override { const std::string &name) const override {
const std::vector<std::string> arg_names = Outputs(name); const std::vector<std::string> arg_names = Outputs(name);
std::vector<InferShapeVarPtr> res; std::vector<InferShapeVarPtr> res;
res.reserve(arg_names.size()); res.reserve(arg_names.size());
......
...@@ -871,7 +871,7 @@ class RuntimeInferShapeContext : public InferShapeContext { ...@@ -871,7 +871,7 @@ class RuntimeInferShapeContext : public InferShapeContext {
// TODO(paddle-dev): Can this be template? // TODO(paddle-dev): Can this be template?
std::vector<InferShapeVarPtr> GetInputVarPtrs( std::vector<InferShapeVarPtr> GetInputVarPtrs(
const std::string& name) override { const std::string& name) const override {
const std::vector<Variable*>& vars = InputVars(name); const std::vector<Variable*>& vars = InputVars(name);
std::vector<InferShapeVarPtr> res; std::vector<InferShapeVarPtr> res;
res.reserve(vars.size()); res.reserve(vars.size());
...@@ -880,7 +880,7 @@ class RuntimeInferShapeContext : public InferShapeContext { ...@@ -880,7 +880,7 @@ class RuntimeInferShapeContext : public InferShapeContext {
} }
std::vector<InferShapeVarPtr> GetOutputVarPtrs( std::vector<InferShapeVarPtr> GetOutputVarPtrs(
const std::string& name) override { const std::string& name) const override {
const std::vector<Variable*>& vars = OutputVars(name); const std::vector<Variable*>& vars = OutputVars(name);
std::vector<InferShapeVarPtr> res; std::vector<InferShapeVarPtr> res;
res.reserve(vars.size()); res.reserve(vars.size());
......
...@@ -103,9 +103,9 @@ class InferShapeContext { ...@@ -103,9 +103,9 @@ class InferShapeContext {
virtual bool IsRuntime() const = 0; virtual bool IsRuntime() const = 0;
virtual std::vector<InferShapeVarPtr> GetInputVarPtrs( virtual std::vector<InferShapeVarPtr> GetInputVarPtrs(
const std::string &name) = 0; const std::string &name) const = 0;
virtual std::vector<InferShapeVarPtr> GetOutputVarPtrs( virtual std::vector<InferShapeVarPtr> GetOutputVarPtrs(
const std::string &name) = 0; const std::string &name) const = 0;
protected: protected:
virtual std::vector<DDim> GetRepeatedDims(const std::string &name) const = 0; virtual std::vector<DDim> GetRepeatedDims(const std::string &name) const = 0;
......
...@@ -216,13 +216,13 @@ class DygraphInferShapeContext : public framework::InferShapeContext { ...@@ -216,13 +216,13 @@ class DygraphInferShapeContext : public framework::InferShapeContext {
// TODO(paddle-dev): Can this be template? // TODO(paddle-dev): Can this be template?
std::vector<framework::InferShapeVarPtr> GetInputVarPtrs( std::vector<framework::InferShapeVarPtr> GetInputVarPtrs(
const std::string& name) override { const std::string& name) const override {
PADDLE_THROW(platform::errors::PermissionDenied( PADDLE_THROW(platform::errors::PermissionDenied(
"GetInputVarPtrs not support in dygraph runtime context")); "GetInputVarPtrs not support in dygraph runtime context"));
} }
std::vector<framework::InferShapeVarPtr> GetOutputVarPtrs( std::vector<framework::InferShapeVarPtr> GetOutputVarPtrs(
const std::string& name) override { const std::string& name) const override {
PADDLE_THROW(platform::errors::PermissionDenied( PADDLE_THROW(platform::errors::PermissionDenied(
"GetOutputVarPtrs not support in dygraph runtime context")); "GetOutputVarPtrs not support in dygraph runtime context"));
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册