From ceed07b76304c1b66039180149f8546ffcaed2c6 Mon Sep 17 00:00:00 2001 From: yangfei Date: Wed, 31 Oct 2018 22:37:55 +0800 Subject: [PATCH] modify operator.cpp --- src/framework/operator.cpp | 126 +++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 55 deletions(-) diff --git a/src/framework/operator.cpp b/src/framework/operator.cpp index ac2a4917db..e0b40cebf7 100644 --- a/src/framework/operator.cpp +++ b/src/framework/operator.cpp @@ -57,63 +57,79 @@ void OperatorBase::CheckAllInputOutputSet() const {} template void OperatorBase::Run() { - DLOG << " ----- Begin run impl --- " << type_ << " ----- "; RunImpl(); - DLOG << " ----- End run impl --- " << type_ << " ----- "; - //#ifdef PADDLE_MOBILE_DEBUG - // DLOG << "-------------" << type_ << "----------------------------"; - // vector input_keys = GetInputKeys(); - // for (const auto key : input_keys) { - // auto var_vec_in = inputs_.at(key); - // for (int i = 0; i < var_vec_in.size(); ++i) { - // auto vari = scope_->FindVar(var_vec_in[i]); - // if (vari->IsInitialized()) { - //#ifdef PADDLE_MOBILE_CL - // if (type_ == "feed") { - // Tensor *tensor = vari->template - // GetMutable(); if (tensor) DLOG << type_ << " - // input- " << key << "=" << *tensor; - // } else { - // CLImage *cl_image = vari->template - // GetMutable(); if (cl_image) { - // DLOG << type_ << " input- " << key << "=" << *cl_image; - // } - // } - // - //#else - // Tensor *tensor = vari->template GetMutable(); - // if (tensor) DLOG << type_ << " input- " << key << "=" << *tensor; - //#endif - // } - // } - // } - // for (const auto key : GetOutKeys()) { - // auto var_vec_out = outputs_.at(key); - // for (int i = 0; i < var_vec_out.size(); ++i) { - // auto vari = scope_->FindVar(var_vec_out[i]); - // if (vari->IsInitialized()) { - //#ifdef PADDLE_MOBILE_CL - // if (type_ == "fetch") { - // Tensor *tensor = vari->template - // GetMutable(); if (tensor) { - // DLOG << type_ << " output- " << key << "=" << *tensor; - // } - // } else { - // CLImage *cl_image = vari->template - // GetMutable(); if (cl_image) { - // DLOG << type_ << " output- " << key << "=" << *cl_image; - // } - // } - // - //#else - // Tensor *tensor = vari->template GetMutable(); - // if (tensor) DLOG << type_ << " output- " << key << "=" << *tensor; - //#endif - // } - // } - // } - //#endif +#ifdef PADDLE_MOBILE_DEBUG + DLOG << "-------------" << type_ << "----------------------------"; + vector input_keys = GetInputKeys(); + for (const auto key : input_keys) { + auto var_vec_in = inputs_.at(key); + for (int i = 0; i < var_vec_in.size(); ++i) { + auto vari = scope_->FindVar(var_vec_in[i]); + if (vari->IsInitialized()) { + Tensor *tensor = vari->template GetMutable(); + if (tensor) DLOG << type_ << " input- " << key << "=" << *tensor; + } + } + } + for (const auto key : GetOutKeys()) { + auto var_vec_out = outputs_.at(key); + for (int i = 0; i < var_vec_out.size(); ++i) { + auto vari = scope_->FindVar(var_vec_out[i]); + if (vari->IsInitialized()) { + Tensor *tensor = vari->template GetMutable(); + if (tensor) DLOG << type_ << " output- " << key << "=" << *tensor; + } + } + } +#endif +} + +#ifdef PADDLE_MOBILE_CL +template <> +void OperatorBase::Run() { + RunImpl(); +#ifdef PADDLE_MOBILE_DEBUG + DLOG << "-------------" << type_ << "----------------------------"; + vector input_keys = GetInputKeys(); + for (const auto key : input_keys) { + auto var_vec_in = inputs_.at(key); + for (int i = 0; i < var_vec_in.size(); ++i) { + auto vari = scope_->FindVar(var_vec_in[i]); + if (vari->IsInitialized()) { + if (type_ == "feed") { + Tensor *tensor = vari->template GetMutable(); + if (tensor) DLOG << type_ << " input- " << key << "=" << *tensor; + } else { + CLImage *cl_image = vari->template GetMutable(); + if (cl_image) { + DLOG << type_ << " input- " << key << "=" << *cl_image; + } + } + } + } + } + for (const auto key : GetOutKeys()) { + auto var_vec_out = outputs_.at(key); + for (int i = 0; i < var_vec_out.size(); ++i) { + auto vari = scope_->FindVar(var_vec_out[i]); + if (vari->IsInitialized()) { + if (type_ == "fetch") { + Tensor *tensor = vari->template GetMutable(); + if (tensor) { + DLOG << type_ << " output- " << key << "=" << *tensor; + } + } else { + CLImage *cl_image = vari->template GetMutable(); + if (cl_image) { + DLOG << type_ << " output- " << key << "=" << *cl_image; + } + } + } + } + } +#endif } +#endif template class OperatorBase; template class OperatorBase; -- GitLab