-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathEngineManager.cpp
More file actions
75 lines (63 loc) · 2.33 KB
/
Copy pathEngineManager.cpp
File metadata and controls
75 lines (63 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#include <algorithm>
#include <hipdnn_sdk/plugin/PluginException.hpp>
#include <hipdnn_sdk/plugin/flatbuffer_utilities/GraphWrapper.hpp>
#include "EngineManager.hpp"
#include "engines/MiopenEngine.hpp"
using namespace hipdnn_plugin;
namespace miopen_legacy_plugin
{
void EngineManager::addEngine(std::unique_ptr<IEngine> engine)
{
_engines.emplace(engine->id(), std::move(engine));
}
std::vector<int64_t> EngineManager::getApplicableEngineIds(HipdnnEnginePluginHandle& handle,
const hipdnn_plugin::IGraph& opGraph)
{
std::vector<int64_t> applicable;
for(const auto& engine : _engines)
{
if(engine.second->isApplicable(handle, opGraph))
{
applicable.push_back(engine.second->id());
}
}
return applicable;
}
void EngineManager::getEngineDetails(HipdnnEnginePluginHandle& handle,
const hipdnn_plugin::IGraph& opGraph,
int64_t engineId,
hipdnnPluginConstData_t& engineDetailsOut)
{
(void)opGraph; // Unused parameter
auto& engine = getEngine(engineId);
engine.getDetails(handle, engineDetailsOut);
}
size_t EngineManager::getWorkspaceSize(const HipdnnEnginePluginHandle& handle,
int64_t engineId,
const hipdnn_plugin::IGraph& opGraph) const
{
auto& engine = getEngine(engineId);
return engine.getWorkspaceSize(handle, opGraph);
}
void EngineManager::initializeExecutionContext(
const HipdnnEnginePluginHandle& handle,
const hipdnn_plugin::IGraph& opGraph,
const hipdnn_plugin::IEngineConfig& engineConfig,
HipdnnEnginePluginExecutionContext& executionContext) const
{
auto& engine = getEngine(engineConfig.engineId());
engine.initializeExecutionContext(handle, opGraph, executionContext);
}
IEngine& EngineManager::getEngine(int64_t engineId) const
{
auto it = _engines.find(engineId);
if(it == _engines.end())
{
throw HipdnnPluginException(HIPDNN_PLUGIN_STATUS_INVALID_VALUE,
"Engine with ID " + std::to_string(engineId) + " not found.");
}
return *it->second;
}
}