Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
b4d15642
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看板
提交
b4d15642
编写于
8月 27, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update
上级
d403cf08
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
59 addition
and
27 deletion
+59
-27
metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift
...l/paddle-mobile/paddle-mobile/Common/MetalExtension.swift
+21
-0
metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift
metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift
+11
-8
metal/paddle-mobile/paddle-mobile/Operators/ConvBNReluOp.swift
.../paddle-mobile/paddle-mobile/Operators/ConvBNReluOp.swift
+12
-8
metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift
...mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift
...obile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift
...l/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift
+13
-9
未找到文件。
metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift
浏览文件 @
b4d15642
...
...
@@ -339,6 +339,27 @@ public extension MTLTexture {
return
nil
}
// n c h w - dim
func
toTensor
(
dim
:
(
n
:
Int
,
c
:
Int
,
h
:
Int
,
w
:
Int
))
->
[
Float32
]
{
let
textureArray
=
floatArray
{
(
i
:
Float32
)
->
Float32
in
return
i
}
var
output
:
[
Float32
]
=
[]
for
s
in
0
..<
arrayLength
{
for
c
in
0
..<
4
{
for
h
in
0
..<
dim
.
h
{
for
w
in
0
..<
dim
.
w
{
if
(
s
*
4
+
c
)
<
dim
.
c
{
let
textureValue
=
textureArray
[
dim
.
w
*
dim
.
h
*
4
*
s
+
h
*
dim
.
w
*
4
+
w
*
4
+
c
]
output
.
append
(
textureValue
)
}
}
}
}
}
return
output
}
}
...
...
metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift
浏览文件 @
b4d15642
...
...
@@ -45,7 +45,10 @@ class ConvAddParam<P: PrecisionType>: OpParam {
class
ConvAddOp
<
P
:
PrecisionType
>
:
Operator
<
ConvAddKernel
<
P
>
,
ConvAddParam
<
P
>>
,
Runable
,
Creator
,
InferShaperable
,
Fusion
{
func
delogOutput
()
{
print
(
" conv add: "
)
print
(
para
.
output
.
metalTexture
.
toTensor
(
dim
:
(
n
:
para
.
output
.
tensorDim
[
0
],
c
:
para
.
output
.
tensorDim
[
1
],
h
:
para
.
output
.
tensorDim
[
2
],
w
:
para
.
output
.
tensorDim
[
3
]))
.
strideArray
())
// print(" conv add: ")
// print(para.input.metalTexture)
...
...
@@ -53,16 +56,16 @@ class ConvAddOp<P: PrecisionType>: Operator<ConvAddKernel<P>, ConvAddParam<P>>,
// let filterArray: [P] = para.filter.buffer.array()
// print(filterArray)
let
input
=
para
.
input
.
metalTexture
.
floatArray
{
(
p
:
P
)
->
P
in
return
p
}
//
let input = para.input.metalTexture.floatArray { (p: P) -> P in
//
return p
//
}
// print(input)
let
output
=
para
.
output
.
metalTexture
.
floatArray
{
(
p
:
P
)
->
P
in
return
p
}
//
let output = para.output.metalTexture.floatArray { (p: P) -> P in
//
return p
//
}
// print(para.output.metalTexture)
print
(
output
)
//
print(output)
}
...
...
metal/paddle-mobile/paddle-mobile/Operators/ConvBNReluOp.swift
浏览文件 @
b4d15642
...
...
@@ -159,19 +159,23 @@ class ConvBNReluOp<P: PrecisionType>: Operator<ConvBNReluKernel<P>, ConvBNReluPa
// print("index: \(i) \(newBiase![i]) ")
// }
print
(
para
.
output
.
metalTexture
)
let
output
=
para
.
output
.
metalTexture
.
floatArray
{
(
p
:
P
)
->
P
in
return
p
}
print
(
output
)
// print(para.output.metalTexture)
//
//
//
writeToLibrary
(
fileName
:
"batch_norm_34.tmp_2"
,
array
:
output
)
print
(
" write done"
)
// let output = para.output.metalTexture.floatArray { (p: P) -> P in
// return p
// }
// print(output)
//
//
// writeToLibrary(fileName: "batch_norm_34.tmp_2", array: output)
// print(" write done")
//
print
(
para
.
output
.
metalTexture
.
toTensor
(
dim
:
(
n
:
para
.
output
.
tensorDim
[
0
],
c
:
para
.
output
.
tensorDim
[
1
],
h
:
para
.
output
.
tensorDim
[
2
],
w
:
para
.
output
.
tensorDim
[
3
]))
.
strideArray
())
// let _: P? = para.output.metalTexture.logDesc(header: "conv add batchnorm relu output: ", stridable: true)
}
...
...
metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift
浏览文件 @
b4d15642
...
...
@@ -50,7 +50,7 @@ class ConvAddBatchNormReluKernel<P: PrecisionType>: Kernel, Computable, Testable
required
init
(
device
:
MTLDevice
,
param
:
ConvAddBatchNormReluParam
<
P
>
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
])
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
3
,
1
,
2
])
if
param
.
filter
.
width
==
1
&&
param
.
filter
.
height
==
1
{
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_batch_norm_relu_1x1"
)
...
...
metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift
浏览文件 @
b4d15642
...
...
@@ -25,7 +25,7 @@ class ConvAddKernel<P: PrecisionType>: Kernel, Computable {
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_3x3"
)
}
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
])
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
3
,
1
,
2
])
let
offsetX
=
param
.
filter
.
width
/
2
-
Int
(
param
.
paddings
[
0
])
let
offsetY
=
param
.
filter
.
height
/
2
-
Int
(
param
.
paddings
[
1
])
...
...
metal/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift
浏览文件 @
b4d15642
...
...
@@ -49,17 +49,21 @@ class TransposeOp<P: PrecisionType>: Operator<TransposeKernel<P>, TransposeParam
}
}
func
delogOutput
()
{
let
inputArray
:
[
Float32
]
=
para
.
input
.
metalTexture
.
floatArray
{
(
ele
:
Float32
)
->
Float32
in
return
ele
}
print
(
inputArray
.
strideArray
())
print
(
para
.
output
.
metalTexture
.
toTensor
(
dim
:
(
n
:
1
,
c
:
21
,
h
:
19
,
w
:
19
))
.
strideArray
())
let
outputArray
:
[
Float32
]
=
para
.
output
.
metalTexture
.
floatArray
{
(
ele
:
Float32
)
->
Float32
in
return
ele
}
print
(
outputArray
.
strideArray
())
// let inputArray: [Float32] = para.input.metalTexture.floatArray { (ele: Float32) -> Float32 in
// return ele
// }
//
// print(inputArray.strideArray())
//
// let outputArray: [Float32] = para.output.metalTexture.floatArray { (ele: Float32) -> Float32 in
// return ele
// }
//
// print(outputArray.strideArray())
// writeToLibrary(fileName: "transpose_ouput", array: outputArray)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录