-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathHipdnnEnginePluginHandle.hpp
More file actions
73 lines (59 loc) · 2 KB
/
Copy pathHipdnnEnginePluginHandle.hpp
File metadata and controls
73 lines (59 loc) · 2 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
// Copyright © Advanced Micro Devices, Inc., or its affiliates.
// SPDX-License-Identifier: MIT
#pragma once
#include <flatbuffers/flatbuffers.h>
#include <memory>
#include <miopen/miopen.h>
#include <unordered_map>
#include <hipdnn_sdk/logging/Logger.hpp>
#include <hipdnn_sdk/plugin/PluginException.hpp>
#include "MiopenContainer.hpp"
#include "MiopenUtils.hpp"
// NOLINTBEGIN
struct HipdnnEnginePluginHandle
{
public:
virtual ~HipdnnEnginePluginHandle() = default;
miopenHandle_t miopenHandle = nullptr;
void setStream(hipStream_t stream)
{
THROW_ON_MIOPEN_FAILURE(miopenSetStream(miopenHandle, stream));
_stream = stream;
}
hipStream_t getStream() const
{
return _stream;
}
std::shared_ptr<miopen_legacy_plugin::MiopenContainer> miopenContainer;
miopen_legacy_plugin::EngineManager& getEngineManager()
{
return miopenContainer->getEngineManager();
}
void storeEngineDetailsDetachedBuffer(const void* ptr,
std::unique_ptr<flatbuffers::DetachedBuffer> buffer)
{
HIPDNN_LOG_INFO("Storing detached buffer at address: {:p}", ptr);
_engineDetailsBuffers[ptr] = std::move(buffer);
}
void removeEngineDetailsDetachedBuffer(const void* ptr)
{
HIPDNN_LOG_INFO("Removing detached buffer at address: {:p}", ptr);
auto it = _engineDetailsBuffers.find(ptr);
if(it != _engineDetailsBuffers.end())
{
_engineDetailsBuffers.erase(it);
}
else
{
HIPDNN_LOG_WARN("No detached buffer found at address: {:p}. Could not remove engine "
"details. Ensure you "
"are using the same hipdnn handle you used for engine details creation",
ptr);
}
}
private:
hipStream_t _stream = nullptr;
std::unordered_map<const void*, std::unique_ptr<flatbuffers::DetachedBuffer>>
_engineDetailsBuffers;
};
// NOLINTEND