// Copyright © Advanced Micro Devices, Inc., or its affiliates. // SPDX-License-Identifier: MIT #pragma once #include #include #include #include "HipdnnMiopenHandle.hpp" namespace miopen_plugin { /* * Container class to manage the intantiation and ownership of all MIOpen plan builders and engines. * The class designs use dependency injection to get the components they need in order to function. * This makes it easier to test and maintain the code as you can swap out implementations. * * The construction sequence should contain no logic other than the creation of various classes. * If logic is needed, it should be placed in a separate function that can be called after the * container has finished constructing all its components. */ class MiopenContainer { public: MiopenContainer(); ~MiopenContainer(); // Copy engine IDs into a buffer. // If maxEngines == 0: Does not copy, only queries total count. // If maxEngines > 0: Copies up to maxEngines IDs into *engineIds, sets numEngines to number copied. // Returns: Total number of available engines (regardless of maxEngines value). static uint32_t copyEngineIds(int64_t* engineIds, uint32_t maxEngines, uint32_t& numEngines); hipdnn_plugin_sdk::EngineManager& getEngineManager(); private: struct EngineDefinition { int64_t id; // Set id using EngineNames.hpp. std::function>()> createEngine; }; static const std::vector& getEngineDefinitions(); std::unique_ptr> _engineManager; }; }