Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
d91c89dd
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看板
提交
d91c89dd
编写于
12月 28, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove cpu in gpu project
上级
26fdcbef
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
166 addition
and
264 deletion
+166
-264
metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj
...-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj
+24
-0
metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift
...-demo/paddle-mobile-demo/MultiPredictViewController.swift
+2
-2
metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift
...addle-mobile-demo/paddle-mobile-demo/ViewController.swift
+18
-64
metal/paddle-mobile/paddle-mobile.xcodeproj/project.pbxproj
metal/paddle-mobile/paddle-mobile.xcodeproj/project.pbxproj
+8
-16
metal/paddle-mobile/paddle-mobile.xcodeproj/xcshareddata/xcschemes/paddle-mobile.xcscheme
...e.xcodeproj/xcshareddata/xcschemes/paddle-mobile.xcscheme
+80
-0
metal/paddle-mobile/paddle-mobile/CPU/PaddleMobileCPU.h
metal/paddle-mobile/paddle-mobile/CPU/PaddleMobileCPU.h
+0
-85
metal/paddle-mobile/paddle-mobile/CPUCompute.h
metal/paddle-mobile/paddle-mobile/CPUCompute.h
+0
-1
metal/paddle-mobile/paddle-mobile/CPUCompute.mm
metal/paddle-mobile/paddle-mobile/CPUCompute.mm
+0
-4
metal/paddle-mobile/paddle-mobile/MobileNet.swift
metal/paddle-mobile/paddle-mobile/MobileNet.swift
+4
-4
metal/paddle-mobile/paddle-mobile/Net.swift
metal/paddle-mobile/paddle-mobile/Net.swift
+11
-6
metal/paddle-mobile/paddle-mobile/Operators/ResizeBilinearOp.swift
...dle-mobile/paddle-mobile/Operators/ResizeBilinearOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m
metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m
+4
-3
metal/paddle-mobile/paddle-mobile/Runner.swift
metal/paddle-mobile/paddle-mobile/Runner.swift
+6
-70
metal/paddle-mobile/paddle-mobile/SuperResolutionNet.swift
metal/paddle-mobile/paddle-mobile/SuperResolutionNet.swift
+2
-1
metal/paddle-mobile/paddle-mobile/framework/Executor.swift
metal/paddle-mobile/paddle-mobile/framework/Executor.swift
+5
-5
metal/paddle-mobile/paddle-mobile/paddle_mobile.h
metal/paddle-mobile/paddle-mobile/paddle_mobile.h
+0
-1
未找到文件。
metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj
浏览文件 @
d91c89dd
...
...
@@ -25,6 +25,10 @@
FC704C2521D237FC00F98BAB
/* yolo_model in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC704C2121D237FC00F98BAB
/* yolo_model */
;
};
FC803BCD214D27930094B8E5
/* FPSCounter.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC803BCB214D27920094B8E5
/* FPSCounter.swift */
;
};
FC803BCE214D27930094B8E5
/* VideoCapture.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC803BCC214D27920094B8E5
/* VideoCapture.swift */
;
};
FC9797BE21D6045B00F2FD90
/* banana.jpeg in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797BD21D6045B00F2FD90
/* banana.jpeg */
;
};
FC9797C221D608E000F2FD90
/* mobilenet_model in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C021D608DF00F2FD90
/* mobilenet_model */
;
};
FC9797C321D608E000F2FD90
/* mobilenet_params in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C121D608DF00F2FD90
/* mobilenet_params */
;
};
FC9797C721D609FB00F2FD90
/* synset.txt in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C621D609FB00F2FD90
/* synset.txt */
;
};
FCBCCC552122EF5500D94F7E
/* MetalHelper.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCBCCC542122EF5400D94F7E
/* MetalHelper.swift */
;
};
FCEBEC2C20E1391F00C0B14D
/* paddle_mobile.framework in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCEBEC2B20E1391F00C0B14D
/* paddle_mobile.framework */
;
};
FCEBEC2D20E1391F00C0B14D
/* paddle_mobile.framework in Embed Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCEBEC2B20E1391F00C0B14D
/* paddle_mobile.framework */
;
settings
=
{
ATTRIBUTES
=
(
CodeSignOnCopy
,
RemoveHeadersOnCopy
,
);
};
};
...
...
@@ -70,6 +74,10 @@
FC704C2121D237FC00F98BAB
/* yolo_model */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
yolo_model
;
sourceTree
=
"<group>"
;
};
FC803BCB214D27920094B8E5
/* FPSCounter.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
FPSCounter.swift
;
sourceTree
=
"<group>"
;
};
FC803BCC214D27920094B8E5
/* VideoCapture.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
VideoCapture.swift
;
sourceTree
=
"<group>"
;
};
FC9797BD21D6045B00F2FD90
/* banana.jpeg */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
image.jpeg
;
path
=
banana.jpeg
;
sourceTree
=
"<group>"
;
};
FC9797C021D608DF00F2FD90
/* mobilenet_model */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
mobilenet_model
;
sourceTree
=
"<group>"
;
};
FC9797C121D608DF00F2FD90
/* mobilenet_params */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
mobilenet_params
;
sourceTree
=
"<group>"
;
};
FC9797C621D609FB00F2FD90
/* synset.txt */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text
;
path
=
synset.txt
;
sourceTree
=
"<group>"
;
};
FCBCCC542122EF5400D94F7E
/* MetalHelper.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MetalHelper.swift
;
sourceTree
=
"<group>"
;
};
FCEBEC2B20E1391F00C0B14D
/* paddle_mobile.framework */
=
{
isa
=
PBXFileReference
;
explicitFileType
=
wrapper.framework
;
path
=
paddle_mobile.framework
;
sourceTree
=
BUILT_PRODUCTS_DIR
;
};
FCF437E7214B6DDB00943429
/* MultiPredictViewController.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MultiPredictViewController.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -150,6 +158,7 @@
FC203FA821CBFDBA00B37166
/* images */
=
{
isa
=
PBXGroup
;
children
=
(
FC9797BD21D6045B00F2FD90
/* banana.jpeg */
,
FC203FA921CBFDBA00B37166
/* test.jpg */
,
);
name
=
images
;
...
...
@@ -159,6 +168,7 @@
FC203FAA21CBFDBA00B37166
/* models */
=
{
isa
=
PBXGroup
;
children
=
(
FC9797BF21D608DF00F2FD90
/* mobilenet */
,
FC704C1B21D237FC00F98BAB
/* vision_model */
,
FC704C1621D2375300F98BAB
/* superresoltion */
,
);
...
...
@@ -220,6 +230,16 @@
path
=
Net
;
sourceTree
=
"<group>"
;
};
FC9797BF21D608DF00F2FD90
/* mobilenet */
=
{
isa
=
PBXGroup
;
children
=
(
FC9797C621D609FB00F2FD90
/* synset.txt */
,
FC9797C021D608DF00F2FD90
/* mobilenet_model */
,
FC9797C121D608DF00F2FD90
/* mobilenet_params */
,
);
path
=
mobilenet
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
...
...
@@ -286,11 +306,15 @@
FC704C2221D237FC00F98BAB
/* combined_mobilenet_params in Resources */
,
FC704C1921D2375300F98BAB
/* super_params in Resources */
,
FC039B8920E11C560081E9F8
/* Assets.xcassets in Resources */
,
FC9797C721D609FB00F2FD90
/* synset.txt in Resources */
,
FC704C1A21D2375300F98BAB
/* super_model in Resources */
,
FC039B8720E11C550081E9F8
/* Main.storyboard in Resources */
,
FC9797C221D608E000F2FD90
/* mobilenet_model in Resources */
,
FC203FB221CBFDBA00B37166
/* test.jpg in Resources */
,
FC704C2321D237FC00F98BAB
/* combined_mobilenet_model in Resources */
,
FC9797C321D608E000F2FD90
/* mobilenet_params in Resources */
,
FC704C2421D237FC00F98BAB
/* yolo_params in Resources */
,
FC9797BE21D6045B00F2FD90
/* banana.jpeg in Resources */
,
FC704C2521D237FC00F98BAB
/* yolo_model in Resources */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
...
...
metal/paddle-mobile-demo/paddle-mobile-demo/MultiPredictViewController.swift
浏览文件 @
d91c89dd
...
...
@@ -22,10 +22,10 @@ class MultiPredictViewController: UIViewController {
super
.
viewDidLoad
()
let
mobileNet
=
MobileNet_ssd_hand
.
init
(
device
:
MetalHelper
.
shared
.
device
)
let
genet
=
Genet
.
init
(
device
:
MetalHelper
.
shared
.
device
)
runner1
=
Runner
.
init
(
inNet
:
mobileNet
,
commandQueue
:
MetalHelper
.
shared
.
queue
,
inPlatform
:
.
GPU
)
runner1
=
Runner
.
init
(
inNet
:
mobileNet
,
commandQueue
:
MetalHelper
.
shared
.
queue
)
let
queue2
=
MetalHelper
.
shared
.
device
.
makeCommandQueue
()
runner2
=
Runner
.
init
(
inNet
:
genet
,
commandQueue
:
MetalHelper
.
shared
.
queue
,
inPlatform
:
.
GPU
)
runner2
=
Runner
.
init
(
inNet
:
genet
,
commandQueue
:
MetalHelper
.
shared
.
queue
)
}
@IBAction
func
predictAct
(
_
sender
:
Any
)
{
...
...
metal/paddle-mobile-demo/paddle-mobile-demo/ViewController.swift
浏览文件 @
d91c89dd
...
...
@@ -18,23 +18,11 @@ import CoreMedia
import
paddle_mobile
import
MetalPerformanceShaders
var
platform
:
Platform
=
.
GPU
let
threadSupport
:
[(
Platform
,
String
)]
=
[(
.
GPU
,
"GPU"
),
(
.
CPU
,
"CPU"
)]
let
netSupport
:
[
SupportModel
:
Net
]
=
[
.
super_resolution
:
SuperResolutionNet
.
init
(
device
:
MetalHelper
.
shared
.
device
),
.
yolo
:
YoloNet
.
init
(
device
:
MetalHelper
.
shared
.
device
),
.
mobilenet_combined
:
MobileNetCombined
.
init
(
device
:
MetalHelper
.
shared
.
device
)]
//.mobilenet_ssd : Runner.init(inNet: MobileNet_ssd_hand.init(device: MetalHelper.shared.device), commandQueue: MetalHelper.shared.queue, inPlatform: platform),
let
modelHelperMap
:
[
SupportModel
:
Runner
]
=
[
.
super_resolution
:
Runner
.
init
(
inNet
:
netSupport
[
.
super_resolution
]
!
,
commandQueue
:
MetalHelper
.
shared
.
queue
,
inPlatform
:
platform
),
.
yolo
:
Runner
.
init
(
inNet
:
YoloNet
.
init
(
device
:
MetalHelper
.
shared
.
device
),
commandQueue
:
MetalHelper
.
shared
.
queue
,
inPlatform
:
platform
),
.
mobilenet_combined
:
Runner
.
init
(
inNet
:
MobileNetCombined
.
init
(
device
:
MetalHelper
.
shared
.
device
),
commandQueue
:
MetalHelper
.
shared
.
queue
,
inPlatform
:
platform
)]
//, .genet : Genet.init()
//let modelHelperMap: [SupportModel : Net] = [.mobilenet : MobileNet.init(), .mobilenet_ssd : MobileNet_ssd_hand.init()]
enum
Platform
{
case
GPU
}
let
platformSupport
:
[(
Platform
,
String
)]
=
[(
.
GPU
,
"GPU"
)]
enum
SupportModel
:
String
{
// case mobilenet = "mobilenet"
...
...
@@ -42,14 +30,21 @@ enum SupportModel: String{
case
yolo
=
"yolo"
case
mobilenet_combined
=
"mobilenet_combined"
case
super_resolution
=
"superresoltion"
case
mobilenet
=
"mobilenet"
static
func
supportedModels
()
->
[
SupportModel
]
{
// .mobilenet,
// .mobilenet_ssd,
return
[
.
super_resolution
,
.
yolo
,
.
mobilenet_combined
]
return
[
.
super_resolution
,
.
yolo
,
.
mobilenet_combined
,
.
mobilenet
]
}
}
let
netSupport
:
[
SupportModel
:
Net
]
=
[
.
super_resolution
:
SuperResolutionNet
.
init
(
device
:
MetalHelper
.
shared
.
device
),
.
yolo
:
YoloNet
.
init
(
device
:
MetalHelper
.
shared
.
device
),
.
mobilenet_combined
:
MobileNetCombined
.
init
(
device
:
MetalHelper
.
shared
.
device
),
.
mobilenet
:
MobileNet
.
init
(
device
:
MetalHelper
.
shared
.
device
)]
class
ViewController
:
UIViewController
{
@IBOutlet
weak
var
resultTextView
:
UITextView
!
@IBOutlet
weak
var
selectImageView
:
UIImageView
!
...
...
@@ -65,23 +60,16 @@ class ViewController: UIViewController {
var
toPredictTexture
:
MTLTexture
?
var
runner
:
Runner
!
var
platform
:
Platform
=
.
GPU
var
threadNum
=
1
@IBAction
func
loadAct
(
_
sender
:
Any
)
{
runner
=
Runner
.
init
(
inNet
:
netSupport
[
modelType
]
!
,
commandQueue
:
MetalHelper
.
shared
.
queue
,
inPlatform
:
platform
)
if
platform
==
.
CPU
{
if
inputPointer
==
nil
{
inputPointer
=
runner
.
preproccess
(
image
:
selectImage
!.
cgImage
!
)
}
}
else
if
platform
==
.
GPU
{
runner
=
Runner
.
init
(
inNet
:
netSupport
[
modelType
]
!
,
commandQueue
:
MetalHelper
.
shared
.
queue
)
if
platform
==
.
GPU
{
if
self
.
toPredictTexture
==
nil
{
runner
.
getTexture
(
image
:
selectImage
!.
cgImage
!
)
{
[
weak
self
]
(
texture
)
in
self
?
.
toPredictTexture
=
texture
}
}
}
else
{
fatalError
(
" unsupport "
)
...
...
@@ -138,39 +126,6 @@ class ViewController: UIViewController {
}
}
}
case
.
CPU
:
guard
let
inInputPointer
=
inputPointer
else
{
fatalError
(
" need input pointer "
)
}
for
_
in
0
..<
10
{
runner
.
predict
(
inputPointer
:
inInputPointer
)
{
(
success
,
res
)
in
res
?
.
releaseOutput
()
}
}
let
startDate
=
Date
.
init
()
for
i
in
0
..<
max
{
runner
.
predict
(
inputPointer
:
inInputPointer
)
{
[
weak
self
](
success
,
res
)
in
guard
let
sSelf
=
self
else
{
fatalError
()
}
if
success
{
if
i
==
max
-
1
{
let
time
=
Date
.
init
()
.
timeIntervalSince
(
startDate
)
DispatchQueue
.
main
.
async
{
// sSelf.resultTextView.text = sSelf.runner.net.resultStr(res: res)
sSelf
.
elapsedTimeLabel
.
text
=
"平均耗时:
\(
time
/
Double
(
max
)
*
1000.0
)
ms"
}
}
}
res
?
.
releaseOutput
()
print
(
" predict done -- 123 "
)
}
}
}
}
...
...
@@ -230,7 +185,7 @@ extension ViewController: UIPickerViewDataSource, UIPickerViewDelegate{
if
pickerView
==
modelPickerView
{
return
SupportModel
.
supportedModels
()
.
count
}
else
if
pickerView
==
threadPickerView
{
return
thread
Support
.
count
return
platform
Support
.
count
}
else
{
fatalError
()
}
...
...
@@ -240,7 +195,7 @@ extension ViewController: UIPickerViewDataSource, UIPickerViewDelegate{
if
pickerView
==
modelPickerView
{
return
SupportModel
.
supportedModels
()[
row
]
.
rawValue
}
else
if
pickerView
==
threadPickerView
{
return
thread
Support
[
row
]
.
1
return
platform
Support
[
row
]
.
1
}
else
{
fatalError
()
}
...
...
@@ -250,8 +205,7 @@ extension ViewController: UIPickerViewDataSource, UIPickerViewDelegate{
if
pickerView
==
modelPickerView
{
self
.
modelType
=
SupportModel
.
supportedModels
()[
row
]
}
else
if
pickerView
==
threadPickerView
{
platform
=
threadSupport
[
row
]
.
0
platform
=
platformSupport
[
row
]
.
0
}
else
{
fatalError
()
}
...
...
metal/paddle-mobile/paddle-mobile.xcodeproj/project.pbxproj
浏览文件 @
d91c89dd
...
...
@@ -75,8 +75,6 @@
FC3602CC2108819F00FACB58
/* PaddleMobileUnitTest.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC3602CB2108819F00FACB58
/* PaddleMobileUnitTest.swift */
;
};
FC4CB74920F0B954007C0C6D
/* ConvKernel.metal in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC4CB74820F0B954007C0C6D
/* ConvKernel.metal */
;
};
FC4CB74B20F12C30007C0C6D
/* ProgramOptimize.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC4CB74A20F12C30007C0C6D
/* ProgramOptimize.swift */
;
};
FC4FD9792140E4980073E130
/* PaddleMobileCPU.h in Headers */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC4FD9772140E4980073E130
/* PaddleMobileCPU.h */
;
settings
=
{
ATTRIBUTES
=
(
Public
,
);
};
};
FC4FD97A2140E4980073E130
/* libpaddle-mobile.a in Frameworks */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC4FD9782140E4980073E130
/* libpaddle-mobile.a */
;
};
FC5163F620EF556E00636C28
/* Texture2DTo2DArrayKernel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC5163F520EF556E00636C28
/* Texture2DTo2DArrayKernel.swift */
;
};
FC60DB8920E9AAA500FF203F
/* MetalExtension.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC60DB8820E9AAA500FF203F
/* MetalExtension.swift */
;
};
FC704C2721D2385100F98BAB
/* SuperResolutionNet.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC704C2621D2385100F98BAB
/* SuperResolutionNet.swift */
;
};
...
...
@@ -87,6 +85,8 @@
FC803BC7214CBA820094B8E5
/* Macro.metal in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC803BC6214CBA820094B8E5
/* Macro.metal */
;
};
FC803BC9214CFC8D0094B8E5
/* FetchKernel.metal in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC803BC8214CFC8D0094B8E5
/* FetchKernel.metal */
;
};
FC82735920E3C04200BE430A
/* OpCreator.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC82735820E3C04200BE430A
/* OpCreator.swift */
;
};
FC9797C921D6101D00F2FD90
/* ResizeBilinearOp.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C821D6101D00F2FD90
/* ResizeBilinearOp.swift */
;
};
FC9797CB21D6102D00F2FD90
/* ResizeBilinearKernel.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797CA21D6102D00F2FD90
/* ResizeBilinearKernel.swift */
;
};
FC9A19E32148C31300CD9CBF
/* MobilenetSSD_AR.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9A19E22148C31300CD9CBF
/* MobilenetSSD_AR.swift */
;
};
FC9C2A0D21D3D185005856C6
/* FetchKernel.inc.metal in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9C2A0C21D3D185005856C6
/* FetchKernel.inc.metal */
;
};
FC9D037920E229E4000F735A
/* OpParam.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9D037820E229E4000F735A
/* OpParam.swift */
;
};
...
...
@@ -216,8 +216,6 @@
FC3602CB2108819F00FACB58
/* PaddleMobileUnitTest.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PaddleMobileUnitTest.swift
;
sourceTree
=
"<group>"
;
};
FC4CB74820F0B954007C0C6D
/* ConvKernel.metal */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.metal
;
path
=
ConvKernel.metal
;
sourceTree
=
"<group>"
;
};
FC4CB74A20F12C30007C0C6D
/* ProgramOptimize.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ProgramOptimize.swift
;
sourceTree
=
"<group>"
;
};
FC4FD9772140E4980073E130
/* PaddleMobileCPU.h */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.c.h
;
path
=
PaddleMobileCPU.h
;
sourceTree
=
"<group>"
;
};
FC4FD9782140E4980073E130
/* libpaddle-mobile.a */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
archive.ar
;
path
=
"libpaddle-mobile.a"
;
sourceTree
=
"<group>"
;
};
FC4FD97D2140F2C30073E130
/* libstdc++.tbd */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"sourcecode.text-based-dylib-definition"
;
name
=
"libstdc++.tbd"
;
path
=
"usr/lib/libstdc++.tbd"
;
sourceTree
=
SDKROOT
;
};
FC5163F520EF556E00636C28
/* Texture2DTo2DArrayKernel.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
Texture2DTo2DArrayKernel.swift
;
sourceTree
=
"<group>"
;
};
FC60DB8820E9AAA500FF203F
/* MetalExtension.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MetalExtension.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -229,6 +227,8 @@
FC803BC6214CBA820094B8E5
/* Macro.metal */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.metal
;
path
=
Macro.metal
;
sourceTree
=
"<group>"
;
};
FC803BC8214CFC8D0094B8E5
/* FetchKernel.metal */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.metal
;
path
=
FetchKernel.metal
;
sourceTree
=
"<group>"
;
};
FC82735820E3C04200BE430A
/* OpCreator.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OpCreator.swift
;
sourceTree
=
"<group>"
;
};
FC9797C821D6101D00F2FD90
/* ResizeBilinearOp.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ResizeBilinearOp.swift
;
sourceTree
=
"<group>"
;
};
FC9797CA21D6102D00F2FD90
/* ResizeBilinearKernel.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ResizeBilinearKernel.swift
;
sourceTree
=
"<group>"
;
};
FC9A19E22148C31300CD9CBF
/* MobilenetSSD_AR.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MobilenetSSD_AR.swift
;
sourceTree
=
"<group>"
;
};
FC9C2A0C21D3D185005856C6
/* FetchKernel.inc.metal */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.metal
;
path
=
FetchKernel.inc.metal
;
sourceTree
=
"<group>"
;
};
FC9D037820E229E4000F735A
/* OpParam.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
OpParam.swift
;
sourceTree
=
"<group>"
;
};
...
...
@@ -294,7 +294,6 @@
C28FE03021BA68C00054EFAC
/* MetalPerformanceShaders.framework in Frameworks */
,
C28FE03121BA68C00054EFAC
/* MetalKit.framework in Frameworks */
,
D3831F70E7E0B565B9AC22DA
/* Pods_paddle_mobile.framework in Frameworks */
,
FC4FD97A2140E4980073E130
/* libpaddle-mobile.a in Frameworks */
,
);
runOnlyForDeploymentPostprocessing
=
0
;
};
...
...
@@ -355,7 +354,6 @@
FC292C7D214255BC00CF622F
/* CPUCompute.h */
,
FC292C5521421B4600CF622F
/* PaddleMobileGPU.m */
,
FC292C5321421B2E00CF622F
/* PaddleMobileGPU.h */
,
FC4FD9762140E4920073E130
/* CPU */
,
FC039BAE20E11CC20081E9F8
/* Program */
,
FC039BA320E11CBC0081E9F8
/* Operators */
,
FC039B9C20E11CB20081E9F8
/* framework */
,
...
...
@@ -395,6 +393,7 @@
FC039BA320E11CBC0081E9F8
/* Operators */
=
{
isa
=
PBXGroup
;
children
=
(
FC9797C821D6101D00F2FD90
/* ResizeBilinearOp.swift */
,
FC086BA520E67E8500D85EF7
/* Kernels */
,
FCD592FA20E248EC00252966
/* Base */
,
FCEBC0F320F1FDD90099DBAF
/* ConvAddBatchNormReluOp.swift */
,
...
...
@@ -449,6 +448,7 @@
FC086BA520E67E8500D85EF7
/* Kernels */
=
{
isa
=
PBXGroup
;
children
=
(
FC9797CA21D6102D00F2FD90
/* ResizeBilinearKernel.swift */
,
FCDDC6CD212FE02100E5EF74
/* Base */
,
FCEB6837212F00B100D2448E
/* metal */
,
FCDDC6C7212FA3CA00E5EF74
/* ConvTransposeKernel.swift */
,
...
...
@@ -480,15 +480,6 @@
path
=
Kernels
;
sourceTree
=
"<group>"
;
};
FC4FD9762140E4920073E130
/* CPU */
=
{
isa
=
PBXGroup
;
children
=
(
FC4FD9782140E4980073E130
/* libpaddle-mobile.a */
,
FC4FD9772140E4980073E130
/* PaddleMobileCPU.h */
,
);
path
=
CPU
;
sourceTree
=
"<group>"
;
};
FCD592FA20E248EC00252966
/* Base */
=
{
isa
=
PBXGroup
;
children
=
(
...
...
@@ -557,7 +548,6 @@
isa
=
PBXHeadersBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
FC4FD9792140E4980073E130
/* PaddleMobileCPU.h in Headers */
,
FC292C85214257CB00CF622F
/* CPUCompute.h in Headers */
,
FC292C5421421B2F00CF622F
/* PaddleMobileGPU.h in Headers */
,
4AA1EA9E2148D6F900D0F791
/* ConcatKernel.inc.metal in Headers */
,
...
...
@@ -683,6 +673,7 @@
FCDDC6CC212FDFDB00E5EF74
/* ReluKernel.metal in Sources */
,
FC0226562138F33800F395E2
/* TransposeKernel.metal in Sources */
,
FCDDC6C6212F9FB800E5EF74
/* PreluKernel.swift in Sources */
,
FC9797CB21D6102D00F2FD90
/* ResizeBilinearKernel.swift in Sources */
,
FCA67CD52138272900BD58AA
/* ConvAddMetal.metal in Sources */
,
FCBCCC5B2122F66F00D94F7E
/* ConvBNReluKernel.swift in Sources */
,
4AA1EA8C2146640900D0F791
/* SplitOp.swift in Sources */
,
...
...
@@ -777,6 +768,7 @@
FC039BAD20E11CBC0081E9F8
/* ReluOp.swift in Sources */
,
FCBCCC572122F41300D94F7E
/* DwConvBNReluOp.swift in Sources */
,
FC039BBE20E11CC20081E9F8
/* OpDesc.swift in Sources */
,
FC9797C921D6101D00F2FD90
/* ResizeBilinearOp.swift in Sources */
,
4AA1EA88214662BD00D0F791
/* BilinearInterpKernel.swift in Sources */
,
FC039B9720E11C9A0081E9F8
/* Extensions.swift in Sources */
,
);
...
...
metal/paddle-mobile/paddle-mobile.xcodeproj/xcshareddata/xcschemes/paddle-mobile.xcscheme
0 → 100644
浏览文件 @
d91c89dd
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion =
"1010"
version =
"1.3"
>
<BuildAction
parallelizeBuildables =
"YES"
buildImplicitDependencies =
"YES"
>
<BuildActionEntries>
<BuildActionEntry
buildForTesting =
"YES"
buildForRunning =
"YES"
buildForProfiling =
"YES"
buildForArchiving =
"YES"
buildForAnalyzing =
"YES"
>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"FC039B6920E11C3C0081E9F8"
BuildableName =
"paddle_mobile.framework"
BlueprintName =
"paddle-mobile"
ReferencedContainer =
"container:paddle-mobile.xcodeproj"
>
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv =
"YES"
>
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration =
"Debug"
selectedDebuggerIdentifier =
"Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier =
"Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle =
"0"
useCustomWorkingDirectory =
"NO"
ignoresPersistentStateOnLaunch =
"NO"
debugDocumentVersioning =
"YES"
debugServiceExtension =
"internal"
allowLocationSimulation =
"YES"
>
<MacroExpansion>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"FC039B6920E11C3C0081E9F8"
BuildableName =
"paddle_mobile.framework"
BlueprintName =
"paddle-mobile"
ReferencedContainer =
"container:paddle-mobile.xcodeproj"
>
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration =
"Release"
shouldUseLaunchSchemeArgsEnv =
"YES"
savedToolIdentifier =
""
useCustomWorkingDirectory =
"NO"
debugDocumentVersioning =
"YES"
>
<MacroExpansion>
<BuildableReference
BuildableIdentifier =
"primary"
BlueprintIdentifier =
"FC039B6920E11C3C0081E9F8"
BuildableName =
"paddle_mobile.framework"
BlueprintName =
"paddle-mobile"
ReferencedContainer =
"container:paddle-mobile.xcodeproj"
>
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration =
"Debug"
>
</AnalyzeAction>
<ArchiveAction
buildConfiguration =
"Release"
revealArchiveInOrganizer =
"YES"
>
</ArchiveAction>
</Scheme>
metal/paddle-mobile/paddle-mobile/CPU/PaddleMobileCPU.h
已删除
100644 → 0
浏览文件 @
26fdcbef
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#pragma once
#import <CoreImage/CoreImage.h>
#import <Foundation/Foundation.h>
@interface
PaddleMobileCPUResult
:
NSObject
@property
(
assign
,
nonatomic
,
readonly
)
float
*
output
;
@property
(
assign
,
nonatomic
,
readonly
)
int
outputSize
;
-
(
void
)
releaseOutput
;
@end
@interface
PaddleMobileCPU
:
NSObject
/*
创建对象
*/
-
(
instancetype
)
init
;
/*
load 模型, 开辟内存
*/
-
(
BOOL
)
load
:(
NSString
*
)
modelPath
andWeightsPath
:(
NSString
*
)
weighsPath
;
/*
加载散开形式的模型, 需传入模型的目录
*/
-
(
BOOL
)
load
:(
NSString
*
)
modelAndWeightPath
;
/*
* 从内存中加载模型
* */
-
(
BOOL
)
LoadCombinedMemory
:(
size_t
)
modelLen
andModelBuf
:(
const
uint8_t
*
)
modelBuf
andModelParamsLen
:(
size_t
)
combinedParamsLen
andCombinedParamsBuf
:(
const
uint8_t
*
)
combinedParamsBuf
;
/*
* 对图像进行预处理, 需要外部开辟 output 内存, 外部释放 output 内存
* */
-
(
void
)
preprocess
:(
CGImageRef
)
image
output
:(
float
*
)
output
means
:(
NSArray
<
NSNumber
*>
*
)
means
scale
:(
float
)
scale
dim
:(
NSArray
<
NSNumber
*>
*
)
dim
;
/*
* 预测预处理后的数据, 返回结果使用结束需要调用其 realseOutput 函数进行释放
* */
-
(
PaddleMobileCPUResult
*
)
predictInput
:(
float
*
)
input
dim
:(
NSArray
<
NSNumber
*>
*
)
dim
;
/*
进行预测, means 和 scale 为训练模型时的预处理参数, 如训练时没有做这些预处理则直接使用 predict
*/
-
(
NSArray
*
)
predict
:(
CGImageRef
)
image
dim
:(
NSArray
<
NSNumber
*>
*
)
dim
means
:(
NSArray
<
NSNumber
*>
*
)
means
scale
:(
float
)
scale
;
/*
进行预测, 默认 means 为 0, scale 为 1.0
*/
-
(
NSArray
*
)
predict
:(
CGImageRef
)
image
dim
:(
NSArray
<
NSNumber
*>
*
)
dim
;
/*
清理内存
*/
-
(
void
)
clear
;
@end
metal/paddle-mobile/paddle-mobile/CPUCompute.h
浏览文件 @
d91c89dd
...
...
@@ -16,7 +16,6 @@
#import <Foundation/Foundation.h>
@interface
CPUResult
:
NSObject
@property
(
assign
,
nonatomic
)
float
*
output
;
@property
(
assign
,
nonatomic
)
int
outputSize
;
...
...
metal/paddle-mobile/paddle-mobile/CPUCompute.mm
浏览文件 @
d91c89dd
...
...
@@ -12,7 +12,6 @@
See the License for the specific language governing permissions and
limitations under the License. */
#import "CPUCompute.h"
#import <map>
...
...
@@ -20,9 +19,6 @@
#import <utility>
#import <algorithm>
struct
NMSParam
{
float
*
score_data
;
...
...
metal/paddle-mobile/paddle-mobile/MobileNet.swift
浏览文件 @
d91c89dd
...
...
@@ -14,7 +14,7 @@
import
Foundation
class
MobileNet
:
Net
{
public
class
MobileNet
:
Net
{
class
MobilenetPreProccess
:
CusomKernel
{
init
(
device
:
MTLDevice
)
{
...
...
@@ -53,13 +53,13 @@ class MobileNet: Net{
return
s
.
joined
(
separator
:
"
\n
"
)
}
override
init
(
device
:
MTLDevice
)
{
override
public
init
(
device
:
MTLDevice
)
{
super
.
init
(
device
:
device
)
means
=
[
123.68
,
116.78
,
103.94
]
scale
=
0.017
except
=
0
modelPath
=
Bundle
.
main
.
path
(
forResource
:
"model"
,
ofType
:
nil
)
?
!
"model null"
paramPath
=
Bundle
.
main
.
path
(
forResource
:
"params"
,
ofType
:
nil
)
?
!
"para null"
modelPath
=
Bundle
.
main
.
path
(
forResource
:
"mo
bilenet_mo
del"
,
ofType
:
nil
)
?
!
"model null"
paramPath
=
Bundle
.
main
.
path
(
forResource
:
"
mobilenet_
params"
,
ofType
:
nil
)
?
!
"para null"
modelDir
=
""
preprocessKernel
=
MobilenetPreProccess
.
init
(
device
:
device
)
inputDim_
=
Dim
.
init
(
inDim
:
[
1
,
224
,
224
,
3
])
...
...
metal/paddle-mobile/paddle-mobile/Net.swift
浏览文件 @
d91c89dd
...
...
@@ -33,6 +33,8 @@ public class ResultHolder: NSObject {
public
class
Net
:
NSObject
{
var
except
:
Int
=
0
// for CPU
var
means
:
[
Float
]
=
[]
var
scale
:
Float
=
0.0
...
...
@@ -69,7 +71,16 @@ public class Net: NSObject {
self
.
device
=
device
super
.
init
()
}
@objc
public
init
(
device
:
MTLDevice
)
{
self
.
device
=
device
super
.
init
()
}
@objc
public
func
updateInputDim
(
inDim
:
[
Int
])
{
inputDim
=
Dim
.
init
(
inDim
:
inDim
)
}
public
func
resultStr
(
res
:
ResultHolder
)
->
String
{
fatalError
()
}
...
...
@@ -78,12 +89,6 @@ public class Net: NSObject {
return
ResultHolder
.
init
(
inResult
:
paddleMobileRes
.
resultPointer
,
inCapacity
:
paddleMobileRes
.
capacity
)
}
@objc
public
init
(
device
:
MTLDevice
)
{
self
.
device
=
device
super
.
init
()
}
func
updateProgram
(
program
:
Program
)
{
}
}
metal/paddle-mobile/paddle-mobile/Operators/ResizeBilinearOp.swift
浏览文件 @
d91c89dd
...
...
@@ -29,8 +29,8 @@ class ResizeBilinearParam<P: PrecisionType>: OpParam {
throw
error
}
}
let
input
:
Texture
<
P
>
var
output
:
Texture
<
P
>
let
input
:
Texture
var
output
:
Texture
let
out_h
:
Int32
let
out_w
:
Int32
}
...
...
metal/paddle-mobile/paddle-mobile/PaddleMobileGPU.m
浏览文件 @
d91c89dd
...
...
@@ -12,9 +12,10 @@
See the License for the specific language governing permissions and
limitations under the License. */
#import <Foundation/Foundation.h>
#import "PaddleMobileGPU.h"
#import "paddle_mobile.h"
#import "PaddleMobileGPU.h"
#import <Foundation/Foundation.h>
#import <paddle_mobile/paddle_mobile-Swift.h>
@implementation
ModelConfig
...
...
@@ -59,7 +60,7 @@
}
else
if
(
netType
==
MobileNetType
)
{
}
runner
=
[[
Runner
alloc
]
initInNet
:
net
commandQueue
:
queue
inPlatform
:
PlatformGPU
];
runner
=
[[
Runner
alloc
]
initInNet
:
net
commandQueue
:
queue
];
}
return
self
;
}
...
...
metal/paddle-mobile/paddle-mobile/Runner.swift
浏览文件 @
d91c89dd
...
...
@@ -9,10 +9,6 @@
import
MetalKit
import
Foundation
@objc
public
enum
Platform
:
Int
{
case
CPU
,
GPU
}
class
ScaleKernel
:
CusomKernel
{
init
(
device
:
MTLDevice
,
shape
:
Shape
)
{
if
computePrecision
==
.
Float32
{
...
...
@@ -32,8 +28,6 @@ class ScaleKernel: CusomKernel {
var
textureLoader
:
MTKTextureLoader
?
public
let
net
:
Net
let
device
:
MTLDevice
?
let
platform
:
Platform
var
cpuPaddleMobile
:
PaddleMobileCPU
?
let
numel
:
Int
let
meansNumber
:
[
NSNumber
]
...
...
@@ -44,7 +38,7 @@ class ScaleKernel: CusomKernel {
* commandQueue: GPU 是需要传入
* inPlatform: 需要使用的平台, GPU or CPU
*/
@objc
public
init
(
inNet
:
Net
,
commandQueue
:
MTLCommandQueue
?
,
inPlatform
:
Platform
)
{
@objc
public
init
(
inNet
:
Net
,
commandQueue
:
MTLCommandQueue
?)
{
guard
inNet
.
inputDim
.
cout
()
==
4
else
{
fatalError
(
" input dim count must 4 "
)
}
...
...
@@ -52,14 +46,10 @@ class ScaleKernel: CusomKernel {
net
=
inNet
queue
=
commandQueue
device
=
queue
?
.
device
platform
=
inPlatform
if
let
inDevice
=
device
{
textureLoader
=
MTKTextureLoader
.
init
(
device
:
inDevice
)
}
if
platform
==
.
CPU
{
cpuPaddleMobile
=
PaddleMobileCPU
.
init
()
}
numel
=
net
.
inputDim
.
numel
()
meansNumber
=
net
.
means
.
map
{
NSNumber
.
init
(
value
:
$0
)
}
dimsNum
=
[
NSNumber
.
init
(
value
:
net
.
inputDim
[
0
]),
...
...
@@ -72,7 +62,6 @@ class ScaleKernel: CusomKernel {
* load 模型, 返回 true 可进行预测
*/
@objc
public
func
load
()
->
Bool
{
if
platform
==
.
GPU
{
guard
let
inDevice
=
device
,
let
inQueue
=
queue
else
{
print
(
" paddle mobile gpu load error, need MTLCommandQueue"
)
return
false
...
...
@@ -88,20 +77,9 @@ class ScaleKernel: CusomKernel {
print
(
error
)
return
false
}
}
else
{
return
cpuPaddleMobile
?
.
load
(
net
.
modelPath
,
andWeightsPath
:
net
.
paramPath
)
??
false
}
return
true
}
@objc
public
func
predict
(
inputPointer
:
UnsafeMutablePointer
<
Float32
>
,
completion
:
@escaping
(
_
success
:
Bool
,
_
result
:
PaddleMobileCPUResult
?)
->
Void
)
{
guard
let
res
=
cpuPaddleMobile
?
.
predictInput
(
inputPointer
,
dim
:
dimsNum
)
else
{
completion
(
false
,
nil
)
return
}
completion
(
true
,
res
)
}
/**
* GPU 版本 predict
* texture: 需要预测的 texture 需要做过预处理
...
...
@@ -124,57 +102,15 @@ class ScaleKernel: CusomKernel {
}
}
/**
* CPU GPU 通用版本 predict
* cgImage: 需要预测的图片
* ( _ success: Bool, _ time:TimeInterval, _ resultArray: [Float32]) -> Void : 回调闭包, 三个参数分别为: 是否成功, 预测耗时, 结果数组
*/
// @objc public func predict(cgImage: CGImage, completion: @escaping ( _ success: Bool, _ resultArray: [Float32]) -> Void) {
// if platform == .GPU {
// getTexture(image: cgImage) { [weak self] (texture) in
// guard let SSelf = self else {
// fatalError( "" )
// }
// SSelf.predict(texture: texture, completion: completion)
// }
// } else if platform == .CPU {
// let input = preproccess(image: cgImage)
// predict(inputPointer: input, completion: completion)
// input.deinitialize(count: numel)
// input.deallocate()
// }
// }
/*
* 清理内存, 调用此函数后, 不能再使用, 需重新 load
*/
@objc
public
func
clear
()
{
if
platform
==
.
GPU
{
executor
?
.
clear
()
executor
=
nil
program
=
nil
}
else
if
platform
==
.
CPU
{
cpuPaddleMobile
?
.
clear
()
}
}
@objc
public
func
preproccess
(
image
:
CGImage
)
->
UnsafeMutablePointer
<
Float
>
{
let
output
=
UnsafeMutablePointer
<
Float
>.
allocate
(
capacity
:
numel
)
let
means
=
net
.
means
.
map
{
NSNumber
.
init
(
value
:
$0
)
}
if
net
.
inputDim
.
cout
()
==
4
{
let
dims
=
[
NSNumber
.
init
(
value
:
net
.
inputDim
[
0
]),
NSNumber
.
init
(
value
:
net
.
inputDim
[
3
]),
NSNumber
.
init
(
value
:
net
.
inputDim
[
1
]),
NSNumber
.
init
(
value
:
net
.
inputDim
[
2
])]
cpuPaddleMobile
?
.
preprocess
(
image
,
output
:
output
,
means
:
means
,
scale
:
net
.
scale
,
dim
:
dims
)
return
output
}
fatalError
()
executor
?
.
clear
()
executor
=
nil
program
=
nil
}
/*
* 获取 texture, 对 texture 进行预处理, GPU 预测时使用
*/
...
...
metal/paddle-mobile/paddle-mobile/SuperResolutionNet.swift
浏览文件 @
d91c89dd
...
...
@@ -28,7 +28,8 @@ public class SuperResolutionNet: Net{
paramPath
=
Bundle
.
main
.
path
(
forResource
:
"super_params"
,
ofType
:
nil
)
?
!
"para null"
modelDir
=
""
preprocessKernel
=
nil
inputDim_
=
Dim
.
init
(
inDim
:
[
1
,
Int
(
552
*
1.414
),
Int
(
310
*
1.414
),
1
])
// inputDim_ = Dim.init(inDim: [1, Int(552 * 1.414), Int(310 * 1.414), 1])
inputDim_
=
Dim
.
init
(
inDim
:
[
1
,
224
,
224
,
1
])
}
override
func
updateProgram
(
program
:
Program
)
{
...
...
metal/paddle-mobile/paddle-mobile/framework/Executor.swift
浏览文件 @
d91c89dd
...
...
@@ -19,8 +19,7 @@ let testTo = 22
var
isTest
=
false
let
computePrecision
:
ComputePrecision
=
.
Float16
let
computePrecision
:
ComputePrecision
=
.
Float32
public
class
GPUResultHolder
{
public
let
dim
:
[
Int
]
public
let
capacity
:
Int
...
...
@@ -153,17 +152,18 @@ public class Executor<P: PrecisionType> {
/*
let inputArr = resInput.toTensor(dim: (n: dim[0], c: dim[3], h: dim[1], w: dim[2]))
print(dim)
writeToLibrary(fileName: "test_image_
ssd_ar
", array: inputArr)
writeToLibrary(fileName: "test_image_
yolo
", array: inputArr)
print(" write done ")
return
*/
/* 输出 op 计算结果
for op in SSelf.ops {
op.delogOutput()
op.delogOutput()
}
*/
let
afterDate
=
Date
.
init
()
var
resultHolder
:
GPUResultHolder
if
except
>
0
{
...
...
metal/paddle-mobile/paddle-mobile/paddle_mobile.h
浏览文件 @
d91c89dd
...
...
@@ -14,7 +14,6 @@
#pragma once
#import "PaddleMobileCPU.h"
#import "CPUCompute.h"
#import "PaddleMobileGPU.h"
#import <UIKit/UIKit.h>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录