From b96c7c9a7acbac495e29653e32ea1cfcdd412d2b Mon Sep 17 00:00:00 2001 From: Leo Chen Date: Tue, 21 Jan 2020 17:53:15 +0800 Subject: [PATCH] polish code, test=develop (#22380) remove unnecessary template. --- paddle/fluid/imperative/tracer.h | 5 +---- paddle/fluid/pybind/imperative.cc | 12 ++++++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/imperative/tracer.h b/paddle/fluid/imperative/tracer.h index 72236272913..3e03100ab01 100644 --- a/paddle/fluid/imperative/tracer.h +++ b/paddle/fluid/imperative/tracer.h @@ -87,10 +87,7 @@ class Tracer { platform::Place ExpectedPlace() const { return expected_place_; } - template - void SetExpectedPlace(PlaceType place) { - expected_place_ = place; - } + void SetExpectedPlace(platform::Place place) { expected_place_ = place; } bool NoGrad() const { return no_grad_; } diff --git a/paddle/fluid/pybind/imperative.cc b/paddle/fluid/pybind/imperative.cc index bbdafbf3d54..84b6ff267ed 100644 --- a/paddle/fluid/pybind/imperative.cc +++ b/paddle/fluid/pybind/imperative.cc @@ -536,18 +536,18 @@ void BindImperative(py::module *m_ptr) { [](imperative::Tracer &self, const py::object &obj) { if (py::isinstance(obj)) { auto p = obj.cast(); - self.SetExpectedPlace(*p); + self.SetExpectedPlace(*p); } else if (py::isinstance(obj)) { auto p = obj.cast(); - self.SetExpectedPlace(*p); + self.SetExpectedPlace(*p); } else if (py::isinstance(obj)) { auto p = obj.cast(); - self.SetExpectedPlace(*p); + self.SetExpectedPlace(*p); } else { - PADDLE_THROW( + PADDLE_THROW(platform::errors::InvalidArgument( "Incompatible Place Type: supports CUDAPlace, CPUPlace, " - "CUDAPinnedPlace, " - "but got Unknown Type!"); + "and CUDAPinnedPlace, " + "but got Unknown Type!")); } }) .def("_get_program_desc_tracer", -- GitLab