Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
95dd3047
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看板
提交
95dd3047
编写于
3月 11, 2019
作者:
R
Ray Liu
提交者:
GitHub
3月 11, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1490 from codeWorm2015/develop
add preprocess Kernel
上级
4f3ae703
94624b1d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
12 deletion
+16
-12
metal/paddle-mobile-demo/paddle-mobile-demo/Net/MobileNetCombined.swift
...obile-demo/paddle-mobile-demo/Net/MobileNetCombined.swift
+4
-1
metal/paddle-mobile-demo/paddle-mobile-demo/Net/YoloNet.swift
...l/paddle-mobile-demo/paddle-mobile-demo/Net/YoloNet.swift
+2
-0
metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift
...addle-mobile-demo/paddle-mobile-demo/ViewController.swift
+8
-9
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/Scale.swift
...le-mobile/paddle-mobile/Src/Operators/Kernels/Scale.swift
+2
-2
未找到文件。
metal/paddle-mobile-demo/paddle-mobile-demo/Net/MobileNetCombined.swift
浏览文件 @
95dd3047
...
@@ -23,8 +23,11 @@ public class MobileNetCombined: Net {
...
@@ -23,8 +23,11 @@ public class MobileNetCombined: Net {
paramPath
=
Bundle
.
main
.
path
(
forResource
:
"combined_mobilenet_params"
,
ofType
:
nil
)
?
!
"para null"
paramPath
=
Bundle
.
main
.
path
(
forResource
:
"combined_mobilenet_params"
,
ofType
:
nil
)
?
!
"para null"
inputDim
=
Dim
.
init
(
inDim
:
[
1
,
224
,
224
,
3
])
inputDim
=
Dim
.
init
(
inDim
:
[
1
,
224
,
224
,
3
])
metalLoadMode
=
.
LoadMetalInCustomMetalLib
metalLoadMode
=
.
LoadMetalInCustomMetalLib
metalLibPath
=
Bundle
.
main
.
path
(
forResource
:
"paddle-mobile-metallib"
,
ofType
:
"metallib"
)
let
paddleMobileMetallib
=
Bundle
.
main
.
path
(
forResource
:
"paddle-mobile-metallib"
,
ofType
:
"metallib"
)
metalLibPath
=
paddleMobileMetallib
useMPS
=
true
useMPS
=
true
preprocessKernel
=
ScaleKernel
.
init
(
device
:
device
,
shape
:
Shape
.
init
(
inWidth
:
224
,
inHeight
:
224
,
inChannel
:
3
),
metalLoadMode
:
.
LoadMetalInCustomMetalLib
,
metalLibPath
:
paddleMobileMetallib
)
}
}
let
labels
=
PreWords
.
init
(
fileName
:
"vision_synset"
)
let
labels
=
PreWords
.
init
(
fileName
:
"vision_synset"
)
...
...
metal/paddle-mobile-demo/paddle-mobile-demo/Net/YoloNet.swift
浏览文件 @
95dd3047
...
@@ -27,6 +27,8 @@ public class YoloNet: Net {
...
@@ -27,6 +27,8 @@ public class YoloNet: Net {
metalLibPath
=
Bundle
.
main
.
path
(
forResource
:
"paddle-mobile-metallib"
,
ofType
:
"metallib"
)
metalLibPath
=
Bundle
.
main
.
path
(
forResource
:
"paddle-mobile-metallib"
,
ofType
:
"metallib"
)
useMPS
=
true
useMPS
=
true
paramPrecision
=
.
Float16
paramPrecision
=
.
Float16
preprocessKernel
=
ScaleKernel
.
init
(
device
:
device
,
shape
:
Shape
.
init
(
inWidth
:
416
,
inHeight
:
416
,
inChannel
:
3
),
metalLoadMode
:
.
LoadMetalInCustomMetalLib
,
metalLibPath
:
Bundle
.
main
.
path
(
forResource
:
"paddle-mobile-metallib"
,
ofType
:
"metallib"
))
}
}
override
public
func
resultStr
(
res
:
[
ResultHolder
])
->
String
{
override
public
func
resultStr
(
res
:
[
ResultHolder
])
->
String
{
...
...
metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift
浏览文件 @
95dd3047
...
@@ -100,16 +100,15 @@ class ViewController: UIViewController {
...
@@ -100,16 +100,15 @@ class ViewController: UIViewController {
if
self
.
toPredictTexture
==
nil
{
if
self
.
toPredictTexture
==
nil
{
// runner.getTexture(inBuffer: buffer!) { [weak self] (texture) in
// self?.toPredictTexture = texture
// }
let
beforeDate
=
Date
.
init
()
let
beforeDate
=
Date
.
init
()
runner
.
getTexture
(
image
:
selectImage
!.
cgImage
!
)
{
[
weak
self
]
(
texture
)
in
if
modelType
==
.
mobilenet_combined
||
modelType
==
.
yolo
{
let
timeUse
=
Date
.
init
()
.
timeIntervalSince
(
beforeDate
)
self
.
toPredictTexture
=
try!
MetalHelper
.
shared
.
textureLoader
.
newTexture
(
cgImage
:
selectImage
!.
cgImage
!
,
options
:
nil
)
print
(
"get texture time use:
\(
timeUse
)
"
)
}
else
{
self
?
.
toPredictTexture
=
texture
runner
.
getTexture
(
image
:
selectImage
!.
cgImage
!
)
{
[
weak
self
]
(
texture
)
in
let
timeUse
=
Date
.
init
()
.
timeIntervalSince
(
beforeDate
)
print
(
"get texture time use:
\(
timeUse
)
"
)
self
?
.
toPredictTexture
=
texture
}
}
}
}
}
}
else
{
}
else
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/Scale.swift
浏览文件 @
95dd3047
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
import
Foundation
import
Foundation
class
ScaleKernel
:
CusomKernel
{
public
class
ScaleKernel
:
CusomKernel
{
init
(
device
:
MTLDevice
,
shape
:
Shape
,
metalLoadMode
:
MetalLoadMode
,
metalLibPath
:
String
?)
{
public
init
(
device
:
MTLDevice
,
shape
:
Shape
,
metalLoadMode
:
MetalLoadMode
,
metalLibPath
:
String
?)
{
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float32
{
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float32
{
super
.
init
(
device
:
device
,
inFunctionName
:
"scale"
,
outputDim
:
shape
,
metalLoadModel
:
metalLoadMode
,
metalLibPath
:
metalLibPath
)
super
.
init
(
device
:
device
,
inFunctionName
:
"scale"
,
outputDim
:
shape
,
metalLoadModel
:
metalLoadMode
,
metalLibPath
:
metalLibPath
)
}
else
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float16
{
}
else
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float16
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录