-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.patch
125 lines (113 loc) · 5.48 KB
/
demo.patch
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
commit 24ea4360371bd28a8df4618607568eb7fa82f89e
Author: luxuhui <[email protected]>
Date: Thu Jul 22 15:18:55 2021 +0800
fix: change MatMul op's type and fix compile&run errors in Android demo
N/A
Signed-off-by: Luxuhui <[email protected]>
diff --git a/examples/android/build.gradle b/examples/android/build.gradle
index e6b32bc..4e8009d 100644
--- a/examples/android/build.gradle
+++ b/examples/android/build.gradle
@@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.1'
+ classpath 'com.android.tools.build:gradle:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
diff --git a/examples/android/build.sh b/examples/android/build.sh
index 3ce6f3b..bcf4a35 100755
--- a/examples/android/build.sh
+++ b/examples/android/build.sh
@@ -54,7 +54,7 @@ cp -rf include/mace $INCLUDE_DIR
cp -rf build/mobilenet/include/mace/public/*.h $INCLUDE_DIR/mace/public/
cp -rf build/mobilenet/model $LIBRARY_DIR
-bazel build --config android --config optimization $BAZEL_LIBMACE_TARGET --define neon=true --define opencl=true --define quantize=true --cpu=$TARGET_ABI
+bazel build --config android --config optimization $BAZEL_LIBMACE_TARGET --define cpu_enabled=true --define neon=true --define opencl=true --define quantize=true --cpu=$TARGET_ABI
cp -rf $BAZEL_GEN_LIBMACE_PATH $LIBMACE_DIR
if [ $MACE_LINK_TYPE == "dynamic" ]; then
diff --git a/examples/android/gradle/wrapper/gradle-wrapper.properties b/examples/android/gradle/wrapper/gradle-wrapper.properties
index 929e900..e08c46d 100644
--- a/examples/android/gradle/wrapper/gradle-wrapper.properties
+++ b/examples/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/examples/android/macelibrary/src/main/cpp/image_classify.cc b/examples/android/macelibrary/src/main/cpp/image_classify.cc
index f3ded52..238ffa4 100755
--- a/examples/android/macelibrary/src/main/cpp/image_classify.cc
+++ b/examples/android/macelibrary/src/main/cpp/image_classify.cc
@@ -41,7 +41,7 @@ struct MaceContext {
std::shared_ptr<mace::OpenclContext> gpu_context;
std::shared_ptr<mace::MaceEngine> engine;
std::string model_name;
- mace::DeviceType device_type = mace::DeviceType::CPU;
+ mace::RuntimeType runtime_type = mace::RuntimeType ::RT_CPU;
std::map<std::string, ModelInfo> model_infos = {
{"mobilenet_v1", {"input", "MobilenetV1/Predictions/Reshape_1",
{1, 224, 224, 3}, {1, 1001}}},
@@ -54,15 +54,15 @@ struct MaceContext {
};
};
-mace::DeviceType ParseDeviceType(const std::string &device) {
+mace::RuntimeType ParseDeviceType(const std::string &device) {
if (device.compare("CPU") == 0) {
- return mace::DeviceType::CPU;
+ return mace::RuntimeType ::RT_CPU;
} else if (device.compare("GPU") == 0) {
- return mace::DeviceType::GPU;
+ return mace::RuntimeType::RT_OPENCL;
} else if (device.compare("HEXAGON") == 0) {
- return mace::DeviceType::HEXAGON;
+ return mace::RuntimeType::RT_HEXAGON;
} else {
- return mace::DeviceType::CPU;
+ return mace::RuntimeType::RT_CPU;
}
}
@@ -115,12 +115,13 @@ Java_com_xiaomi_mace_JniMaceUtils_maceMobilenetCreateEngine(
// get device
const char *device_ptr = env->GetStringUTFChars(device, nullptr);
if (device_ptr == nullptr) return JNI_ERR;
- mace_context.device_type = ParseDeviceType(device_ptr);
+ mace_context.runtime_type = ParseDeviceType(device_ptr);
env->ReleaseStringUTFChars(device, device_ptr);
// create MaceEngineConfig
mace::MaceStatus status;
mace::MaceEngineConfig config;
+ config.SetRuntimeType(mace_context.runtime_type);
status = config.SetCPUThreadPolicy(
num_threads,
static_cast<mace::CPUAffinityPolicy>(cpu_affinity_policy));
@@ -130,7 +131,7 @@ Java_com_xiaomi_mace_JniMaceUtils_maceMobilenetCreateEngine(
"threads: %d, cpu: %d",
num_threads, cpu_affinity_policy);
}
- if (mace_context.device_type == mace::DeviceType::GPU) {
+ if (mace_context.runtime_type == mace::RuntimeType::RT_OPENCL) {
config.SetGPUContext(mace_context.gpu_context);
config.SetGPUHints(
static_cast<mace::GPUPerfHint>(gpu_perf_hint),
@@ -144,7 +145,7 @@ Java_com_xiaomi_mace_JniMaceUtils_maceMobilenetCreateEngine(
__android_log_print(ANDROID_LOG_INFO,
"image_classify attrs",
"device: %d",
- mace_context.device_type);
+ mace_context.runtime_type);
// parse model name
const char *model_name_ptr = env->GetStringUTFChars(model_name_str, nullptr);
diff --git a/tools/python/transform/base_converter.py b/tools/python/transform/base_converter.py
index c63f71a..0515b1a 100644
--- a/tools/python/transform/base_converter.py
+++ b/tools/python/transform/base_converter.py
@@ -199,7 +199,6 @@ MaceFixedDataFormatOps = [MaceOp.BatchNorm,
MaceOp.SpaceToDepth,
MaceOp.LpNorm,
MaceOp.MVNorm,
- MaceOp.MatMul,
MaceOp.NonlocalReshape,
MaceOp.GroupNorm,
MaceOp.DetectionOutput,