Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
78271926
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看板
提交
78271926
编写于
8月 27, 2018
作者:
R
Ruilong Liu
提交者:
GitHub
8月 27, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #841 from codeWorm2015/metal
update
上级
d82bd7bc
3fff4d34
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
47 addition
and
5 deletion
+47
-5
metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift
...l/paddle-mobile/paddle-mobile/Common/MetalExtension.swift
+38
-0
metal/paddle-mobile/paddle-mobile/Executor.swift
metal/paddle-mobile/paddle-mobile/Executor.swift
+1
-1
metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift
metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift
+1
-1
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
+5
-1
未找到文件。
metal/paddle-mobile/paddle-mobile/Common/MetalExtension.swift
浏览文件 @
78271926
...
@@ -342,6 +342,10 @@ public extension MTLTexture {
...
@@ -342,6 +342,10 @@ public extension MTLTexture {
// n c h w - dim
// n c h w - dim
func
toTensor
(
dim
:
(
n
:
Int
,
c
:
Int
,
h
:
Int
,
w
:
Int
))
->
[
Float32
]
{
func
toTensor
(
dim
:
(
n
:
Int
,
c
:
Int
,
h
:
Int
,
w
:
Int
))
->
[
Float32
]
{
print
(
"origin dim:
\(
dim
)
"
)
print
(
"texture: "
)
print
(
self
)
let
textureArray
=
floatArray
{
(
i
:
Float32
)
->
Float32
in
let
textureArray
=
floatArray
{
(
i
:
Float32
)
->
Float32
in
return
i
return
i
}
}
...
@@ -358,8 +362,42 @@ public extension MTLTexture {
...
@@ -358,8 +362,42 @@ public extension MTLTexture {
}
}
}
}
}
}
print
(
" tensor count --
\(
output
.
count
)
"
)
return
output
return
output
}
}
func
realNHWC
(
dim
:
(
n
:
Int
,
h
:
Int
,
w
:
Int
,
c
:
Int
))
->
[
Float32
]
{
print
(
"origin dim:
\(
dim
)
"
)
print
(
"texture: "
)
print
(
self
)
let
textureArray
=
floatArray
{
(
i
:
Float32
)
->
Float32
in
return
i
}
var
output
:
[
Float32
]
=
[]
let
numOfASlice
=
dim
.
h
*
dim
.
w
*
4
for
h
in
0
..<
dim
.
h
{
for
w
in
0
..<
dim
.
w
{
for
sliceIndex
in
0
..<
arrayLength
{
if
sliceIndex
*
4
+
4
>
dim
.
c
{
for
i
in
0
..<
((
sliceIndex
*
4
+
4
)
-
dim
.
c
)
{
let
value
=
textureArray
[
sliceIndex
*
numOfASlice
+
h
*
dim
.
w
*
4
+
w
*
4
+
i
]
output
.
append
(
value
)
}
}
else
{
for
i
in
0
..<
4
{
let
value
=
textureArray
[
sliceIndex
*
numOfASlice
+
h
*
dim
.
w
*
4
+
w
*
4
+
i
]
output
.
append
(
value
)
}
}
}
}
}
print
(
" tensor count --
\(
output
.
count
)
"
)
return
output
}
}
}
...
...
metal/paddle-mobile/paddle-mobile/Executor.swift
浏览文件 @
78271926
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
import
Foundation
import
Foundation
let
testTo
=
4
1
let
testTo
=
4
8
public
class
ResultHolder
<
P
:
PrecisionType
>
{
public
class
ResultHolder
<
P
:
PrecisionType
>
{
public
let
dim
:
[
Int
]
public
let
dim
:
[
Int
]
...
...
metal/paddle-mobile/paddle-mobile/Operators/ConvAddOp.swift
浏览文件 @
78271926
...
@@ -47,9 +47,9 @@ class ConvAddOp<P: PrecisionType>: Operator<ConvAddKernel<P>, ConvAddParam<P>>,
...
@@ -47,9 +47,9 @@ class ConvAddOp<P: PrecisionType>: Operator<ConvAddKernel<P>, ConvAddParam<P>>,
func
delogOutput
()
{
func
delogOutput
()
{
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
(
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(" conv add: ")
// print(para.input.metalTexture)
// print(para.input.metalTexture)
// print(" filter array: ")
// print(" filter array: ")
...
...
metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddBatchNormReluKernel.swift
浏览文件 @
78271926
...
@@ -50,7 +50,7 @@ class ConvAddBatchNormReluKernel<P: PrecisionType>: Kernel, Computable, Testable
...
@@ -50,7 +50,7 @@ class ConvAddBatchNormReluKernel<P: PrecisionType>: Kernel, Computable, Testable
required
init
(
device
:
MTLDevice
,
param
:
ConvAddBatchNormReluParam
<
P
>
)
{
required
init
(
device
:
MTLDevice
,
param
:
ConvAddBatchNormReluParam
<
P
>
)
{
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
3
,
1
,
2
])
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
])
if
param
.
filter
.
width
==
1
&&
param
.
filter
.
height
==
1
{
if
param
.
filter
.
width
==
1
&&
param
.
filter
.
height
==
1
{
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_batch_norm_relu_1x1"
)
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_batch_norm_relu_1x1"
)
...
...
metal/paddle-mobile/paddle-mobile/Operators/Kernels/ConvAddKernel.swift
浏览文件 @
78271926
...
@@ -25,7 +25,7 @@ class ConvAddKernel<P: PrecisionType>: Kernel, Computable {
...
@@ -25,7 +25,7 @@ class ConvAddKernel<P: PrecisionType>: Kernel, Computable {
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_3x3"
)
super
.
init
(
device
:
device
,
inFunctionName
:
"conv_add_3x3"
)
}
}
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
3
,
1
,
2
])
param
.
output
.
initTexture
(
device
:
device
,
inTranspose
:
[
0
,
2
,
3
,
1
])
let
offsetX
=
param
.
filter
.
width
/
2
-
Int
(
param
.
paddings
[
0
])
let
offsetX
=
param
.
filter
.
width
/
2
-
Int
(
param
.
paddings
[
0
])
let
offsetY
=
param
.
filter
.
height
/
2
-
Int
(
param
.
paddings
[
1
])
let
offsetY
=
param
.
filter
.
height
/
2
-
Int
(
param
.
paddings
[
1
])
...
...
metal/paddle-mobile/paddle-mobile/Operators/TransposeOp.swift
浏览文件 @
78271926
...
@@ -49,8 +49,12 @@ class TransposeOp<P: PrecisionType>: Operator<TransposeKernel<P>, TransposeParam
...
@@ -49,8 +49,12 @@ class TransposeOp<P: PrecisionType>: Operator<TransposeKernel<P>, TransposeParam
}
}
}
}
func
delogOutput
()
{
func
delogOutput
()
{
print
(
para
.
input
.
metalTexture
.
toTensor
(
dim
:
(
n
:
para
.
input
.
tensorDim
[
0
],
c
:
para
.
input
.
tensorDim
[
1
],
h
:
para
.
input
.
tensorDim
[
2
],
w
:
para
.
input
.
tensorDim
[
3
]))
.
strideArray
())
print
(
para
.
output
.
metalTexture
.
toTensor
(
dim
:
(
n
:
1
,
c
:
21
,
h
:
19
,
w
:
19
))
.
strideArray
())
let
originDim
=
para
.
output
.
tensorDim
let
outputArray
=
para
.
output
.
metalTexture
.
realNHWC
(
dim
:
(
n
:
originDim
[
0
],
h
:
originDim
[
1
],
w
:
originDim
[
2
],
c
:
originDim
[
3
]))
print
(
outputArray
.
strideArray
())
// let inputArray: [Float32] = para.input.metalTexture.floatArray { (ele: Float32) -> Float32 in
// let inputArray: [Float32] = para.input.metalTexture.floatArray { (ele: Float32) -> Float32 in
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录