forked from alibaba/MNN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTestUtils.cpp
45 lines (39 loc) · 1.05 KB
/
TestUtils.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
//
// TestUtils.cpp
// MNN
//
// Created by MNN on 2019/01/15.
// Copyright © 2018, Alibaba Group Holding Limited
//
#include "TestUtils.h"
#include <math.h>
#include "Macro.h"
#include "TensorUtils.hpp"
using namespace MNN;
Session *createSession(MNN::Interpreter *net, MNNForwardType backend) {
ScheduleConfig config;
config.type = backend;
return net->createSession(config);
}
#if defined(__APPLE__)
void dispatchMetal(std::function<void(MNNForwardType)> payload, MNNForwardType backend);
#endif
void dispatch(std::function<void(MNNForwardType)> payload) {
for (int i = 0; i < MNN_FORWARD_ALL; i++) {
MNNForwardType type = (MNNForwardType)i;
if (MNNGetExtraBackendCreator(type))
dispatch(payload, type);
}
}
void dispatch(std::function<void(MNNForwardType)> payload, MNNForwardType backend) {
switch (backend) {
#if defined(__APPLE__)
case MNN_FORWARD_METAL:
dispatchMetal(payload, backend);
break;
#endif
default:
payload(backend);
break;
}
}