Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
e2e2614d
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看板
提交
e2e2614d
编写于
3月 08, 2019
作者:
J
Jiaying Zhao
提交者:
GitHub
3月 08, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into develop
上级
f566d061
9cde4488
变更
71
隐藏空白更改
内联
并排
Showing
71 changed file
with
245 addition
and
231 deletion
+245
-231
metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj
...-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj
+16
-0
metal/paddle-mobile-demo/paddle-mobile-demo/Net/YoloNet.swift
...l/paddle-mobile-demo/paddle-mobile-demo/Net/YoloNet.swift
+4
-3
metal/paddle-mobile/paddle-mobile/API/GlobalConfig.swift
metal/paddle-mobile/paddle-mobile/API/GlobalConfig.swift
+2
-2
metal/paddle-mobile/paddle-mobile/API/Net.swift
metal/paddle-mobile/paddle-mobile/API/Net.swift
+3
-0
metal/paddle-mobile/paddle-mobile/API/Runner.swift
metal/paddle-mobile/paddle-mobile/API/Runner.swift
+17
-3
metal/paddle-mobile/paddle-mobile/Src/Common/MetalExtension.swift
...ddle-mobile/paddle-mobile/Src/Common/MetalExtension.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Common/Tools.swift
metal/paddle-mobile/paddle-mobile/Src/Common/Tools.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Common/Types.swift
metal/paddle-mobile/paddle-mobile/Src/Common/Types.swift
+25
-82
metal/paddle-mobile/paddle-mobile/Src/Framework/Executor.swift
.../paddle-mobile/paddle-mobile/Src/Framework/Executor.swift
+6
-1
metal/paddle-mobile/paddle-mobile/Src/Framework/Loader.swift
metal/paddle-mobile/paddle-mobile/Src/Framework/Loader.swift
+8
-3
metal/paddle-mobile/paddle-mobile/Src/Framework/Tensor.swift
metal/paddle-mobile/paddle-mobile/Src/Framework/Tensor.swift
+71
-44
metal/paddle-mobile/paddle-mobile/Src/Framework/Texture.swift
...l/paddle-mobile/paddle-mobile/Src/Framework/Texture.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/Base/OpCreator.swift
...e-mobile/paddle-mobile/Src/Operators/Base/OpCreator.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Base/OpParam.swift
...dle-mobile/paddle-mobile/Src/Operators/Base/OpParam.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/BatchNormOp.swift
...ddle-mobile/paddle-mobile/Src/Operators/BatchNormOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/BilinearInterpOp.swift
...mobile/paddle-mobile/Src/Operators/BilinearInterpOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/BoxcoderOp.swift
...addle-mobile/paddle-mobile/Src/Operators/BoxcoderOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConcatOp.swift
.../paddle-mobile/paddle-mobile/Src/Operators/ConcatOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddAddPreluOp.swift
...obile/paddle-mobile/Src/Operators/ConvAddAddPreluOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddBatchNormReluOp.swift
.../paddle-mobile/Src/Operators/ConvAddBatchNormReluOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddOp.swift
...paddle-mobile/paddle-mobile/Src/Operators/ConvAddOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddPreluOp.swift
...e-mobile/paddle-mobile/Src/Operators/ConvAddPreluOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvBNReluOp.swift
...dle-mobile/paddle-mobile/Src/Operators/ConvBNReluOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvOp.swift
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvTransposeOp.swift
...-mobile/paddle-mobile/Src/Operators/ConvTransposeOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/DepthwiseConvOp.swift
...-mobile/paddle-mobile/Src/Operators/DepthwiseConvOp.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/DwConvBNReluOp.swift
...e-mobile/paddle-mobile/Src/Operators/DwConvBNReluOp.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/ElementwiseAddOp.swift
...mobile/paddle-mobile/Src/Operators/ElementwiseAddOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ElementwiseAddPreluOp.swift
...e/paddle-mobile/Src/Operators/ElementwiseAddPreluOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/FeedOp.swift
metal/paddle-mobile/paddle-mobile/Src/Operators/FeedOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/FetchOp.swift
...l/paddle-mobile/paddle-mobile/Src/Operators/FetchOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/FlattenOp.swift
...paddle-mobile/paddle-mobile/Src/Operators/FlattenOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/BatchNormKernel.swift
...paddle-mobile/Src/Operators/Kernels/BatchNormKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/BilinearInterpKernel.swift
...e-mobile/Src/Operators/Kernels/BilinearInterpKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/BoxcoderKernel.swift
.../paddle-mobile/Src/Operators/Kernels/BoxcoderKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConcatKernel.swift
...le/paddle-mobile/Src/Operators/Kernels/ConcatKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddAddPreluKernel.swift
...-mobile/Src/Operators/Kernels/ConvAddAddPreluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddBatchNormReluKernel.swift
...le/Src/Operators/Kernels/ConvAddBatchNormReluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddKernel.swift
...e/paddle-mobile/Src/Operators/Kernels/ConvAddKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddPreluKernel.swift
...dle-mobile/Src/Operators/Kernels/ConvAddPreluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvBNReluKernel.swift
...addle-mobile/Src/Operators/Kernels/ConvBNReluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvKernel.swift
...bile/paddle-mobile/Src/Operators/Kernels/ConvKernel.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvTransposeKernel.swift
...le-mobile/Src/Operators/Kernels/ConvTransposeKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ElementwiseAddKernel.swift
...e-mobile/Src/Operators/Kernels/ElementwiseAddKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ElementwiseAddPreluKernel.swift
...ile/Src/Operators/Kernels/ElementwiseAddPreluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/FetchKernel.swift
...ile/paddle-mobile/Src/Operators/Kernels/FetchKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/FlattenKernel.swift
...e/paddle-mobile/Src/Operators/Kernels/FlattenKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/MulticlassNMSKernel.swift
...le-mobile/Src/Operators/Kernels/MulticlassNMSKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/PoolKernel.swift
...bile/paddle-mobile/Src/Operators/Kernels/PoolKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/PreluKernel.swift
...ile/paddle-mobile/Src/Operators/Kernels/PreluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/PriorBoxKernel.swift
.../paddle-mobile/Src/Operators/Kernels/PriorBoxKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ReluKernel.swift
...bile/paddle-mobile/Src/Operators/Kernels/ReluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ReshapeKernel.swift
...e/paddle-mobile/Src/Operators/Kernels/ReshapeKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ResizeBilinearKernel.swift
...e-mobile/Src/Operators/Kernels/ResizeBilinearKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ShapeKernel.swift
...ile/paddle-mobile/Src/Operators/Kernels/ShapeKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/SoftmaxKernel.swift
...e/paddle-mobile/Src/Operators/Kernels/SoftmaxKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/SplitKernel.swift
...ile/paddle-mobile/Src/Operators/Kernels/SplitKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/Texture2DTo2DArrayKernel.swift
...bile/Src/Operators/Kernels/Texture2DTo2DArrayKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/TransposeKernel.swift
...paddle-mobile/Src/Operators/Kernels/TransposeKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Src/Operators/MulticlassNMSOp.swift
...-mobile/paddle-mobile/Src/Operators/MulticlassNMSOp.swift
+4
-4
metal/paddle-mobile/paddle-mobile/Src/Operators/PoolOp.swift
metal/paddle-mobile/paddle-mobile/Src/Operators/PoolOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/PreluOp.swift
...l/paddle-mobile/paddle-mobile/Src/Operators/PreluOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/PriorBoxOp.swift
...addle-mobile/paddle-mobile/Src/Operators/PriorBoxOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ReluOp.swift
metal/paddle-mobile/paddle-mobile/Src/Operators/ReluOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ReshapeOp.swift
...paddle-mobile/paddle-mobile/Src/Operators/ReshapeOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ResizeBilinearOp.swift
...mobile/paddle-mobile/Src/Operators/ResizeBilinearOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/ShapeOp.swift
...l/paddle-mobile/paddle-mobile/Src/Operators/ShapeOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/SoftmaxOp.swift
...paddle-mobile/paddle-mobile/Src/Operators/SoftmaxOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/SplitOp.swift
...l/paddle-mobile/paddle-mobile/Src/Operators/SplitOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Operators/TransposeOp.swift
...ddle-mobile/paddle-mobile/Src/Operators/TransposeOp.swift
+2
-2
metal/paddle-mobile/paddle-mobile/Src/Program/ProgramOptimize.swift
...le-mobile/paddle-mobile/Src/Program/ProgramOptimize.swift
+1
-1
未找到文件。
metal/paddle-mobile-demo/paddle-mobile-demo.xcodeproj/project.pbxproj
浏览文件 @
e2e2614d
...
@@ -44,6 +44,8 @@
...
@@ -44,6 +44,8 @@
FC9797C321D608E000F2FD90
/* mobilenet_params in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C121D608DF00F2FD90
/* mobilenet_params */
;
};
FC9797C321D608E000F2FD90
/* mobilenet_params in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C121D608DF00F2FD90
/* mobilenet_params */
;
};
FC9797C721D609FB00F2FD90
/* synset.txt in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C621D609FB00F2FD90
/* synset.txt */
;
};
FC9797C721D609FB00F2FD90
/* synset.txt in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797C621D609FB00F2FD90
/* synset.txt */
;
};
FC9797CF21D6506F00F2FD90
/* mingren.jpg in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797CE21D6506F00F2FD90
/* mingren.jpg */
;
};
FC9797CF21D6506F00F2FD90
/* mingren.jpg in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FC9797CE21D6506F00F2FD90
/* mingren.jpg */
;
};
FCAFD84B2231614200496A36
/* yolo_16_param in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCAFD8492231614200496A36
/* yolo_16_param */
;
};
FCAFD84C2231614200496A36
/* yolo_16_model in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCAFD84A2231614200496A36
/* yolo_16_model */
;
};
FCBCCC552122EF5500D94F7E
/* MetalHelper.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCBCCC542122EF5400D94F7E
/* MetalHelper.swift */
;
};
FCBCCC552122EF5500D94F7E
/* MetalHelper.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCBCCC542122EF5400D94F7E
/* MetalHelper.swift */
;
};
FCC15E15221E716500DC3CB2
/* paddle-mobile-metallib.metallib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCC15E14221E716400DC3CB2
/* paddle-mobile-metallib.metallib */
;
};
FCC15E15221E716500DC3CB2
/* paddle-mobile-metallib.metallib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCC15E14221E716400DC3CB2
/* paddle-mobile-metallib.metallib */
;
};
FCCED60521D7646E00BE8D5F
/* test_image_super in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCCED60421D7646E00BE8D5F
/* test_image_super */
;
};
FCCED60521D7646E00BE8D5F
/* test_image_super in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
FCCED60421D7646E00BE8D5F
/* test_image_super */
;
};
...
@@ -114,6 +116,8 @@
...
@@ -114,6 +116,8 @@
FC9797C121D608DF00F2FD90
/* mobilenet_params */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
mobilenet_params
;
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>"
;
};
FC9797C621D609FB00F2FD90
/* synset.txt */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
text
;
path
=
synset.txt
;
sourceTree
=
"<group>"
;
};
FC9797CE21D6506F00F2FD90
/* mingren.jpg */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
image.jpeg
;
path
=
mingren.jpg
;
sourceTree
=
"<group>"
;
};
FC9797CE21D6506F00F2FD90
/* mingren.jpg */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
image.jpeg
;
path
=
mingren.jpg
;
sourceTree
=
"<group>"
;
};
FCAFD8492231614200496A36
/* yolo_16_param */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
yolo_16_param
;
sourceTree
=
"<group>"
;
};
FCAFD84A2231614200496A36
/* yolo_16_model */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
yolo_16_model
;
sourceTree
=
"<group>"
;
};
FCBCCC542122EF5400D94F7E
/* MetalHelper.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MetalHelper.swift
;
sourceTree
=
"<group>"
;
};
FCBCCC542122EF5400D94F7E
/* MetalHelper.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MetalHelper.swift
;
sourceTree
=
"<group>"
;
};
FCC15E14221E716400DC3CB2
/* paddle-mobile-metallib.metallib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"archive.metal-library"
;
name
=
"paddle-mobile-metallib.metallib"
;
path
=
"../../../../Library/Developer/Xcode/DerivedData/paddle-mobile-hdsimtkoxoondndnjczkbkchcwyh/Build/Products/Release-iphoneos/paddle-mobile-metallib.metallib"
;
sourceTree
=
"<group>"
;
};
FCC15E14221E716400DC3CB2
/* paddle-mobile-metallib.metallib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
"archive.metal-library"
;
name
=
"paddle-mobile-metallib.metallib"
;
path
=
"../../../../Library/Developer/Xcode/DerivedData/paddle-mobile-hdsimtkoxoondndnjczkbkchcwyh/Build/Products/Release-iphoneos/paddle-mobile-metallib.metallib"
;
sourceTree
=
"<group>"
;
};
FCCED60421D7646E00BE8D5F
/* test_image_super */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
test_image_super
;
sourceTree
=
"<group>"
;
};
FCCED60421D7646E00BE8D5F
/* test_image_super */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
test_image_super
;
sourceTree
=
"<group>"
;
};
...
@@ -263,6 +267,7 @@
...
@@ -263,6 +267,7 @@
FC704C1B21D237FC00F98BAB
/* vision_model */
=
{
FC704C1B21D237FC00F98BAB
/* vision_model */
=
{
isa
=
PBXGroup
;
isa
=
PBXGroup
;
children
=
(
children
=
(
FCAFD8482231614200496A36
/* yolo_16 */
,
FC704C1C21D237FC00F98BAB
/* mobilenet */
,
FC704C1C21D237FC00F98BAB
/* mobilenet */
,
FC704C1F21D237FC00F98BAB
/* yolo */
,
FC704C1F21D237FC00F98BAB
/* yolo */
,
);
);
...
@@ -322,6 +327,15 @@
...
@@ -322,6 +327,15 @@
path
=
mobilenet
;
path
=
mobilenet
;
sourceTree
=
"<group>"
;
sourceTree
=
"<group>"
;
};
};
FCAFD8482231614200496A36
/* yolo_16 */
=
{
isa
=
PBXGroup
;
children
=
(
FCAFD8492231614200496A36
/* yolo_16_param */
,
FCAFD84A2231614200496A36
/* yolo_16_model */
,
);
path
=
yolo_16
;
sourceTree
=
"<group>"
;
};
/* End PBXGroup section */
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
/* Begin PBXNativeTarget section */
...
@@ -388,6 +402,7 @@
...
@@ -388,6 +402,7 @@
FC039B8C20E11C560081E9F8
/* LaunchScreen.storyboard in Resources */
,
FC039B8C20E11C560081E9F8
/* LaunchScreen.storyboard in Resources */
,
FC9797CF21D6506F00F2FD90
/* mingren.jpg in Resources */
,
FC9797CF21D6506F00F2FD90
/* mingren.jpg in Resources */
,
FC704C2221D237FC00F98BAB
/* combined_mobilenet_params in Resources */
,
FC704C2221D237FC00F98BAB
/* combined_mobilenet_params in Resources */
,
FCAFD84B2231614200496A36
/* yolo_16_param in Resources */
,
FC704C1921D2375300F98BAB
/* super_params in Resources */
,
FC704C1921D2375300F98BAB
/* super_params in Resources */
,
FC2BFCBE21DF15D900C262B2
/* 123.jpg in Resources */
,
FC2BFCBE21DF15D900C262B2
/* 123.jpg in Resources */
,
FC039B8920E11C560081E9F8
/* Assets.xcassets in Resources */
,
FC039B8920E11C560081E9F8
/* Assets.xcassets in Resources */
,
...
@@ -397,6 +412,7 @@
...
@@ -397,6 +412,7 @@
FC704C1A21D2375300F98BAB
/* super_model in Resources */
,
FC704C1A21D2375300F98BAB
/* super_model in Resources */
,
FC039B8720E11C550081E9F8
/* Main.storyboard in Resources */
,
FC039B8720E11C550081E9F8
/* Main.storyboard in Resources */
,
FC9797C221D608E000F2FD90
/* mobilenet_model in Resources */
,
FC9797C221D608E000F2FD90
/* mobilenet_model in Resources */
,
FCAFD84C2231614200496A36
/* yolo_16_model in Resources */
,
FC2BFCC021DF279900C262B2
/* classify-img-output.png in Resources */
,
FC2BFCC021DF279900C262B2
/* classify-img-output.png in Resources */
,
FC203FB221CBFDBA00B37166
/* test.jpg in Resources */
,
FC203FB221CBFDBA00B37166
/* test.jpg in Resources */
,
FCC15E15221E716500DC3CB2
/* paddle-mobile-metallib.metallib in Resources */
,
FCC15E15221E716500DC3CB2
/* paddle-mobile-metallib.metallib in Resources */
,
...
...
metal/paddle-mobile-demo/paddle-mobile-demo/Net/YoloNet.swift
浏览文件 @
e2e2614d
...
@@ -20,12 +20,13 @@ public class YoloNet: Net {
...
@@ -20,12 +20,13 @@ public class YoloNet: Net {
@objc
public
override
init
(
device
:
MTLDevice
)
{
@objc
public
override
init
(
device
:
MTLDevice
)
{
super
.
init
(
device
:
device
)
super
.
init
(
device
:
device
)
except
=
0
except
=
0
modelPath
=
Bundle
.
main
.
path
(
forResource
:
"yolo_model"
,
ofType
:
nil
)
?
!
"model null"
modelPath
=
Bundle
.
main
.
path
(
forResource
:
"yolo_
16_
model"
,
ofType
:
nil
)
?
!
"model null"
paramPath
=
Bundle
.
main
.
path
(
forResource
:
"yolo_
params
"
,
ofType
:
nil
)
?
!
"para null"
paramPath
=
Bundle
.
main
.
path
(
forResource
:
"yolo_
16_param
"
,
ofType
:
nil
)
?
!
"para null"
inputDim
=
Dim
.
init
(
inDim
:
[
1
,
416
,
416
,
3
])
inputDim
=
Dim
.
init
(
inDim
:
[
1
,
416
,
416
,
3
])
metalLoadMode
=
.
LoadMetalInCustomMetalLib
metalLoadMode
=
.
LoadMetalInCustomMetalLib
metalLibPath
=
Bundle
.
main
.
path
(
forResource
:
"paddle-mobile-metallib"
,
ofType
:
"metallib"
)
metalLibPath
=
Bundle
.
main
.
path
(
forResource
:
"paddle-mobile-metallib"
,
ofType
:
"metallib"
)
useMPS
=
true
useMPS
=
false
paramPrecision
=
.
Float16
}
}
override
public
func
resultStr
(
res
:
[
ResultHolder
])
->
String
{
override
public
func
resultStr
(
res
:
[
ResultHolder
])
->
String
{
...
...
metal/paddle-mobile/paddle-mobile/API/GlobalConfig.swift
浏览文件 @
e2e2614d
...
@@ -21,7 +21,7 @@ import Foundation
...
@@ -21,7 +21,7 @@ import Foundation
LoadMetalInCustomMetalLib
=
3
// 使用 metal 库文件
LoadMetalInCustomMetalLib
=
3
// 使用 metal 库文件
}
}
@objc
public
enum
Compute
Precision
:
Int
{
@objc
public
enum
Precision
:
Int
{
case
case
Float32
=
1
,
Float32
=
1
,
Float16
=
2
Float16
=
2
...
@@ -33,7 +33,7 @@ import Foundation
...
@@ -33,7 +33,7 @@ import Foundation
@objc
public
static
let
shared
:
GlobalConfig
=
GlobalConfig
.
init
()
@objc
public
static
let
shared
:
GlobalConfig
=
GlobalConfig
.
init
()
/// 运算精度, runner 生命周期中不可变
/// 运算精度, runner 生命周期中不可变
@objc
public
var
computePrecision
:
Compute
Precision
=
.
Float16
@objc
public
var
computePrecision
:
Precision
=
.
Float16
/// 是否开启 log
/// 是否开启 log
@objc
public
var
debug
:
Bool
=
false
@objc
public
var
debug
:
Bool
=
false
...
...
metal/paddle-mobile/paddle-mobile/API/Net.swift
浏览文件 @
e2e2614d
...
@@ -59,6 +59,9 @@ import Foundation
...
@@ -59,6 +59,9 @@ import Foundation
/// 是否使用 MetalPerformanceShaders 进行运算
/// 是否使用 MetalPerformanceShaders 进行运算
@objc
public
var
useMPS
:
Bool
=
false
@objc
public
var
useMPS
:
Bool
=
false
/// 模型精度 - 当使用模型精度为 Float 16 时 不要开启 useMPS, 暂不支持
@objc
public
var
paramPrecision
:
Precision
=
.
Float32
@objc
public
init
(
device
:
MTLDevice
,
inParamPointer
:
UnsafeMutableRawPointer
,
inParamSize
:
Int
,
inModelPointer
:
UnsafeMutableRawPointer
,
inModelSize
:
Int
)
{
@objc
public
init
(
device
:
MTLDevice
,
inParamPointer
:
UnsafeMutableRawPointer
,
inParamSize
:
Int
,
inModelPointer
:
UnsafeMutableRawPointer
,
inModelSize
:
Int
)
{
self
.
paramPointer
=
inParamPointer
self
.
paramPointer
=
inParamPointer
self
.
paramSize
=
inParamSize
self
.
paramSize
=
inParamSize
...
...
metal/paddle-mobile/paddle-mobile/API/Runner.swift
浏览文件 @
e2e2614d
...
@@ -34,7 +34,7 @@ import Foundation
...
@@ -34,7 +34,7 @@ import Foundation
@objc
public
class
Runner
:
NSObject
{
@objc
public
class
Runner
:
NSObject
{
var
program
:
Program
?
var
program
:
Program
?
var
executor
:
Executor
<
Float32
>
?
var
executor
:
Executor
able
?
var
queue
:
MTLCommandQueue
?
var
queue
:
MTLCommandQueue
?
var
textureLoader
:
MTKTextureLoader
?
var
textureLoader
:
MTKTextureLoader
?
public
let
net
:
Net
public
let
net
:
Net
...
@@ -68,7 +68,14 @@ import Foundation
...
@@ -68,7 +68,14 @@ import Foundation
print
(
" paddle mobile gpu load error, need MTLCommandQueue"
)
print
(
" paddle mobile gpu load error, need MTLCommandQueue"
)
return
false
return
false
}
}
let
loader
=
Loader
<
Float32
>.
init
()
var
loader
:
Loaderable
switch
net
.
paramPrecision
{
case
.
Float16
:
loader
=
Loader
<
Float16
>.
init
()
case
.
Float32
:
loader
=
Loader
<
Float32
>.
init
()
}
do
{
do
{
if
let
inParamPointer
=
net
.
paramPointer
,
let
inModelPointer
=
net
.
modelPointer
{
if
let
inParamPointer
=
net
.
paramPointer
,
let
inModelPointer
=
net
.
modelPointer
{
...
@@ -89,7 +96,13 @@ import Foundation
...
@@ -89,7 +96,13 @@ import Foundation
initContext
.
metalLibPath
=
net
.
metalLibPath
initContext
.
metalLibPath
=
net
.
metalLibPath
initContext
.
useMPS
=
net
.
useMPS
initContext
.
useMPS
=
net
.
useMPS
executor
=
try
Executor
<
Float32
>.
init
(
inDevice
:
inDevice
,
inQueue
:
inQueue
,
inProgram
:
program
!
,
initContext
:
initContext
)
switch
net
.
paramPrecision
{
case
.
Float16
:
executor
=
try
Executor
<
Float16
>.
init
(
inDevice
:
inDevice
,
inQueue
:
inQueue
,
inProgram
:
program
!
,
initContext
:
initContext
)
case
.
Float32
:
executor
=
try
Executor
<
Float32
>.
init
(
inDevice
:
inDevice
,
inQueue
:
inQueue
,
inProgram
:
program
!
,
initContext
:
initContext
)
}
net
.
updateProgram
(
program
:
program
!
)
net
.
updateProgram
(
program
:
program
!
)
}
catch
let
error
{
}
catch
let
error
{
print
(
error
)
print
(
error
)
...
@@ -105,6 +118,7 @@ import Foundation
...
@@ -105,6 +118,7 @@ import Foundation
/// - completion: 结果回调, 当 success 为 true 时 result 不为 nil
/// - completion: 结果回调, 当 success 为 true 时 result 不为 nil
@objc
public
func
predict
(
texture
:
MTLTexture
,
completion
:
@escaping
(
_
success
:
Bool
,
_
result
:
[
ResultHolder
]?)
->
Void
)
{
@objc
public
func
predict
(
texture
:
MTLTexture
,
completion
:
@escaping
(
_
success
:
Bool
,
_
result
:
[
ResultHolder
]?)
->
Void
)
{
do
{
do
{
try
self
.
executor
?
.
predict
(
input
:
texture
,
dim
:
self
.
net
.
inputDim
,
completionHandle
:
{
[
weak
self
]
(
res
)
in
try
self
.
executor
?
.
predict
(
input
:
texture
,
dim
:
self
.
net
.
inputDim
,
completionHandle
:
{
[
weak
self
]
(
res
)
in
guard
let
SSelf
=
self
else
{
guard
let
SSelf
=
self
else
{
fatalError
(
" self nil "
)
fatalError
(
" self nil "
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Common/MetalExtension.swift
浏览文件 @
e2e2614d
...
@@ -254,7 +254,7 @@ extension MTLDevice {
...
@@ -254,7 +254,7 @@ extension MTLDevice {
return
tensor
return
tensor
}
}
func
tensor2texture
<
P
>
(
value
:
[
P
],
dim
:
[
Int
],
transpose
:
[
Int
]
=
[
0
,
1
,
2
,
3
],
inComputePrecision
:
Compute
Precision
=
.
Float32
)
->
MTLTexture
{
func
tensor2texture
<
P
>
(
value
:
[
P
],
dim
:
[
Int
],
transpose
:
[
Int
]
=
[
0
,
1
,
2
,
3
],
inComputePrecision
:
Precision
=
.
Float32
)
->
MTLTexture
{
if
value
.
count
>
0
{
if
value
.
count
>
0
{
assert
(
value
.
count
==
dim
.
reduce
(
1
)
{
$0
*
$1
})
assert
(
value
.
count
==
dim
.
reduce
(
1
)
{
$0
*
$1
})
}
}
...
...
metal/paddle-mobile/paddle-mobile/Src/Common/Tools.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
func
writeToLibrary
<
P
:
Precision
Type
>
(
fileName
:
String
,
array
:
[
P
])
{
func
writeToLibrary
<
P
:
Precision
Protocol
>
(
fileName
:
String
,
array
:
[
P
])
{
let
libraryPath
=
NSSearchPathForDirectoriesInDomains
(
.
libraryDirectory
,
.
userDomainMask
,
true
)
.
last
?
!
" library path get error "
let
libraryPath
=
NSSearchPathForDirectoriesInDomains
(
.
libraryDirectory
,
.
userDomainMask
,
true
)
.
last
?
!
" library path get error "
let
filePath
=
libraryPath
+
"/"
+
fileName
let
filePath
=
libraryPath
+
"/"
+
fileName
let
fileManager
=
FileManager
.
init
()
let
fileManager
=
FileManager
.
init
()
...
...
metal/paddle-mobile/paddle-mobile/Src/Common/Types.swift
浏览文件 @
e2e2614d
...
@@ -20,20 +20,28 @@ public protocol SummableMultipliable: Equatable {
...
@@ -20,20 +20,28 @@ public protocol SummableMultipliable: Equatable {
static
func
*
(
lhs
:
Self
,
rhs
:
Self
)
->
Self
static
func
*
(
lhs
:
Self
,
rhs
:
Self
)
->
Self
static
func
-
(
lhs
:
Self
,
rhs
:
Self
)
->
Self
static
func
-
(
lhs
:
Self
,
rhs
:
Self
)
->
Self
}
}
public
protocol
PrecisionType
:
SummableMultipliable
{
public
protocol
PrecisionProtocol
:
SummableMultipliable
{
init
(
inFloat
:
Float32
)
init
(
inFloat
:
Float32
)
init
(
inFloat16
:
Float16
)
init
(
inFloat16
:
Float16
)
init
<
P
:
Precision
Type
>
(
_
inP
:
P
)
init
<
P
:
Precision
Protocol
>
(
_
inP
:
P
)
static
var
bitSize
:
UInt
{
get
}
static
var
bitSize
:
UInt
{
get
}
static
func
initializeValue
()
->
Self
static
var
precisionType
:
Precision
{
get
}
}
}
public
typealias
Float16
=
Int16
public
typealias
Float16
=
Int16
extension
Float16
:
PrecisionType
{
extension
Float16
:
PrecisionProtocol
{
public
static
func
*
(
prefix
:
Float16
,
postfix
:
Float16
)
{
return
prefix
*
postfix
public
static
var
precisionType
:
Precision
{
return
.
Float16
}
}
public
init
<
P
>
(
_
inP
:
P
)
where
P
:
PrecisionType
{
public
static
func
initializeValue
()
->
Int16
{
return
0
}
public
init
<
P
>
(
_
inP
:
P
)
where
P
:
PrecisionProtocol
{
if
P
.
bitSize
==
Float32
.
bitSize
{
if
P
.
bitSize
==
Float32
.
bitSize
{
self
=
Float16
(
inFloat
:
inP
as!
Float32
)
self
=
Float16
(
inFloat
:
inP
as!
Float32
)
}
else
if
P
.
bitSize
==
Float16
.
bitSize
{
}
else
if
P
.
bitSize
==
Float16
.
bitSize
{
...
@@ -55,8 +63,17 @@ extension Float16: PrecisionType {
...
@@ -55,8 +63,17 @@ extension Float16: PrecisionType {
}
}
}
}
extension
Float32
:
PrecisionType
{
extension
Float32
:
PrecisionProtocol
{
public
init
<
P
>
(
_
inP
:
P
)
where
P
:
PrecisionType
{
public
static
var
precisionType
:
Precision
{
return
.
Float32
}
public
static
func
initializeValue
()
->
Float
{
return
0.0
}
public
init
<
P
>
(
_
inP
:
P
)
where
P
:
PrecisionProtocol
{
if
P
.
bitSize
==
Float32
.
bitSize
{
if
P
.
bitSize
==
Float32
.
bitSize
{
self
=
inP
as!
Float32
self
=
inP
as!
Float32
}
else
if
P
.
bitSize
==
Float16
.
bitSize
{
}
else
if
P
.
bitSize
==
Float16
.
bitSize
{
...
@@ -116,80 +133,6 @@ struct DataLayout {
...
@@ -116,80 +133,6 @@ struct DataLayout {
return
layoutWithDim
.
count
return
layoutWithDim
.
count
}
}
var
N
:
Int
?
{
get
{
for
layoutDim
in
layoutWithDim
{
if
layoutDim
.
0
==
.
N
{
return
layoutDim
.
1
}
}
return
nil
}
set
{
var
newN
=
(
Layout
.
N
,
newValue
)
if
let
index
=
layoutWithDim
.
index
(
where
:
{
(
layout
:
Layout
,
dim
:
Int
)
->
Bool
in
return
layout
==
.
N
})
{
fatalError
()
}
}
}
var
C
:
Int
?
{
get
{
for
layoutDim
in
layoutWithDim
{
if
layoutDim
.
0
==
.
C
{
return
layoutDim
.
1
}
}
return
nil
}
set
{
var
newN
=
(
Layout
.
C
,
newValue
)
if
let
index
=
layoutWithDim
.
index
(
where
:
{
(
layout
:
Layout
,
dim
:
Int
)
->
Bool
in
return
layout
==
.
N
})
{
fatalError
()
}
}
}
var
H
:
Int
?
{
get
{
for
layoutDim
in
layoutWithDim
{
if
layoutDim
.
0
==
.
H
{
return
layoutDim
.
1
}
}
return
nil
}
set
{
var
newN
=
(
Layout
.
H
,
newValue
)
if
let
index
=
layoutWithDim
.
index
(
where
:
{
(
layout
:
Layout
,
dim
:
Int
)
->
Bool
in
return
layout
==
.
H
})
{
fatalError
()
}
}
}
var
W
:
Int
?
{
get
{
for
layoutDim
in
layoutWithDim
{
if
layoutDim
.
0
==
.
W
{
return
layoutDim
.
1
}
}
return
nil
}
set
{
var
newN
=
(
Layout
.
W
,
newValue
)
if
let
index
=
layoutWithDim
.
index
(
where
:
{
(
layout
:
Layout
,
dim
:
Int
)
->
Bool
in
return
layout
==
.
W
})
{
fatalError
()
}
}
}
init
(
_
inLayout
:
[(
Layout
,
Int
)])
{
init
(
_
inLayout
:
[(
Layout
,
Int
)])
{
layoutWithDim
=
inLayout
layoutWithDim
=
inLayout
}
}
...
...
metal/paddle-mobile/paddle-mobile/Src/Framework/Executor.swift
浏览文件 @
e2e2614d
...
@@ -41,7 +41,12 @@ var isTest = false
...
@@ -41,7 +41,12 @@ var isTest = false
}
}
public
class
Executor
<
P
:
PrecisionType
>
{
protocol
Executorable
{
func
predict
(
input
:
MTLTexture
,
dim
:
Dim
,
completionHandle
:
@escaping
([
GPUResultHolder
])
->
Void
,
preProcessKernle
:
CusomKernel
?,
except
:
Int
)
throws
func
clear
()
}
public
class
Executor
<
P
:
PrecisionProtocol
>
:
Executorable
{
var
ops
:
[
Runable
&
InferShaperable
]
=
[]
var
ops
:
[
Runable
&
InferShaperable
]
=
[]
var
preInputDim
:
Dim
=
Dim
.
init
(
inDim
:
[])
var
preInputDim
:
Dim
=
Dim
.
init
(
inDim
:
[])
let
program
:
Program
let
program
:
Program
...
...
metal/paddle-mobile/paddle-mobile/Src/Framework/Loader.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,12 @@
...
@@ -15,7 +15,12 @@
import
Foundation
import
Foundation
//import SwiftProtobuf
//import SwiftProtobuf
public
class
Loader
<
P
:
PrecisionType
>
{
protocol
Loaderable
{
func
load
(
device
:
MTLDevice
,
paramPointer
:
UnsafeMutableRawPointer
,
paramSize
:
Int
,
modePointer
:
UnsafeMutableRawPointer
,
modelSize
:
Int
)
throws
->
Program
func
load
(
device
:
MTLDevice
,
modelPath
:
String
,
paraPath
:
String
)
throws
->
Program
}
public
class
Loader
<
P
:
PrecisionProtocol
>
:
Loaderable
{
class
ParaLoader
{
class
ParaLoader
{
let
file
:
UnsafeMutablePointer
<
FILE
>
let
file
:
UnsafeMutablePointer
<
FILE
>
let
fileSize
:
Int
let
fileSize
:
Int
...
@@ -143,7 +148,7 @@ public class Loader<P: PrecisionType> {
...
@@ -143,7 +148,7 @@ public class Loader<P: PrecisionType> {
}
}
}
}
public
init
(){}
public
init
(){}
func
loadModelandParam
(
_
device
:
MTLDevice
,
_
modelData
:
Data
,
_
paraLoaderPointer
:
ParaLoaderWithPointer
?,
_
paraLoader
:
ParaLoader
?)
throws
->
Program
{
private
func
loadModelandParam
(
_
device
:
MTLDevice
,
_
modelData
:
Data
,
_
paraLoaderPointer
:
ParaLoaderWithPointer
?,
_
paraLoader
:
ParaLoader
?)
throws
->
Program
{
do
{
do
{
/// swift protobuf serialized Data to instance class
/// swift protobuf serialized Data to instance class
// let protoProgram = try PaddleMobile_Framework_Proto_ProgramDesc.init(
// let protoProgram = try PaddleMobile_Framework_Proto_ProgramDesc.init(
...
@@ -248,7 +253,7 @@ public class Loader<P: PrecisionType> {
...
@@ -248,7 +253,7 @@ public class Loader<P: PrecisionType> {
}
}
}
}
public
func
load
(
device
:
MTLDevice
,
modelPath
:
String
,
paraPath
:
String
)
throws
->
Program
{
public
func
load
(
device
:
MTLDevice
,
modelPath
:
String
,
paraPath
:
String
)
throws
->
Program
{
guard
let
modelData
=
try
?
Data
.
init
(
contentsOf
:
URL
.
init
(
fileURLWithPath
:
modelPath
))
else
{
guard
let
modelData
=
try
?
Data
.
init
(
contentsOf
:
URL
.
init
(
fileURLWithPath
:
modelPath
))
else
{
throw
PaddleMobileError
.
loaderError
(
message
:
"load "
+
modelPath
+
" failed !"
)
throw
PaddleMobileError
.
loaderError
(
message
:
"load "
+
modelPath
+
" failed !"
)
}
}
...
...
metal/paddle-mobile/paddle-mobile/Src/Framework/Tensor.swift
浏览文件 @
e2e2614d
...
@@ -28,7 +28,7 @@ extension Tensorial {
...
@@ -28,7 +28,7 @@ extension Tensorial {
}
}
}
}
class
DataConverter
<
P
:
Precision
Type
>
{
class
DataConverter
<
P
:
Precision
Protocol
>
{
func
convert
(
from
:
UnsafeMutablePointer
<
P
>
,
to
:
UnsafeMutablePointer
<
P
>
,
fromDim
:
Dim
)
{
func
convert
(
from
:
UnsafeMutablePointer
<
P
>
,
to
:
UnsafeMutablePointer
<
P
>
,
fromDim
:
Dim
)
{
fatalError
(
" need imp"
)
fatalError
(
" need imp"
)
}
}
...
@@ -40,7 +40,7 @@ class DataConverter<P: PrecisionType> {
...
@@ -40,7 +40,7 @@ class DataConverter<P: PrecisionType> {
/// [ outputChannels ][ inputChannels ][ kernelHeight ][ kernelWidth ] ->
/// [ outputChannels ][ inputChannels ][ kernelHeight ][ kernelWidth ] ->
/// [ outputChannels ][ kernelHeight ][ kernelWidth ][ inputChannels ]
/// [ outputChannels ][ kernelHeight ][ kernelWidth ][ inputChannels ]
class
MPSPointerConverter
<
P
:
Precision
Type
>
:
DataConverter
<
P
>
{
class
MPSPointerConverter
<
P
:
Precision
Protocol
>
:
DataConverter
<
P
>
{
/// [ outputChannels ][ inputChannels ][ kernelHeight ][ kernelWidth ] ->
/// [ outputChannels ][ inputChannels ][ kernelHeight ][ kernelWidth ] ->
/// [ outputChannels ][ kernelHeight ][ kernelWidth ][ inputChannels ]
/// [ outputChannels ][ kernelHeight ][ kernelWidth ][ inputChannels ]
...
@@ -81,7 +81,7 @@ class MPSPointerConverter<P: PrecisionType>: DataConverter<P>{
...
@@ -81,7 +81,7 @@ class MPSPointerConverter<P: PrecisionType>: DataConverter<P>{
}
}
}
}
class
Tensor
<
P
:
Precision
Type
>
:
Tensorial
{
class
Tensor
<
P
:
Precision
Protocol
>
:
Tensorial
{
var
data
:
Data
var
data
:
Data
var
dim
:
Dim
var
dim
:
Dim
...
@@ -169,14 +169,15 @@ class Tensor<P: PrecisionType>: Tensorial {
...
@@ -169,14 +169,15 @@ class Tensor<P: PrecisionType>: Tensorial {
layout
=
to
layout
=
to
}
}
func
initBuffer
(
device
:
MTLDevice
,
precision
computePrecision
:
Precision
=
.
Float16
,
padWhenOneC
:
Bool
=
false
,
convertToNHWC
:
Bool
=
true
,
withTranspose
:
Bool
=
false
)
{
func
initBuffer
(
device
:
MTLDevice
,
precision
:
ComputePrecision
=
.
Float16
,
padWhenOneC
:
Bool
=
false
,
convertToNHWC
:
Bool
=
true
,
withTranspose
:
Bool
=
false
)
{
if
convertToNHWC
{
if
convertToNHWC
{
// print(layout)
convert
(
to
:
DataLayout
.
NHWC
())
convert
(
to
:
DataLayout
.
NHWC
())
}
}
if
P
.
precisionType
==
.
Float16
&&
computePrecision
==
.
Float32
{
fatalError
(
" 不支持: 16位模型不能按照 32 位进行运算"
)
}
if
withTranspose
{
if
withTranspose
{
let
transposePointer
=
UnsafeMutablePointer
<
P
>.
allocate
(
capacity
:
numel
())
let
transposePointer
=
UnsafeMutablePointer
<
P
>.
allocate
(
capacity
:
numel
())
let
n
=
dim
[
0
]
let
n
=
dim
[
0
]
...
@@ -193,12 +194,8 @@ class Tensor<P: PrecisionType>: Tensorial {
...
@@ -193,12 +194,8 @@ class Tensor<P: PrecisionType>: Tensorial {
data
=
Data
.
init
(
inCount
:
data
.
count
,
inPointer
:
transposePointer
)
data
=
Data
.
init
(
inCount
:
data
.
count
,
inPointer
:
transposePointer
)
}
}
guard
let
floatPointer
=
data
.
pointer
as?
UnsafeMutablePointer
<
Float32
>
else
{
fatalError
(
" not support yet "
)
}
let
precisionSize
:
Int
let
precisionSize
:
Int
switch
p
recision
{
switch
computeP
recision
{
case
.
Float32
:
case
.
Float32
:
precisionSize
=
4
precisionSize
=
4
case
.
Float16
:
case
.
Float16
:
...
@@ -213,44 +210,58 @@ class Tensor<P: PrecisionType>: Tensorial {
...
@@ -213,44 +210,58 @@ class Tensor<P: PrecisionType>: Tensorial {
let
count
=
paddedC
*
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
let
count
=
paddedC
*
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
if
C
==
paddedC
{
if
C
==
paddedC
{
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
switch
precision
{
switch
P
.
precisionType
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
case
.
Float16
:
float32ToFloat16
(
input
:
floatPointer
,
output
:
buffer
.
contents
(),
count
:
count
)
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float32
:
switch
computePrecision
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
float32ToFloat16
(
input
:
data
.
pointer
as!
UnsafeMutablePointer
<
Float32
>
,
output
:
buffer
.
contents
(),
count
:
count
)
}
}
}
}
else
if
C
==
1
&&
!
padWhenOneC
{
}
else
if
C
==
1
&&
!
padWhenOneC
{
buffer
=
device
.
makeBuffer
(
length
:
numel
()
*
precisionSize
)
buffer
=
device
.
makeBuffer
(
length
:
numel
()
*
precisionSize
)
switch
precision
{
switch
P
.
precisionType
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
numel
()
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
case
.
Float16
:
float32ToFloat16
(
input
:
floatPointer
,
output
:
buffer
.
contents
(),
count
:
numel
())
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
numel
()
*
MemoryLayout
<
P
>.
stride
)
case
.
Float32
:
switch
computePrecision
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
numel
()
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
float32ToFloat16
(
input
:
data
.
pointer
as!
UnsafeMutablePointer
<
Float32
>
,
output
:
buffer
.
contents
(),
count
:
numel
())
}
}
}
}
else
{
}
else
{
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
let
convertedPointer
=
UnsafeMutablePointer
<
Float32
>.
allocate
(
capacity
:
count
)
let
convertedPointer
=
UnsafeMutablePointer
<
P
>.
allocate
(
capacity
:
count
)
var
tmpPointer
=
floatP
ointer
var
tmpPointer
=
data
.
p
ointer
var
dstPtr
=
convertedPointer
var
dstPtr
=
convertedPointer
for
_
in
0
..<
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
{
for
_
in
0
..<
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
{
for
j
in
0
..<
paddedC
{
for
j
in
0
..<
paddedC
{
if
j
<
C
{
if
j
<
C
{
dstPtr
[
j
]
=
tmpPointer
[
j
]
dstPtr
[
j
]
=
tmpPointer
[
j
]
}
else
{
}
else
{
dstPtr
[
j
]
=
0
dstPtr
[
j
]
=
P
.
initializeValue
()
}
}
}
}
tmpPointer
+=
C
tmpPointer
+=
C
dstPtr
+=
paddedC
dstPtr
+=
paddedC
}
}
switch
precision
{
switch
P
.
precisionType
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
convertedPointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
case
.
Float16
:
float32ToFloat16
(
input
:
convertedPointer
,
output
:
buffer
.
contents
(),
count
:
count
)
buffer
?
.
contents
()
.
copyMemory
(
from
:
convertedPointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float32
:
switch
computePrecision
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
convertedPointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
float32ToFloat16
(
input
:
convertedPointer
as!
UnsafeMutablePointer
<
Float32
>
,
output
:
buffer
.
contents
(),
count
:
count
)
}
}
}
convertedPointer
.
deinitialize
(
count
:
count
)
convertedPointer
.
deinitialize
(
count
:
count
)
convertedPointer
.
deallocate
()
convertedPointer
.
deallocate
()
}
}
...
@@ -261,36 +272,46 @@ class Tensor<P: PrecisionType>: Tensorial {
...
@@ -261,36 +272,46 @@ class Tensor<P: PrecisionType>: Tensorial {
let
count
=
paddedC
*
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
let
count
=
paddedC
*
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
if
C
==
paddedC
{
if
C
==
paddedC
{
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
switch
precision
{
switch
P
.
precisionType
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
case
.
Float16
:
float32ToFloat16
(
input
:
floatPointer
,
output
:
buffer
.
contents
(),
count
:
count
)
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float32
:
switch
computePrecision
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
float32ToFloat16
(
input
:
data
.
pointer
as!
UnsafeMutablePointer
<
Float32
>
,
output
:
buffer
.
contents
(),
count
:
count
)
}
}
}
}
else
if
C
==
1
{
}
else
if
C
==
1
{
fatalError
(
" not support "
)
fatalError
(
" not support "
)
}
else
{
}
else
{
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
buffer
=
device
.
makeBuffer
(
length
:
count
*
precisionSize
)
let
convertedPointer
=
UnsafeMutablePointer
<
Float32
>.
allocate
(
capacity
:
count
)
let
convertedPointer
=
UnsafeMutablePointer
<
P
>.
allocate
(
capacity
:
count
)
var
tmpPointer
=
floatP
ointer
var
tmpPointer
=
data
.
p
ointer
var
dstPtr
=
convertedPointer
var
dstPtr
=
convertedPointer
for
_
in
0
..<
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
{
for
_
in
0
..<
dim
[
0
]
*
dim
[
1
]
*
dim
[
2
]
{
for
j
in
0
..<
paddedC
{
for
j
in
0
..<
paddedC
{
if
j
<
C
{
if
j
<
C
{
dstPtr
[
j
]
=
tmpPointer
[
j
]
dstPtr
[
j
]
=
tmpPointer
[
j
]
}
else
{
}
else
{
dstPtr
[
j
]
=
0
dstPtr
[
j
]
=
P
.
initializeValue
()
}
}
}
}
tmpPointer
+=
C
tmpPointer
+=
C
dstPtr
+=
paddedC
dstPtr
+=
paddedC
}
}
switch
precision
{
switch
P
.
precisionType
{
case
.
Float
32
:
case
.
Float
16
:
// 模型精度为 32 位
buffer
?
.
contents
()
.
copyMemory
(
from
:
convertedPointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
buffer
?
.
contents
()
.
copyMemory
(
from
:
convertedPointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
case
.
Float32
:
// 模型精度为 16 位
float32ToFloat16
(
input
:
convertedPointer
,
output
:
buffer
.
contents
(),
count
:
count
)
switch
computePrecision
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
convertedPointer
,
byteCount
:
count
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
float32ToFloat16
(
input
:
convertedPointer
as!
UnsafeMutablePointer
<
Float32
>
,
output
:
buffer
.
contents
(),
count
:
count
)
}
}
}
convertedPointer
.
deinitialize
(
count
:
count
)
convertedPointer
.
deinitialize
(
count
:
count
)
convertedPointer
.
deallocate
()
convertedPointer
.
deallocate
()
...
@@ -299,11 +320,17 @@ class Tensor<P: PrecisionType>: Tensorial {
...
@@ -299,11 +320,17 @@ class Tensor<P: PrecisionType>: Tensorial {
}
else
if
dim
.
cout
()
==
1
{
}
else
if
dim
.
cout
()
==
1
{
let
num
=
((
numel
()
+
3
)
/
4
)
*
4
let
num
=
((
numel
()
+
3
)
/
4
)
*
4
buffer
=
device
.
makeBuffer
(
length
:
num
*
precisionSize
)
buffer
=
device
.
makeBuffer
(
length
:
num
*
precisionSize
)
switch
precision
{
case
.
Float32
:
switch
P
.
precisionType
{
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
num
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
case
.
Float16
:
float32ToFloat16
(
input
:
floatPointer
,
output
:
buffer
.
contents
(),
count
:
num
)
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
num
*
MemoryLayout
<
P
>.
stride
)
case
.
Float32
:
switch
computePrecision
{
case
.
Float32
:
buffer
?
.
contents
()
.
copyMemory
(
from
:
data
.
pointer
,
byteCount
:
num
*
MemoryLayout
<
P
>.
stride
)
case
.
Float16
:
float32ToFloat16
(
input
:
data
.
pointer
as!
UnsafeMutablePointer
<
Float32
>
,
output
:
buffer
.
contents
(),
count
:
num
)
}
}
}
}
else
{
}
else
{
fatalError
(
" not support !"
)
fatalError
(
" not support !"
)
...
@@ -404,7 +431,7 @@ extension Tensor {
...
@@ -404,7 +431,7 @@ extension Tensor {
var
debugDescription
:
String
{
var
debugDescription
:
String
{
var
str
=
"dim:
\(
dim
)
\n
"
var
str
=
"dim:
\(
dim
)
\n
"
str
+=
"MTLBuffer:
\(
self
.
buffer
)
\n
"
str
+=
"MTLBuffer:
\(
self
.
buffer
.
description
)
\n
"
for
i
in
0
..<
buffer
.
length
/
MemoryLayout
<
P
>.
size
{
for
i
in
0
..<
buffer
.
length
/
MemoryLayout
<
P
>.
size
{
str
+=
"
\(
buffer
.
contents
()
.
assumingMemoryBound
(
to
:
P
.
self
)[
i
]
)
"
str
+=
"
\(
buffer
.
contents
()
.
assumingMemoryBound
(
to
:
P
.
self
)[
i
]
)
"
}
}
...
...
metal/paddle-mobile/paddle-mobile/Src/Framework/Texture.swift
浏览文件 @
e2e2614d
...
@@ -96,7 +96,7 @@ public class Texture: Tensorial {
...
@@ -96,7 +96,7 @@ public class Texture: Tensorial {
return
metalTexture
.
realNHWC
(
dim
:
(
n
:
padToFourDim
[
0
],
h
:
padToFourDim
[
1
],
w
:
padToFourDim
[
2
],
c
:
padToFourDim
[
3
]))
return
metalTexture
.
realNHWC
(
dim
:
(
n
:
padToFourDim
[
0
],
h
:
padToFourDim
[
1
],
w
:
padToFourDim
[
2
],
c
:
padToFourDim
[
3
]))
}
}
public
func
initTexture
(
device
:
MTLDevice
,
inTranspose
:
[
Int
]
=
[
0
,
1
,
2
,
3
],
computePrecision
:
Compute
Precision
=
.
Float16
)
{
public
func
initTexture
(
device
:
MTLDevice
,
inTranspose
:
[
Int
]
=
[
0
,
1
,
2
,
3
],
computePrecision
:
Precision
=
.
Float16
)
{
transpose
=
inTranspose
transpose
=
inTranspose
for
i
in
0
..<
(
4
-
tensorDim
.
cout
())
{
for
i
in
0
..<
(
4
-
tensorDim
.
cout
())
{
if
i
!=
inTranspose
[
i
]
{
if
i
!=
inTranspose
[
i
]
{
...
@@ -196,7 +196,7 @@ extension Texture {
...
@@ -196,7 +196,7 @@ extension Texture {
public
var
debugDescription
:
String
{
public
var
debugDescription
:
String
{
var
str
=
""
var
str
=
""
str
+=
"Dim:
\(
dim
)
\n
value:[ "
str
+=
"Dim:
\(
dim
)
\n
value:[ "
str
+=
"
\(
metalTexture
)
"
str
+=
"
\(
metalTexture
.
description
)
"
str
+=
" ]"
str
+=
" ]"
return
str
return
str
}
}
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Base/OpCreator.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
fileprivate
var
singletons
:
[
String
:
Any
]
=
[:]
fileprivate
var
singletons
:
[
String
:
Any
]
=
[:]
class
OpCreator
<
P
:
Precision
Type
>
{
class
OpCreator
<
P
:
Precision
Protocol
>
{
static
var
shared
:
OpCreator
<
P
>
{
static
var
shared
:
OpCreator
<
P
>
{
let
key
=
String
(
describing
:
P
.
self
)
let
key
=
String
(
describing
:
P
.
self
)
if
let
singleton
=
singletons
[
key
]
{
if
let
singleton
=
singletons
[
key
]
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Base/OpParam.swift
浏览文件 @
e2e2614d
...
@@ -26,7 +26,7 @@ protocol OpParam {
...
@@ -26,7 +26,7 @@ protocol OpParam {
var
output
:
OutputType
{
get
set
}
var
output
:
OutputType
{
get
set
}
func
outputDesc
()
->
String
func
outputDesc
()
->
String
//associatedtype ParamPrecisionType: Precision
Type
//associatedtype ParamPrecisionType: Precision
Protocol
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
static
func
getFirstTensor
<
VarType
:
Variant
>
(
key
:
String
,
map
:
[
String
:
[
String
]],
from
:
Scope
)
throws
->
VarType
static
func
getFirstTensor
<
VarType
:
Variant
>
(
key
:
String
,
map
:
[
String
:
[
String
]],
from
:
Scope
)
throws
->
VarType
static
func
inputX
<
VarType
:
Variant
>
(
inputs
:
[
String
:
[
String
]],
from
:
Scope
)
throws
->
VarType
static
func
inputX
<
VarType
:
Variant
>
(
inputs
:
[
String
:
[
String
]],
from
:
Scope
)
throws
->
VarType
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/BatchNormOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
BatchNormParam
<
P
:
Precision
Type
>
:
OpParam
{
class
BatchNormParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -44,7 +44,7 @@ class BatchNormParam<P: PrecisionType>: OpParam {
...
@@ -44,7 +44,7 @@ class BatchNormParam<P: PrecisionType>: OpParam {
let
momentum
:
Float
let
momentum
:
Float
}
}
class
BatchNormOp
<
P
:
Precision
Type
>
:
Operator
<
BatchNormKernel
<
P
>
,
BatchNormParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
BatchNormOp
<
P
:
Precision
Protocol
>
:
Operator
<
BatchNormKernel
<
P
>
,
BatchNormParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
BatchNormOp
<
P
>
typealias
OpType
=
BatchNormOp
<
P
>
func
inferShape
()
{
func
inferShape
()
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/BilinearInterpOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
BilinearInterpParam
<
P
:
Precision
Type
>
:
OpParam
{
class
BilinearInterpParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -36,7 +36,7 @@ class BilinearInterpParam<P: PrecisionType>: OpParam {
...
@@ -36,7 +36,7 @@ class BilinearInterpParam<P: PrecisionType>: OpParam {
let
out_w
:
Int
let
out_w
:
Int
}
}
class
BilinearInterpOp
<
P
:
Precision
Type
>
:
Operator
<
BilinearInterpKernel
<
P
>
,
BilinearInterpParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
BilinearInterpOp
<
P
:
Precision
Protocol
>
:
Operator
<
BilinearInterpKernel
<
P
>
,
BilinearInterpParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
BilinearInterpOp
<
P
>
typealias
OpType
=
BilinearInterpOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/BoxcoderOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
BoxcoderParam
<
P
:
Precision
Type
>
:
OpParam
{
class
BoxcoderParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -45,7 +45,7 @@ class BoxcoderParam<P: PrecisionType>: OpParam {
...
@@ -45,7 +45,7 @@ class BoxcoderParam<P: PrecisionType>: OpParam {
let
boxNormalized
:
Bool
let
boxNormalized
:
Bool
}
}
class
BoxcoderOp
<
P
:
Precision
Type
>
:
Operator
<
BoxcoderKernel
<
P
>
,
BoxcoderParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
BoxcoderOp
<
P
:
Precision
Protocol
>
:
Operator
<
BoxcoderKernel
<
P
>
,
BoxcoderParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
BoxcoderOp
<
P
>
typealias
OpType
=
BoxcoderOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConcatOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConcatParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ConcatParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -46,7 +46,7 @@ class ConcatParam<P: PrecisionType>: OpParam {
...
@@ -46,7 +46,7 @@ class ConcatParam<P: PrecisionType>: OpParam {
let
axis
:
Int
let
axis
:
Int
}
}
class
ConcatOp
<
P
:
Precision
Type
>
:
Operator
<
ConcatKernel
<
P
>
,
ConcatParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ConcatOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConcatKernel
<
P
>
,
ConcatParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ConcatOp
<
P
>
typealias
OpType
=
ConcatOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddAddPreluOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
ConvAddAddPreluParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ConvAddAddPreluParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -46,7 +46,7 @@ class ConvAddAddPreluParam<P: PrecisionType>: OpParam {
...
@@ -46,7 +46,7 @@ class ConvAddAddPreluParam<P: PrecisionType>: OpParam {
let
groups
:
Int
let
groups
:
Int
}
}
class
ConvAddAddPreluOp
<
P
:
Precision
Type
>
:
Operator
<
ConvAddAddPreluKernel
<
P
>
,
ConvAddAddPreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
class
ConvAddAddPreluOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvAddAddPreluKernel
<
P
>
,
ConvAddAddPreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
typealias
OpType
=
ConvAddAddPreluOp
<
P
>
typealias
OpType
=
ConvAddAddPreluOp
<
P
>
static
func
fusionNode
()
->
Node
{
static
func
fusionNode
()
->
Node
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddBatchNormReluOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
class
ConvAddBatchNormReluParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ConvAddBatchNormReluParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -59,7 +59,7 @@ class ConvAddBatchNormReluParam<P: PrecisionType>: OpParam {
...
@@ -59,7 +59,7 @@ class ConvAddBatchNormReluParam<P: PrecisionType>: OpParam {
let
groups
:
Int
let
groups
:
Int
}
}
class
ConvAddBatchNormReluOp
<
P
:
Precision
Type
>
:
Operator
<
ConvAddBatchNormReluKernel
<
P
>
,
ConvAddBatchNormReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
class
ConvAddBatchNormReluOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvAddBatchNormReluKernel
<
P
>
,
ConvAddBatchNormReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
typealias
OpType
=
ConvAddBatchNormReluOp
<
P
>
typealias
OpType
=
ConvAddBatchNormReluOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConvAddParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ConvAddParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -43,7 +43,7 @@ class ConvAddParam<P: PrecisionType>: OpParam {
...
@@ -43,7 +43,7 @@ class ConvAddParam<P: PrecisionType>: OpParam {
let
groups
:
Int
let
groups
:
Int
}
}
class
ConvAddOp
<
P
:
Precision
Type
>
:
Operator
<
ConvAddKernel
<
P
>
,
ConvAddParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
class
ConvAddOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvAddKernel
<
P
>
,
ConvAddParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
typealias
OpType
=
ConvAddOp
<
P
>
typealias
OpType
=
ConvAddOp
<
P
>
static
func
fusionNode
()
->
Node
{
static
func
fusionNode
()
->
Node
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvAddPreluOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConvAddPreluParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ConvAddPreluParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -45,7 +45,7 @@ class ConvAddPreluParam<P: PrecisionType>: OpParam {
...
@@ -45,7 +45,7 @@ class ConvAddPreluParam<P: PrecisionType>: OpParam {
let
groups
:
Int
let
groups
:
Int
}
}
class
ConvAddPreluOp
<
P
:
Precision
Type
>
:
Operator
<
ConvAddPreluKernel
<
P
>
,
ConvAddPreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
class
ConvAddPreluOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvAddPreluKernel
<
P
>
,
ConvAddPreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
typealias
OpType
=
ConvAddPreluOp
<
P
>
typealias
OpType
=
ConvAddPreluOp
<
P
>
static
func
fusionNode
()
->
Node
{
static
func
fusionNode
()
->
Node
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvBNReluOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConvBNReluParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ConvBNReluParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -53,7 +53,7 @@ class ConvBNReluParam<P: PrecisionType>: OpParam {
...
@@ -53,7 +53,7 @@ class ConvBNReluParam<P: PrecisionType>: OpParam {
let
groups
:
Int
let
groups
:
Int
}
}
class
ConvBNReluOp
<
P
:
Precision
Type
>
:
Operator
<
ConvBNReluKernel
<
P
>
,
ConvBNReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
class
ConvBNReluOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvBNReluKernel
<
P
>
,
ConvBNReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
typealias
OpType
=
ConvBNReluOp
<
P
>
typealias
OpType
=
ConvBNReluOp
<
P
>
func
inputs
()
->
[
Variant
]
{
func
inputs
()
->
[
Variant
]
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConvParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ConvParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -40,7 +40,7 @@ class ConvParam<P: PrecisionType>: OpParam {
...
@@ -40,7 +40,7 @@ class ConvParam<P: PrecisionType>: OpParam {
let
groups
:
Int
let
groups
:
Int
}
}
class
ConvOp
<
P
:
Precision
Type
>
:
Operator
<
ConvKernel
<
P
>
,
ConvParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ConvOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvKernel
<
P
>
,
ConvParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ConvOp
<
P
>
typealias
OpType
=
ConvOp
<
P
>
func
inferShape
()
{
func
inferShape
()
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ConvTransposeOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConvTransposeParam
<
P
:
Precision
Type
>
:
ConvParam
<
P
>
{
class
ConvTransposeParam
<
P
:
Precision
Protocol
>
:
ConvParam
<
P
>
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -25,7 +25,7 @@ class ConvTransposeParam<P: PrecisionType>: ConvParam<P> {
...
@@ -25,7 +25,7 @@ class ConvTransposeParam<P: PrecisionType>: ConvParam<P> {
}
}
}
}
class
ConvTransposeOp
<
P
:
Precision
Type
>
:
Operator
<
ConvTransposeKernel
<
P
>
,
ConvTransposeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ConvTransposeOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvTransposeKernel
<
P
>
,
ConvTransposeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ConvTransposeOp
<
P
>
typealias
OpType
=
ConvTransposeOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/DepthwiseConvOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
DepthConvOp
<
P
:
Precision
Type
>
:
Operator
<
ConvKernel
<
P
>
,
ConvParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
DepthConvOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvKernel
<
P
>
,
ConvParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
DepthConvOp
<
P
>
typealias
OpType
=
DepthConvOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/DwConvBNReluOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
DwConvBNReluOp
<
P
:
Precision
Type
>
:
Operator
<
ConvBNReluKernel
<
P
>
,
ConvBNReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
class
DwConvBNReluOp
<
P
:
Precision
Protocol
>
:
Operator
<
ConvBNReluKernel
<
P
>
,
ConvBNReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
typealias
OpType
=
ConvBNReluOp
<
P
>
typealias
OpType
=
ConvBNReluOp
<
P
>
func
inferShape
()
{
func
inferShape
()
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ElementwiseAddOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
ElementwiseAddParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ElementwiseAddParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -61,7 +61,7 @@ class ElementwiseAddParam<P: PrecisionType>: OpParam {
...
@@ -61,7 +61,7 @@ class ElementwiseAddParam<P: PrecisionType>: OpParam {
var
axis
:
Int
var
axis
:
Int
}
}
class
ElementwiseAddOp
<
P
:
Precision
Type
>
:
Operator
<
ElementwiseAddKernel
<
P
>
,
ElementwiseAddParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ElementwiseAddOp
<
P
:
Precision
Protocol
>
:
Operator
<
ElementwiseAddKernel
<
P
>
,
ElementwiseAddParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ElementwiseAddOp
<
P
>
typealias
OpType
=
ElementwiseAddOp
<
P
>
func
inferShape
()
{
func
inferShape
()
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ElementwiseAddPreluOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
ElementwiseAddPreluParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ElementwiseAddPreluParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -65,7 +65,7 @@ class ElementwiseAddPreluParam<P: PrecisionType>: OpParam {
...
@@ -65,7 +65,7 @@ class ElementwiseAddPreluParam<P: PrecisionType>: OpParam {
var
axis
:
Int
var
axis
:
Int
}
}
class
ElementwiseAddPreluOp
<
P
:
Precision
Type
>
:
Operator
<
ElementwiseAddPreluKernel
<
P
>
,
ElementwiseAddPreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
class
ElementwiseAddPreluOp
<
P
:
Precision
Protocol
>
:
Operator
<
ElementwiseAddPreluKernel
<
P
>
,
ElementwiseAddPreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
static
func
fusionNode
()
->
Node
{
static
func
fusionNode
()
->
Node
{
let
beginNode
=
Node
.
init
(
inType
:
gElementwiseAddType
)
let
beginNode
=
Node
.
init
(
inType
:
gElementwiseAddType
)
_
=
beginNode
_
=
beginNode
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/FeedOp.swift
浏览文件 @
e2e2614d
...
@@ -16,7 +16,7 @@ import Foundation
...
@@ -16,7 +16,7 @@ import Foundation
import
MetalKit
import
MetalKit
import
CoreMedia
import
CoreMedia
class
FeedParam
<
P
:
Precision
Type
>
:
OpParam
{
class
FeedParam
<
P
:
Precision
Protocol
>
:
OpParam
{
var
output
:
Texture
var
output
:
Texture
var
input
:
InputTexture
{
var
input
:
InputTexture
{
return
scope
.
input
()
as!
InputTexture
return
scope
.
input
()
as!
InputTexture
...
@@ -35,7 +35,7 @@ class FeedParam<P: PrecisionType>: OpParam{
...
@@ -35,7 +35,7 @@ class FeedParam<P: PrecisionType>: OpParam{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
}
}
class
FeedOp
<
P
:
Precision
Type
>
:
Operator
<
Texture2DTo2DArrayKernel
<
P
>
,
FeedParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
FeedOp
<
P
:
Precision
Protocol
>
:
Operator
<
Texture2DTo2DArrayKernel
<
P
>
,
FeedParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
FeedOp
<
P
>
typealias
OpType
=
FeedOp
<
P
>
func
inferShape
()
{
func
inferShape
()
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/FetchOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
FetchParam
<
P
:
Precision
Type
>
:
OpParam
{
class
FetchParam
<
P
:
Precision
Protocol
>
:
OpParam
{
var
output
:
FetchHolder
var
output
:
FetchHolder
let
input
:
Texture
let
input
:
Texture
let
scope
:
Scope
let
scope
:
Scope
...
@@ -33,7 +33,7 @@ class FetchParam<P: PrecisionType>: OpParam{
...
@@ -33,7 +33,7 @@ class FetchParam<P: PrecisionType>: OpParam{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
}
}
class
FetchOp
<
P
:
Precision
Type
>
:
Operator
<
FetchKernel
<
P
>
,
FetchParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
FetchOp
<
P
:
Precision
Protocol
>
:
Operator
<
FetchKernel
<
P
>
,
FetchParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
FetchOp
<
P
>
typealias
OpType
=
FetchOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/FlattenOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
FlattenParam
<
P
:
Precision
Type
>
:
OpParam
{
class
FlattenParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -31,7 +31,7 @@ class FlattenParam<P: PrecisionType>: OpParam {
...
@@ -31,7 +31,7 @@ class FlattenParam<P: PrecisionType>: OpParam {
}
}
class
FlattenOp
<
P
:
Precision
Type
>
:
Operator
<
FlattenKernel
<
P
>
,
FlattenParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
FlattenOp
<
P
:
Precision
Protocol
>
:
Operator
<
FlattenKernel
<
P
>
,
FlattenParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
FlattenOp
<
P
>
typealias
OpType
=
FlattenOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/BatchNormKernel.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
BatchNormKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
BatchNormKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
required
init
(
device
:
MTLDevice
,
param
:
BatchNormParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
BatchNormParam
<
P
>
,
initContext
:
InitContext
)
{
let
count
=
param
.
variance
.
dim
.
numel
()
let
count
=
param
.
variance
.
dim
.
numel
()
let
varianceP
=
param
.
variance
.
data
.
pointer
let
varianceP
=
param
.
variance
.
data
.
pointer
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/BilinearInterpKernel.swift
浏览文件 @
e2e2614d
...
@@ -19,7 +19,7 @@ struct BilinearInterpMetalParam {
...
@@ -19,7 +19,7 @@ struct BilinearInterpMetalParam {
var
ratio_w
:
Float32
var
ratio_w
:
Float32
}
}
class
BilinearInterpKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
BilinearInterpKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
BilinearInterpParam
<
P
>
)
throws
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
BilinearInterpParam
<
P
>
)
throws
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/BoxcoderKernel.swift
浏览文件 @
e2e2614d
...
@@ -17,7 +17,7 @@ import Foundation
...
@@ -17,7 +17,7 @@ import Foundation
struct
BoxcoderMetalParam
{
struct
BoxcoderMetalParam
{
}
}
class
BoxcoderKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
BoxcoderKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
BoxcoderParam
<
P
>
)
throws
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
BoxcoderParam
<
P
>
)
throws
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConcatKernel.swift
浏览文件 @
e2e2614d
...
@@ -31,7 +31,7 @@ struct ConcatMetalParam {
...
@@ -31,7 +31,7 @@ struct ConcatMetalParam {
var
vdim
:
(
Int32
,
Int32
,
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
0
,
0
,
0
,
0
,
0
)
var
vdim
:
(
Int32
,
Int32
,
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
0
,
0
,
0
,
0
,
0
)
}
}
class
ConcatKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ConcatKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
v
=
"normal"
var
v
=
"normal"
var
pm
=
ConcatMetalParam
.
init
()
var
pm
=
ConcatMetalParam
.
init
()
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ConcatParam
<
P
>
)
throws
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ConcatParam
<
P
>
)
throws
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddAddPreluKernel.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConvAddAddPreluKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ConvAddAddPreluKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
MetalConvParam
!
var
metalParam
:
MetalConvParam
!
required
init
(
device
:
MTLDevice
,
param
:
ConvAddAddPreluParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
ConvAddAddPreluParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
],
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
],
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddBatchNormReluKernel.swift
浏览文件 @
e2e2614d
...
@@ -36,7 +36,7 @@ struct ConvAddBatchNormReluTestParam: TestParam {
...
@@ -36,7 +36,7 @@ struct ConvAddBatchNormReluTestParam: TestParam {
}
}
}
}
class
ConvAddBatchNormReluKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
,
Testable
{
class
ConvAddBatchNormReluKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
,
Testable
{
required
init
(
device
:
MTLDevice
,
testParam
:
ConvAddBatchNormReluTestParam
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
testParam
:
ConvAddBatchNormReluTestParam
,
initContext
:
InitContext
)
{
if
testParam
.
filterSize
.
width
==
1
&&
testParam
.
filterSize
.
height
==
1
{
if
testParam
.
filterSize
.
width
==
1
&&
testParam
.
filterSize
.
height
==
1
{
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_batch_norm_relu_1x1"
,
initContext
:
initContext
)
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_batch_norm_relu_1x1"
,
initContext
:
initContext
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddKernel.swift
浏览文件 @
e2e2614d
...
@@ -27,7 +27,7 @@ func getUniqueKey() -> String {
...
@@ -27,7 +27,7 @@ func getUniqueKey() -> String {
return
UUID
.
init
()
.
uuidString
return
UUID
.
init
()
.
uuidString
}
}
class
ConvAddKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ConvAddKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
MetalConvParam
!
var
metalParam
:
MetalConvParam
!
let
identifyingKey
:
String
=
getUniqueKey
()
let
identifyingKey
:
String
=
getUniqueKey
()
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddPreluKernel.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ConvAddPreluKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ConvAddPreluKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
MetalConvParam
!
var
metalParam
:
MetalConvParam
!
required
init
(
device
:
MTLDevice
,
param
:
ConvAddPreluParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
ConvAddPreluParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
],
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
],
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvBNReluKernel.swift
浏览文件 @
e2e2614d
...
@@ -37,7 +37,7 @@ struct ConvBNReluTestParam: TestParam {
...
@@ -37,7 +37,7 @@ struct ConvBNReluTestParam: TestParam {
}
}
}
}
class
ConvBNReluKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
,
Testable
{
class
ConvBNReluKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
,
Testable
{
required
init
(
device
:
MTLDevice
,
testParam
:
ConvBNReluTestParam
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
testParam
:
ConvBNReluTestParam
,
initContext
:
InitContext
)
{
if
testParam
.
filterSize
.
width
==
1
&&
testParam
.
filterSize
.
height
==
1
{
if
testParam
.
filterSize
.
width
==
1
&&
testParam
.
filterSize
.
height
==
1
{
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_batch_norm_relu_1x1"
,
initContext
:
initContext
)
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_batch_norm_relu_1x1"
,
initContext
:
initContext
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvKernel.swift
浏览文件 @
e2e2614d
...
@@ -24,10 +24,10 @@ public struct MetalConvParam {
...
@@ -24,10 +24,10 @@ public struct MetalConvParam {
let
dilationY
:
UInt16
let
dilationY
:
UInt16
}
}
class
ConvKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ConvKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
MetalConvParam
!
var
metalParam
:
MetalConvParam
!
required
init
(
device
:
MTLDevice
,
param
:
ConvParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
ConvParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
filter
.
initBuffer
(
device
:
device
,
precision
:
Compute
Precision
.
Float32
)
param
.
filter
.
initBuffer
(
device
:
device
,
precision
:
Precision
.
Float32
)
if
param
.
filter
.
width
==
1
&&
param
.
filter
.
height
==
1
{
if
param
.
filter
.
width
==
1
&&
param
.
filter
.
height
==
1
{
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_1x1"
,
initContext
:
initContext
)
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_1x1"
,
initContext
:
initContext
)
}
else
if
param
.
filter
.
channel
==
1
{
}
else
if
param
.
filter
.
channel
==
1
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvTransposeKernel.swift
浏览文件 @
e2e2614d
...
@@ -28,7 +28,7 @@ struct MetalConvTransposeParam {
...
@@ -28,7 +28,7 @@ struct MetalConvTransposeParam {
let
dilationY
:
UInt16
;
let
dilationY
:
UInt16
;
}
}
class
ConvTransposeKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ConvTransposeKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
MetalConvTransposeParam
!
var
metalParam
:
MetalConvTransposeParam
!
required
init
(
device
:
MTLDevice
,
param
:
ConvTransposeParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
ConvTransposeParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ElementwiseAddKernel.swift
浏览文件 @
e2e2614d
...
@@ -24,7 +24,7 @@ struct ElementwiseAddMetalParam {
...
@@ -24,7 +24,7 @@ struct ElementwiseAddMetalParam {
var
ytrans
:
(
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
1
,
2
,
3
)
var
ytrans
:
(
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
1
,
2
,
3
)
}
}
class
ElementwiseAddKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ElementwiseAddKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
ElementwiseAddMetalParam
var
metalParam
:
ElementwiseAddMetalParam
required
init
(
device
:
MTLDevice
,
param
:
ElementwiseAddParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
ElementwiseAddParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
inputX
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
inputX
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ElementwiseAddPreluKernel.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
class
ElementwiseAddPreluKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ElementwiseAddPreluKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
ElementwiseAddMetalParam
var
metalParam
:
ElementwiseAddMetalParam
required
init
(
device
:
MTLDevice
,
param
:
ElementwiseAddPreluParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
ElementwiseAddPreluParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
inputX
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
inputX
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/FetchKernel.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
FetchKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
FetchKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
required
init
(
device
:
MTLDevice
,
param
:
FetchParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
FetchParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initBuffer
(
device
:
device
)
param
.
output
.
initBuffer
(
device
:
device
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/FlattenKernel.swift
浏览文件 @
e2e2614d
...
@@ -22,7 +22,7 @@ struct FlattenMetalParam {
...
@@ -22,7 +22,7 @@ struct FlattenMetalParam {
}
}
class
FlattenKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
FlattenKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
FlattenMetalParam
var
metalParam
:
FlattenMetalParam
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/MulticlassNMSKernel.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
MulticlassNMSKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
MulticlassNMSKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
let
pipline1
:
MTLComputePipelineState
let
pipline1
:
MTLComputePipelineState
required
init
(
device
:
MTLDevice
,
param
:
MulticlassNMSParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
MulticlassNMSParam
<
P
>
,
initContext
:
InitContext
)
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/PoolKernel.swift
浏览文件 @
e2e2614d
...
@@ -24,7 +24,7 @@ struct PoolMetalParam {
...
@@ -24,7 +24,7 @@ struct PoolMetalParam {
let
poolType
:
Int32
let
poolType
:
Int32
}
}
class
PoolKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
PoolKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
PoolMetalParam
var
metalParam
:
PoolMetalParam
required
init
(
device
:
MTLDevice
,
param
:
PoolParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
PoolParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/PreluKernel.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
PreluKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
PreluKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
required
init
(
device
:
MTLDevice
,
param
:
PreluParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
PreluParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
alpha
.
initBuffer
(
device
:
device
,
precision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
alpha
.
initBuffer
(
device
:
device
,
precision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/PriorBoxKernel.swift
浏览文件 @
e2e2614d
...
@@ -29,7 +29,7 @@ struct PriorBoxMetalParam {
...
@@ -29,7 +29,7 @@ struct PriorBoxMetalParam {
let
maxSizeSize
:
uint
let
maxSizeSize
:
uint
}
}
class
PriorBoxKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
PriorBoxKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
PriorBoxMetalParam
!
var
metalParam
:
PriorBoxMetalParam
!
required
init
(
device
:
MTLDevice
,
param
:
PriorBoxParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
PriorBoxParam
<
P
>
,
initContext
:
InitContext
)
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ReluKernel.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ReluKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ReluKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ReluParam
<
P
>
)
throws
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ReluParam
<
P
>
)
throws
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ReshapeKernel.swift
浏览文件 @
e2e2614d
...
@@ -27,7 +27,7 @@ struct ReshapeTestParam: TestParam {
...
@@ -27,7 +27,7 @@ struct ReshapeTestParam: TestParam {
let
param
:
ReshapeMetalParam
let
param
:
ReshapeMetalParam
}
}
class
ReshapeKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ReshapeKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
ReshapeMetalParam
var
metalParam
:
ReshapeMetalParam
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ResizeBilinearKernel.swift
浏览文件 @
e2e2614d
...
@@ -19,7 +19,7 @@ struct ResizeBilinearMetalParam {
...
@@ -19,7 +19,7 @@ struct ResizeBilinearMetalParam {
var
ratio_w
:
Float32
var
ratio_w
:
Float32
}
}
class
ResizeBilinearKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ResizeBilinearKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
required
init
(
device
:
MTLDevice
,
param
:
ResizeBilinearParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
ResizeBilinearParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
param
.
input
.
transpose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float32
{
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float32
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ShapeKernel.swift
浏览文件 @
e2e2614d
...
@@ -18,7 +18,7 @@ import Foundation
...
@@ -18,7 +18,7 @@ import Foundation
struct
ShapeMetalParam
{
struct
ShapeMetalParam
{
}
}
class
ShapeKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
ShapeKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ShapeParam
<
P
>
)
throws
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ShapeParam
<
P
>
)
throws
{
// print("shape compute")
// print("shape compute")
// guard let encoder = commandBuffer.makeComputeCommandEncoder() else {
// guard let encoder = commandBuffer.makeComputeCommandEncoder() else {
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/SoftmaxKernel.swift
浏览文件 @
e2e2614d
...
@@ -19,7 +19,7 @@ struct SoftmaxMetalParam {
...
@@ -19,7 +19,7 @@ struct SoftmaxMetalParam {
let
K
:
Int32
let
K
:
Int32
}
}
class
SoftmaxKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
SoftmaxKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
SoftmaxMetalParam
var
metalParam
:
SoftmaxMetalParam
required
init
(
device
:
MTLDevice
,
param
:
SoftmaxParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
SoftmaxParam
<
P
>
,
initContext
:
InitContext
)
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/SplitKernel.swift
浏览文件 @
e2e2614d
...
@@ -22,7 +22,7 @@ struct SplitMetalParam {
...
@@ -22,7 +22,7 @@ struct SplitMetalParam {
var
vdim
:
(
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
0
,
0
,
0
)
var
vdim
:
(
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
0
,
0
,
0
)
}
}
class
SplitKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
SplitKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
smp
:
SplitMetalParam
var
smp
:
SplitMetalParam
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
SplitParam
<
P
>
)
throws
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
SplitParam
<
P
>
)
throws
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/Texture2DTo2DArrayKernel.swift
浏览文件 @
e2e2614d
...
@@ -22,7 +22,7 @@ struct Texture2DTo2DArrayParam {
...
@@ -22,7 +22,7 @@ struct Texture2DTo2DArrayParam {
let
expectDim
:
Dim
let
expectDim
:
Dim
}
}
class
Texture2DTo2DArrayKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
Texture2DTo2DArrayKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
FeedParam
<
P
>
)
throws
{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
FeedParam
<
P
>
)
throws
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/TransposeKernel.swift
浏览文件 @
e2e2614d
...
@@ -20,7 +20,7 @@ struct TransposeMetalParam {
...
@@ -20,7 +20,7 @@ struct TransposeMetalParam {
var
axis
:
(
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
1
,
2
,
3
)
var
axis
:
(
Int32
,
Int32
,
Int32
,
Int32
)
=
(
0
,
1
,
2
,
3
)
}
}
class
TransposeKernel
<
P
:
Precision
Type
>
:
Kernel
,
Computable
{
class
TransposeKernel
<
P
:
Precision
Protocol
>
:
Kernel
,
Computable
{
var
metalParam
:
TransposeMetalParam
=
TransposeMetalParam
.
init
()
var
metalParam
:
TransposeMetalParam
=
TransposeMetalParam
.
init
()
required
init
(
device
:
MTLDevice
,
param
:
TransposeParam
<
P
>
,
initContext
:
InitContext
)
{
required
init
(
device
:
MTLDevice
,
param
:
TransposeParam
<
P
>
,
initContext
:
InitContext
)
{
param
.
output
.
initTexture
(
device
:
device
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
param
.
output
.
initTexture
(
device
:
device
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/MulticlassNMSOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
MulticlassNMSParam
<
P
:
Precision
Type
>
:
OpParam
{
class
MulticlassNMSParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -36,7 +36,7 @@ class MulticlassNMSParam<P: PrecisionType>: OpParam {
...
@@ -36,7 +36,7 @@ class MulticlassNMSParam<P: PrecisionType>: OpParam {
var
output
:
Texture
var
output
:
Texture
}
}
class
MulticlassNMSOp
<
P
:
Precision
Type
>
:
Operator
<
MulticlassNMSKernel
<
P
>
,
MulticlassNMSParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
MulticlassNMSOp
<
P
:
Precision
Protocol
>
:
Operator
<
MulticlassNMSKernel
<
P
>
,
MulticlassNMSParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
func
inputVariant
()
->
[
String
:
[
MTLBuffer
]]
{
func
inputVariant
()
->
[
String
:
[
MTLBuffer
]]
{
guard
let
scoreBuffer
=
para
.
middleOutput
.
resultBuffer
,
let
bboxBuffer
=
para
.
middleOutput
.
resultBuffer
else
{
guard
let
scoreBuffer
=
para
.
middleOutput
.
resultBuffer
,
let
bboxBuffer
=
para
.
middleOutput
.
resultBuffer
else
{
...
@@ -48,8 +48,8 @@ class MulticlassNMSOp<P: PrecisionType>: Operator<MulticlassNMSKernel<P>, Multic
...
@@ -48,8 +48,8 @@ class MulticlassNMSOp<P: PrecisionType>: Operator<MulticlassNMSKernel<P>, Multic
func
computeMiddleResult
(
device
:
MTLDevice
,
buffer
:
MTLCommandBuffer
)
{
func
computeMiddleResult
(
device
:
MTLDevice
,
buffer
:
MTLCommandBuffer
)
{
do
{
do
{
try
kernel
.
compute
(
commandBuffer
:
buffer
,
param
:
para
)
try
kernel
.
compute
(
commandBuffer
:
buffer
,
param
:
para
)
}
catch
let
_
{
}
catch
let
error
{
fatalError
()
fatalError
(
"
\(
error
)
"
)
}
}
}
}
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/PoolOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
PoolParam
<
P
:
Precision
Type
>
:
OpParam
{
class
PoolParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -42,7 +42,7 @@ class PoolParam<P: PrecisionType>: OpParam {
...
@@ -42,7 +42,7 @@ class PoolParam<P: PrecisionType>: OpParam {
var
globalPooling
:
Bool
var
globalPooling
:
Bool
}
}
class
PoolOp
<
P
:
Precision
Type
>
:
Operator
<
PoolKernel
<
P
>
,
PoolParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
PoolOp
<
P
:
Precision
Protocol
>
:
Operator
<
PoolKernel
<
P
>
,
PoolParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
PoolOp
<
P
>
typealias
OpType
=
PoolOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/PreluOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
PreluParam
<
P
:
Precision
Type
>
:
OpParam
{
class
PreluParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -32,7 +32,7 @@ class PreluParam<P: PrecisionType>: OpParam {
...
@@ -32,7 +32,7 @@ class PreluParam<P: PrecisionType>: OpParam {
var
output
:
Texture
var
output
:
Texture
}
}
class
PreluOp
<
P
:
Precision
Type
>
:
Operator
<
PreluKernel
<
P
>
,
PreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
PreluOp
<
P
:
Precision
Protocol
>
:
Operator
<
PreluKernel
<
P
>
,
PreluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
PreluOp
<
P
>
typealias
OpType
=
PreluOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/PriorBoxOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
PriorBoxParam
<
P
:
Precision
Type
>
:
OpParam
{
class
PriorBoxParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -59,7 +59,7 @@ class PriorBoxParam<P: PrecisionType>: OpParam {
...
@@ -59,7 +59,7 @@ class PriorBoxParam<P: PrecisionType>: OpParam {
let
outputVariances
:
Texture
let
outputVariances
:
Texture
}
}
class
PriorBoxOp
<
P
:
Precision
Type
>
:
Operator
<
PriorBoxKernel
<
P
>
,
PriorBoxParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
PriorBoxOp
<
P
:
Precision
Protocol
>
:
Operator
<
PriorBoxKernel
<
P
>
,
PriorBoxParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
PriorBoxOp
<
P
>
typealias
OpType
=
PriorBoxOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ReluOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
class
ReluParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ReluParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -29,7 +29,7 @@ class ReluParam<P: PrecisionType>: OpParam {
...
@@ -29,7 +29,7 @@ class ReluParam<P: PrecisionType>: OpParam {
var
output
:
Texture
var
output
:
Texture
}
}
class
ReluOp
<
P
:
Precision
Type
>
:
Operator
<
ReluKernel
<
P
>
,
ReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ReluOp
<
P
:
Precision
Protocol
>
:
Operator
<
ReluKernel
<
P
>
,
ReluParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ReluOp
<
P
>
typealias
OpType
=
ReluOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ReshapeOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
ReshapeParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ReshapeParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -53,7 +53,7 @@ class ReshapeParam<P: PrecisionType>: OpParam {
...
@@ -53,7 +53,7 @@ class ReshapeParam<P: PrecisionType>: OpParam {
var
output
:
Texture
var
output
:
Texture
}
}
class
ReshapeOp
<
P
:
Precision
Type
>
:
Operator
<
ReshapeKernel
<
P
>
,
ReshapeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ReshapeOp
<
P
:
Precision
Protocol
>
:
Operator
<
ReshapeKernel
<
P
>
,
ReshapeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ReshapeOp
<
P
>
typealias
OpType
=
ReshapeOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ResizeBilinearOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ResizeBilinearParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ResizeBilinearParam
<
P
:
Precision
Protocol
>
:
OpParam
{
typealias
ParamPrecisionType
=
P
typealias
ParamPrecisionType
=
P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -35,7 +35,7 @@ class ResizeBilinearParam<P: PrecisionType>: OpParam {
...
@@ -35,7 +35,7 @@ class ResizeBilinearParam<P: PrecisionType>: OpParam {
let
out_w
:
Int32
let
out_w
:
Int32
}
}
class
ResizeBilinearOp
<
P
:
Precision
Type
>
:
Operator
<
ResizeBilinearKernel
<
P
>
,
ResizeBilinearParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ResizeBilinearOp
<
P
:
Precision
Protocol
>
:
Operator
<
ResizeBilinearKernel
<
P
>
,
ResizeBilinearParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ResizeBilinearOp
<
P
>
typealias
OpType
=
ResizeBilinearOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/ShapeOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
ShapeParam
<
P
:
Precision
Type
>
:
OpParam
{
class
ShapeParam
<
P
:
Precision
Protocol
>
:
OpParam
{
// typealias ParamPrecisionType = P
// typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -28,7 +28,7 @@ class ShapeParam<P: PrecisionType>: OpParam {
...
@@ -28,7 +28,7 @@ class ShapeParam<P: PrecisionType>: OpParam {
let
input
:
Texture
let
input
:
Texture
}
}
class
ShapeOp
<
P
:
Precision
Type
>
:
Operator
<
ShapeKernel
<
P
>
,
ShapeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
ShapeOp
<
P
:
Precision
Protocol
>
:
Operator
<
ShapeKernel
<
P
>
,
ShapeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
ShapeOp
<
P
>
typealias
OpType
=
ShapeOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/SoftmaxOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
SoftmaxParam
<
P
:
Precision
Type
>
:
OpParam
{
class
SoftmaxParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -36,7 +36,7 @@ class SoftmaxParam<P: PrecisionType>: OpParam {
...
@@ -36,7 +36,7 @@ class SoftmaxParam<P: PrecisionType>: OpParam {
var
output
:
Texture
var
output
:
Texture
}
}
class
SoftmaxOp
<
P
:
Precision
Type
>
:
Operator
<
SoftmaxKernel
<
P
>
,
SoftmaxParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
SoftmaxOp
<
P
:
Precision
Protocol
>
:
Operator
<
SoftmaxKernel
<
P
>
,
SoftmaxParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
SoftmaxOp
<
P
>
typealias
OpType
=
SoftmaxOp
<
P
>
func
inferShape
()
{
func
inferShape
()
{
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/SplitOp.swift
浏览文件 @
e2e2614d
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
class
SplitParam
<
P
:
Precision
Type
>
:
OpParam
{
class
SplitParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -47,7 +47,7 @@ class SplitParam<P: PrecisionType>: OpParam {
...
@@ -47,7 +47,7 @@ class SplitParam<P: PrecisionType>: OpParam {
var
sections
:
[
Int32
]
=
[]
var
sections
:
[
Int32
]
=
[]
}
}
class
SplitOp
<
P
:
Precision
Type
>
:
Operator
<
SplitKernel
<
P
>
,
SplitParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
SplitOp
<
P
:
Precision
Protocol
>
:
Operator
<
SplitKernel
<
P
>
,
SplitParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
SplitOp
<
P
>
typealias
OpType
=
SplitOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/TransposeOp.swift
浏览文件 @
e2e2614d
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
import
Foundation
import
Foundation
import
Metal
import
Metal
class
TransposeParam
<
P
:
Precision
Type
>
:
OpParam
{
class
TransposeParam
<
P
:
Precision
Protocol
>
:
OpParam
{
//typealias ParamPrecisionType = P
//typealias ParamPrecisionType = P
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
required
init
(
opDesc
:
PMOpDesc
,
inScope
:
Scope
)
throws
{
do
{
do
{
...
@@ -31,7 +31,7 @@ class TransposeParam<P: PrecisionType>: OpParam {
...
@@ -31,7 +31,7 @@ class TransposeParam<P: PrecisionType>: OpParam {
let
axis
:
[
Int32
]
let
axis
:
[
Int32
]
}
}
class
TransposeOp
<
P
:
Precision
Type
>
:
Operator
<
TransposeKernel
<
P
>
,
TransposeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
class
TransposeOp
<
P
:
Precision
Protocol
>
:
Operator
<
TransposeKernel
<
P
>
,
TransposeParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
{
typealias
OpType
=
TransposeOp
<
P
>
typealias
OpType
=
TransposeOp
<
P
>
...
...
metal/paddle-mobile/paddle-mobile/Src/Program/ProgramOptimize.swift
浏览文件 @
e2e2614d
...
@@ -181,7 +181,7 @@ extension Node: Equatable {
...
@@ -181,7 +181,7 @@ extension Node: Equatable {
}
}
class
ProgramOptimize
<
P
:
Precision
Type
>
{
class
ProgramOptimize
<
P
:
Precision
Protocol
>
{
// register fusion
// register fusion
let
fusionOps
:
[
Fusion
.
Type
]
=
[
ConvAddBatchNormReluOp
<
P
>.
self
,
let
fusionOps
:
[
Fusion
.
Type
]
=
[
ConvAddBatchNormReluOp
<
P
>.
self
,
// ConvAddAddPreluOp<P>.self,
// ConvAddAddPreluOp<P>.self,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录