Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
b9876e17
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看板
提交
b9876e17
编写于
12月 29, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fomart files
上级
445317f8
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
28 addition
and
20 deletion
+28
-20
metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift
...addle-mobile-demo/paddle-mobile-demo/ViewController.swift
+3
-4
metal/paddle-mobile/paddle-mobile/Common/Extensions.swift
metal/paddle-mobile/paddle-mobile/Common/Extensions.swift
+10
-2
metal/paddle-mobile/paddle-mobile/CustomNet/Genet.swift
metal/paddle-mobile/paddle-mobile/CustomNet/Genet.swift
+1
-1
metal/paddle-mobile/paddle-mobile/CustomNet/MobileNet.swift
metal/paddle-mobile/paddle-mobile/CustomNet/MobileNet.swift
+1
-3
metal/paddle-mobile/paddle-mobile/CustomNet/MobileNetCombined.swift
...le-mobile/paddle-mobile/CustomNet/MobileNetCombined.swift
+1
-1
metal/paddle-mobile/paddle-mobile/CustomNet/MobilenetSSD_AR.swift
...ddle-mobile/paddle-mobile/CustomNet/MobilenetSSD_AR.swift
+1
-1
metal/paddle-mobile/paddle-mobile/CustomNet/YoloNet.swift
metal/paddle-mobile/paddle-mobile/CustomNet/YoloNet.swift
+1
-2
metal/paddle-mobile/paddle-mobile/Net.swift
metal/paddle-mobile/paddle-mobile/Net.swift
+9
-5
metal/paddle-mobile/paddle-mobile/Operators/FetchOp.swift
metal/paddle-mobile/paddle-mobile/Operators/FetchOp.swift
+1
-1
未找到文件。
metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift
浏览文件 @
b9876e17
...
...
@@ -108,15 +108,14 @@ class ViewController: UIViewController {
guard
let
sSelf
=
self
else
{
fatalError
()
}
if
success
{
if
let
inResultHolder
=
resultHolder
,
success
{
if
i
==
max
-
1
{
let
time
=
Date
.
init
()
.
timeIntervalSince
(
startDate
)
print
(
Array
<
Any
>.
floatArrWithBuffer
(
floatArrBuffer
:
resultHolder
!.
result
!
,
count
:
resultHolder
!.
capacity
)
.
strideArray
())
print
(
inResultHolder
.
result
.
floatArr
(
count
:
inResultHolder
.
capacity
)
.
strideArray
())
DispatchQueue
.
main
.
async
{
// print(resultHolder!.result![0])
sSelf
.
resultTextView
.
text
=
sSelf
.
runner
.
net
.
resultStr
(
res
:
resultHolder
!
)
sSelf
.
elapsedTimeLabel
.
text
=
"平均耗时:
\(
time
/
Double
(
max
)
*
1000.0
)
ms"
}
}
}
...
...
metal/paddle-mobile/paddle-mobile/Common/Extensions.swift
浏览文件 @
b9876e17
...
...
@@ -120,9 +120,17 @@ extension Array {
}
}
extension
UnsafeMutablePointer
{
public
func
floatArr
(
count
:
Int
)
->
[
Pointee
]{
var
arr
:
[
Pointee
]
=
[]
for
i
in
0
..<
count
{
arr
.
append
(
self
[
i
])
}
return
arr
}
}
extension
String
{
extension
String
{
func
cStr
()
->
UnsafePointer
<
Int8
>
?
{
return
(
self
as
NSString
)
.
utf8String
}
...
...
metal/paddle-mobile/paddle-mobile/CustomNet/Genet.swift
浏览文件 @
b9876e17
...
...
@@ -48,7 +48,7 @@ public class Genet: Net {
override
public
func
resultStr
(
res
:
ResultHolder
)
->
String
{
// fatalError()
return
"
\(
res
.
result
!
[
0
]
)
... "
return
"
\(
res
.
result
[
0
]
)
... "
}
}
metal/paddle-mobile/paddle-mobile/CustomNet/MobileNet.swift
浏览文件 @
b9876e17
...
...
@@ -43,9 +43,7 @@ public class MobileNet: Net{
let
labels
=
PreWords
.
init
(
fileName
:
"synset"
)
override
public
func
resultStr
(
res
:
ResultHolder
)
->
String
{
guard
let
resPointer
=
res
.
result
else
{
fatalError
()
}
let
resPointer
=
res
.
result
var
s
:
[
String
]
=
[]
(
0
..<
res
.
capacity
)
.
map
{
resPointer
[
$0
]
}
.
top
(
r
:
5
)
.
enumerated
()
.
forEach
{
s
.
append
(
String
(
format
:
"%d: %@ (%3.2f%%)"
,
$0
+
1
,
labels
[
$1
.
0
],
$1
.
1
*
100
))
...
...
metal/paddle-mobile/paddle-mobile/CustomNet/MobileNetCombined.swift
浏览文件 @
b9876e17
...
...
@@ -41,7 +41,7 @@ public class MobileNetCombined: Net {
override
public
func
resultStr
(
res
:
ResultHolder
)
->
String
{
// fatalError()
return
"
\(
res
.
result
!
[
0
]
)
... "
return
"
\(
res
.
result
[
0
]
)
... "
}
}
metal/paddle-mobile/paddle-mobile/CustomNet/MobilenetSSD_AR.swift
浏览文件 @
b9876e17
...
...
@@ -47,7 +47,7 @@ public class MobileNet_ssd_AR: Net{
}
override
public
func
resultStr
(
res
:
ResultHolder
)
->
String
{
return
"
\(
res
.
result
!
[
0
]
)
"
return
"
\(
res
.
result
[
0
]
)
"
}
override
func
fetchResult
(
paddleMobileRes
:
GPUResultHolder
)
->
ResultHolder
{
...
...
metal/paddle-mobile/paddle-mobile/CustomNet/YoloNet.swift
浏览文件 @
b9876e17
...
...
@@ -43,8 +43,7 @@ public class YoloNet: Net {
// }
override
public
func
resultStr
(
res
:
ResultHolder
)
->
String
{
// fatalError()
return
"
\(
res
.
result
!
[
0
]
)
... "
return
"
\(
res
.
result
[
0
]
)
... "
}
}
metal/paddle-mobile/paddle-mobile/Net.swift
浏览文件 @
b9876e17
...
...
@@ -17,17 +17,17 @@ import Foundation
import
Metal
public
class
ResultHolder
:
NSObject
{
@objc
public
let
result
:
UnsafeMutablePointer
<
Float32
>
?
@objc
public
let
result
:
UnsafeMutablePointer
<
Float32
>
@objc
public
let
capacity
:
Int
init
(
inResult
:
UnsafeMutablePointer
<
Float32
>
?
,
inCapacity
:
Int
)
{
init
(
inResult
:
UnsafeMutablePointer
<
Float32
>
,
inCapacity
:
Int
)
{
result
=
inResult
capacity
=
inCapacity
}
@objc
public
func
releasePointer
()
{
result
?
.
deinitialize
(
count
:
capacity
)
result
?
.
deallocate
()
result
.
deinitialize
(
count
:
capacity
)
result
.
deallocate
()
}
}
...
...
@@ -86,7 +86,11 @@ public class Net: NSObject {
}
func
fetchResult
(
paddleMobileRes
:
GPUResultHolder
)
->
ResultHolder
{
return
ResultHolder
.
init
(
inResult
:
paddleMobileRes
.
resultPointer
,
inCapacity
:
paddleMobileRes
.
capacity
)
guard
let
inResPointer
=
paddleMobileRes
.
resultPointer
else
{
fatalError
()
}
return
ResultHolder
.
init
(
inResult
:
inResPointer
,
inCapacity
:
paddleMobileRes
.
capacity
)
}
func
updateProgram
(
program
:
Program
)
{
...
...
metal/paddle-mobile/paddle-mobile/Operators/FetchOp.swift
浏览文件 @
b9876e17
...
...
@@ -83,7 +83,7 @@ class FetchOp<P: PrecisionType>: Operator< FetchKernel<P>, FetchParam<P>>, Runab
func
delogOutput
()
{
print
(
"fetch output: "
)
let
resArr
=
Array
<
Any
>.
floatArrWithBuffer
(
floatArrBuffer
:
self
.
para
.
output
.
result
,
count
:
self
.
para
.
output
.
capacity
)
let
resArr
=
self
.
para
.
output
.
result
.
floatArr
(
count
:
self
.
para
.
output
.
capacity
)
print
(
resArr
.
strideArray
())
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录