From 5fe3f8f630cf4459a30a399d63f27db7b474ca8e Mon Sep 17 00:00:00 2001 From: qijun Date: Mon, 16 Oct 2017 10:50:20 -0700 Subject: [PATCH] refine code --- paddle/framework/feed_fetch_method.h | 6 +++--- paddle/pybind/pybind.cc | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/paddle/framework/feed_fetch_method.h b/paddle/framework/feed_fetch_method.h index be96dc326..826d180bf 100644 --- a/paddle/framework/feed_fetch_method.h +++ b/paddle/framework/feed_fetch_method.h @@ -37,9 +37,9 @@ void SetFeedVariable(const LoDTensor& input, const std::string& var_name, } LoDTensor& GetFetchVariable(const std::string& var_name, size_t index) { - // If var_name Variable is not found in GlobalScope, a new variable will - // be created. - Variable* g_fetch_value = GetGlobalScope().Var(var_name); + // Since we want to fetch LodTensor from a variable, the variable must + // be created alreadly. + Variable* g_fetch_value = GetGlobalScope().FindVar(var_name); auto& fetch_outputs = *(g_fetch_value->GetMutable>()); PADDLE_ENFORCE_LT(index, fetch_outputs.size()); diff --git a/paddle/pybind/pybind.cc b/paddle/pybind/pybind.cc index 983f19b30..008a9441d 100644 --- a/paddle/pybind/pybind.cc +++ b/paddle/pybind/pybind.cc @@ -12,7 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "paddle/pybind/pybind.h" +#include "paddle/pybind/protobuf.h" + #include "paddle/framework/backward.h" #include "paddle/framework/executor.h" #include "paddle/framework/feed_fetch_method.h" @@ -25,7 +26,7 @@ limitations under the License. */ #include "paddle/platform/enforce.h" #include "paddle/platform/place.h" #include "paddle/pybind/exception.h" -#include "paddle/pybind/protobuf.h" +#include "paddle/pybind/pybind.h" #include "paddle/pybind/tensor_py.h" #include "paddle/string/to_string.h" -- GitLab