diff --git a/src/framework/operator.cpp b/src/framework/operator.cpp index ac2a4917db6d90045623b71d07624eb6d07de082..e0b40cebf7f14e0b927e4666d63e740213918333 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;