From 6ba99068c9fab6c3e7759ee038fc532b3010903b Mon Sep 17 00:00:00 2001 From: Anatoliy Talamanov Date: Thu, 25 Mar 2021 17:53:29 +0300 Subject: [PATCH] Support RMat for PlaidML backend --- modules/gapi/src/backends/plaidml/gplaidmlbackend.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/gapi/src/backends/plaidml/gplaidmlbackend.cpp b/modules/gapi/src/backends/plaidml/gplaidmlbackend.cpp index ebce629..c932d5e 100644 --- a/modules/gapi/src/backends/plaidml/gplaidmlbackend.cpp +++ b/modules/gapi/src/backends/plaidml/gplaidmlbackend.cpp @@ -198,9 +198,6 @@ void cv::gimpl::GPlaidMLExecutable::run(std::vector &&input_objs, exec_->run(); for (auto& it : output_objs) bindOutArg(it.first, it.second); - - // FIXME: - // PlaidML backend haven't been updated with RMat support } void cv::gimpl::GPlaidMLExecutable::bindInArg(const RcDesc &rc, const GRunArg &arg) @@ -215,10 +212,12 @@ void cv::gimpl::GPlaidMLExecutable::bindInArg(const RcDesc &rc, const GRunArg & switch (arg.index()) { - case GRunArg::index_of() : + case GRunArg::index_of(): { - auto& arg_mat = util::get(arg); - binder_->input(it->second).copy_from(arg_mat.data); + auto& rmat = cv::util::get(arg); + auto view = rmat.access(cv::RMat::Access::R); + auto mat = cv::gimpl::asMat(view); + binder_->input(it->second).copy_from(mat.data); } break; default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?")); @@ -243,10 +242,12 @@ void cv::gimpl::GPlaidMLExecutable::bindOutArg(const RcDesc &rc, const GRunArgP switch (arg.index()) { - case GRunArgP::index_of() : + case GRunArgP::index_of() : { - auto& arg_mat = *util::get(arg); - binder_->output(it->second).copy_into(arg_mat.data); + auto& rmat = *cv::util::get(arg); + auto view = rmat.access(cv::RMat::Access::W); + auto mat = cv::gimpl::asMat(view); + binder_->output(it->second).copy_into(mat.data); } break; default: util::throw_error(std::logic_error("content type of the runtime argument does not match to resource description ?")); -- 2.7.4