forked from projectceladon/nn_gpu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
executor_manager.cpp
executable file
·88 lines (77 loc) · 1.72 KB
/
executor_manager.cpp
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
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "executor_manager.h"
#include "gles/gles_cs_executor.h"
#include "vulkan/vk_cs_executor.h"
NAME_SPACE_BEGIN
ExecutorManager::ExecutorType ExecutorManager::type = ExecutorManager::ET_VK_CS;
bool ExecutorManager::initPerProcess()
{
NN_GPU_CALL();
//might check setting to change type
if (type == ET_GLES_CS)
{
return GlesCsExecutor::initPerProcess();
}
else if (type == ET_VK_CS)
{
return VkCsExecutor::initPerProcess();
}
return false;
}
void ExecutorManager::deinitPerProcess()
{
NN_GPU_ENTRY();
if (type == ET_GLES_CS)
{
GlesCsExecutor::deinitPerProcess();
}
else if (type == ET_VK_CS)
{
VkCsExecutor::deinitPerProcess();
}
NN_GPU_EXIT();
}
void ExecutorManager::getCapabilities(Capabilities &cap)
{
NN_GPU_ENTRY();
if (type == ET_GLES_CS)
{
GlesCsExecutor::getCapabilities(cap);
}
else if (type == ET_VK_CS)
{
VkCsExecutor::getCapabilities(cap);
}
NN_GPU_EXIT();
}
std::vector<bool> ExecutorManager::getSupportedOperations(const Model& model)
{
NN_GPU_CALL();
if (type == ET_GLES_CS)
{
return GlesCsExecutor::getSupportedOperations(model);
}
else if (type == ET_VK_CS)
{
return VkCsExecutor::getSupportedOperations(model);
}
else
{
const size_t count = model.operations.size();
std::vector<bool> supported(count, false);
return supported;
}
}
BaseExecutor* ExecutorManager::createExecutor(const Model& model)
{
NN_GPU_CALL();
if (type == ET_GLES_CS)
{
return new GlesCsExecutor(model);
}
else if (type == ET_VK_CS)
{
return new VkCsExecutor(model);
}
return NULL;
}
NAME_SPACE_STOP