Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
aabcc54d
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
aabcc54d
编写于
9月 05, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
compile for ios
上级
4b7625f6
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
47 addition
and
10 deletion
+47
-10
CMakeLists.txt
CMakeLists.txt
+3
-3
src/ios_io/PaddleMobile.mm
src/ios_io/PaddleMobile.mm
+30
-5
src/ios_io/op_symbols.h
src/ios_io/op_symbols.h
+3
-1
src/operators/math/pool_2x2.cpp
src/operators/math/pool_2x2.cpp
+11
-1
未找到文件。
CMakeLists.txt
浏览文件 @
aabcc54d
cmake_minimum_required
(
VERSION 3.6
)
cmake_minimum_required
(
VERSION 3.6
)
project
(
paddle-mobile
)
project
(
paddle-mobile
)
option
(
DEBUGING
"enable debug mode"
O
N
)
option
(
DEBUGING
"enable debug mode"
O
FF
)
option
(
USE_OPENMP
"openmp support"
OFF
)
option
(
USE_OPENMP
"openmp support"
OFF
)
option
(
USE_EXCEPTION
"use std exception"
O
N
)
option
(
USE_EXCEPTION
"use std exception"
O
FF
)
option
(
LOG_PROFILE
"log profile"
O
N
)
option
(
LOG_PROFILE
"log profile"
O
FF
)
# select the platform to build
# select the platform to build
option
(
CPU
"armv7 with neon"
ON
)
option
(
CPU
"armv7 with neon"
ON
)
option
(
MALI_GPU
"mali gpu"
OFF
)
option
(
MALI_GPU
"mali gpu"
OFF
)
...
...
src/ios_io/PaddleMobile.mm
浏览文件 @
aabcc54d
...
@@ -13,6 +13,7 @@
...
@@ -13,6 +13,7 @@
limitations under the License. */
limitations under the License. */
#import "PaddleMobile.h"
#import "PaddleMobile.h"
#import "op_symbols.h"
#import "op_symbols.h"
#import "io/paddle_mobile.h"
#import "io/paddle_mobile.h"
...
@@ -23,6 +24,8 @@
...
@@ -23,6 +24,8 @@
{
{
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
,
paddle_mobile
::
Precision
::
FP32
>
*
pam_
;
paddle_mobile
::
PaddleMobile
<
paddle_mobile
::
CPU
,
paddle_mobile
::
Precision
::
FP32
>
*
pam_
;
BOOL
loaded_
;
BOOL
loaded_
;
std
::
vector
<
float
>
*
predict_input_
;
}
}
@end
@end
...
@@ -55,7 +58,7 @@ static std::mutex shared_mutex;
...
@@ -55,7 +58,7 @@ static std::mutex shared_mutex;
-
(
BOOL
)
load
:(
NSString
*
)
modelPath
andWeightsPath
:(
NSString
*
)
weighsPath
{
-
(
BOOL
)
load
:(
NSString
*
)
modelPath
andWeightsPath
:(
NSString
*
)
weighsPath
{
std
::
string
model_path_str
=
std
::
string
([
modelPath
UTF8String
]);
std
::
string
model_path_str
=
std
::
string
([
modelPath
UTF8String
]);
std
::
string
weights_path_str
=
std
::
string
([
weighsPath
UTF8String
]);
std
::
string
weights_path_str
=
std
::
string
([
weighsPath
UTF8String
]);
if
(
loaded_
=
pam_
->
Load
(
model_path_str
,
weights_path_str
,
fals
e
))
{
if
(
loaded_
=
pam_
->
Load
(
model_path_str
,
weights_path_str
,
tru
e
))
{
return
YES
;
return
YES
;
}
else
{
}
else
{
return
NO
;
return
NO
;
...
@@ -102,7 +105,26 @@ static std::mutex shared_mutex;
...
@@ -102,7 +105,26 @@ static std::mutex shared_mutex;
}
}
-
(
NSArray
*
)
predict
:(
CGImageRef
)
image
dim
:(
NSArray
<
NSNumber
*>
*
)
dim
means
:(
NSArray
<
NSNumber
*>
*
)
means
scale
:(
float
)
scale
{
-
(
NSArray
*
)
predict
:(
CGImageRef
)
image
dim
:(
NSArray
<
NSNumber
*>
*
)
dim
means
:(
NSArray
<
NSNumber
*>
*
)
means
scale
:(
float
)
scale
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
shared_mutex
);
// printf(" hi i am here");
if
(
predict_input_
)
{
// printf(" fukc -- ");
// printf(" %d \n", predict_input_->size());
// dim to c++ vector, get numel
std
::
vector
<
int64_t
>
dim_vec
=
{
1
,
3
,
300
,
300
};
// int numel = 1;
// for (int k = 0; k < dim.count; ++k) {
// int d = dim[k].intValue;
// numel *= d;
// dim_vec.push_back(d);
// }
std
::
vector
<
float
>
cpp_result
=
pam_
->
Predict
(
*
predict_input_
,
dim_vec
);
return
nil
;
}
// printf(" predict one ");
// std::lock_guard<std::mutex> lock(shared_mutex);
if
(
!
loaded_
)
{
if
(
!
loaded_
)
{
printf
(
"PaddleMobile doesn't be loaded yet"
);
printf
(
"PaddleMobile doesn't be loaded yet"
);
return
nil
;
return
nil
;
...
@@ -141,13 +163,15 @@ static std::mutex shared_mutex;
...
@@ -141,13 +163,15 @@ static std::mutex shared_mutex;
}
}
// input
// input
std
::
vector
<
float
>
predict_input
;
std
::
vector
<
float
>
*
predict_input
=
new
std
::
vector
<
float
>
()
;
for
(
int
j
=
0
;
j
<
numel
;
++
j
)
{
for
(
int
j
=
0
;
j
<
numel
;
++
j
)
{
predict_input
.
push_back
(
dataPointer
[
j
]);
predict_input
->
push_back
(
dataPointer
[
j
]);
}
}
predict_input_
=
predict_input
;
// predict
// predict
std
::
vector
<
float
>
cpp_result
=
pam_
->
Predict
(
predict_input
,
dim_vec
);
std
::
vector
<
float
>
cpp_result
=
pam_
->
Predict
(
*
predict_input
,
dim_vec
);
// result
// result
long
count
=
0
;
long
count
=
0
;
...
@@ -157,6 +181,7 @@ static std::mutex shared_mutex;
...
@@ -157,6 +181,7 @@ static std::mutex shared_mutex;
[
result
addObject
:[
NSNumber
numberWithFloat
:
cpp_result
[
i
]]];
[
result
addObject
:[
NSNumber
numberWithFloat
:
cpp_result
[
i
]]];
}
}
free
(
output
);
free
(
output
);
// 待验证
// 待验证
...
...
src/ios_io/op_symbols.h
浏览文件 @
aabcc54d
...
@@ -18,8 +18,10 @@
...
@@ -18,8 +18,10 @@
#include "operators/box_coder_op.h"
#include "operators/box_coder_op.h"
#include "operators/concat_op.h"
#include "operators/concat_op.h"
#include "operators/conv_op.h"
#include "operators/conv_op.h"
#include "operators/depthwise_conv_op.h"
#include "operators/dropout_op.h"
#include "operators/dropout_op.h"
#include "operators/depthwise_conv_op.h"
#include "operators/fusion_conv_bn_relu_op.h"
#include "operators/fusion_dwconv_bn_relu_op.h"
#include "operators/elementwise_add_op.h"
#include "operators/elementwise_add_op.h"
#include "operators/feed_op.h"
#include "operators/feed_op.h"
#include "operators/fetch_op.h"
#include "operators/fetch_op.h"
...
...
src/operators/math/pool_2x2.cpp
浏览文件 @
aabcc54d
...
@@ -66,6 +66,9 @@ void Pool2x2Maxs2p0(vector<int> strides, vector<int> paddings,
...
@@ -66,6 +66,9 @@ void Pool2x2Maxs2p0(vector<int> strides, vector<int> paddings,
}
}
float
*
out_ptr
=
output_data
+
i
*
output_batch_stride
+
float
*
out_ptr
=
output_data
+
i
*
output_batch_stride
+
c
*
output_channel_stride
+
ph
/
2
*
output_width
;
c
*
output_channel_stride
+
ph
/
2
*
output_width
;
#if __ARM_NEON
#if __aarch64__
#else
asm
volatile
(
asm
volatile
(
"subs %[w1], %[w1], #1
\n\t
"
"subs %[w1], %[w1], #1
\n\t
"
"blt end_w1_%=
\n\t
"
"blt end_w1_%=
\n\t
"
...
@@ -115,6 +118,8 @@ void Pool2x2Maxs2p0(vector<int> strides, vector<int> paddings,
...
@@ -115,6 +118,8 @@ void Pool2x2Maxs2p0(vector<int> strides, vector<int> paddings,
[
in_ptr2
]
"r"
(
in_ptr2
),
[
out_ptr
]
"r"
(
out_ptr
)
[
in_ptr2
]
"r"
(
in_ptr2
),
[
out_ptr
]
"r"
(
out_ptr
)
:
"memory"
,
"q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4"
,
"q5"
,
"q6"
,
"q7"
,
"q8"
,
:
"memory"
,
"q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4"
,
"q5"
,
"q6"
,
"q7"
,
"q8"
,
"q9"
);
"q9"
);
#endif
#endif
if
(
_w2
!=
0
)
{
if
(
_w2
!=
0
)
{
in_ptr1
+=
16
*
w1
+
4
*
w2
;
in_ptr1
+=
16
*
w1
+
4
*
w2
;
...
@@ -183,6 +188,9 @@ void Pool2x2Avgs2p0(vector<int> strides, vector<int> paddings,
...
@@ -183,6 +188,9 @@ void Pool2x2Avgs2p0(vector<int> strides, vector<int> paddings,
}
}
float
*
out_ptr
=
output_data
+
i
*
output_batch_stride
+
float
*
out_ptr
=
output_data
+
i
*
output_batch_stride
+
c
*
output_channel_stride
+
ph
/
2
*
output_width
;
c
*
output_channel_stride
+
ph
/
2
*
output_width
;
#if __ARM_NEON
#if __aarch64__
#else
asm
volatile
(
asm
volatile
(
"subs %[w1], %[w1], #1
\n\t
"
"subs %[w1], %[w1], #1
\n\t
"
"blt end_w1_%=
\n\t
"
"blt end_w1_%=
\n\t
"
...
@@ -238,6 +246,8 @@ void Pool2x2Avgs2p0(vector<int> strides, vector<int> paddings,
...
@@ -238,6 +246,8 @@ void Pool2x2Avgs2p0(vector<int> strides, vector<int> paddings,
[
quarter
]
"r"
(
quarter
)
[
quarter
]
"r"
(
quarter
)
:
"memory"
,
"q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4"
,
"q5"
,
"q6"
,
"q7"
,
"q8"
,
:
"memory"
,
"q0"
,
"q1"
,
"q2"
,
"q3"
,
"q4"
,
"q5"
,
"q6"
,
"q7"
,
"q8"
,
"q9"
,
"q10"
);
"q9"
,
"q10"
);
#endif
#endif
if
(
_w2
!=
0
)
{
if
(
_w2
!=
0
)
{
in_ptr1
+=
16
*
w1
+
4
*
w2
;
in_ptr1
+=
16
*
w1
+
4
*
w2
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录