// This file is part of OpenCV project. // It is subject to the license terms in the LICENSE file found in the top-level directory // of this distribution and at http://opencv.org/license.html. // // Copyright (C) 2019 Intel Corporation #ifdef HAVE_PLAIDML #ifndef OPENCV_GAPI_GPLAIDMLBACKEND_HPP #define OPENCV_GAPI_GPLAIDMLBACKEND_HPP #include // map #include // unordered_map #include // tuple #include // type_list_index #include #include #include #include "api/gorigin.hpp" #include "backends/common/gbackend.hpp" #include "compiler/gislandmodel.hpp" #include #include namespace cv { namespace gimpl { struct PlaidMLUnit { static const char *name() { return "PlaidMLKernel"; } GPlaidMLKernel k; }; class GPlaidMLExecutable final: public GIslandExecutable { public: struct Config { std::string dev_id; std::string trg_id; }; GPlaidMLExecutable(Config cfg, const ade::Graph& graph, const std::vector& nodes, const std::vector& ins_data, const std::vector& outs_data); virtual inline bool canReshape() const override { return false; } virtual inline void reshape(ade::Graph&, const GCompileArgs&) override { util::throw_error(std::logic_error("GPlaidMLExecutable::reshape() should never be called")); } virtual void run(std::vector &&input_objs, std::vector &&output_objs) override; private: void initBuffers(const std::vector& ins_data, std::vector& bindings); void bindInArg (const RcDesc &rc, const GRunArg &arg); void bindOutArg (const RcDesc &rc, const GRunArgP &arg); void compile(const std::vector& ins_data, const std::vector& outs_data); // FIXME User also can pass config via compile args ? void initConfig(); GArg packArg(const GArg &arg); Config m_cfg; const ade::Graph &m_g; GModel::ConstGraph m_gm; std::vector m_all_ops; std::vector output_ids_; std::unique_ptr binder_; std::shared_ptr exec_; std::vector input_bindings_; std::vector output_bindings_; using Mag = detail::magazine; Mag m_res; }; }} #endif // OPENCV_GAPI_GPLAIDMLBACKEND_HPP #endif // HAVE_PLAIDML