Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
ad098db1
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看板
提交
ad098db1
编写于
5月 21, 2019
作者:
N
NazgulLee
提交者:
Yanzhan Yang
5月 21, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
method to adjust texture transpose (#1642)
上级
6d761d3c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
46 addition
and
0 deletion
+46
-0
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/Base/Kernel.swift
...ile/paddle-mobile/Src/Operators/Kernels/Base/Kernel.swift
+46
-0
未找到文件。
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/Base/Kernel.swift
浏览文件 @
ad098db1
...
@@ -54,6 +54,52 @@ protocol KernelProtocol {
...
@@ -54,6 +54,52 @@ protocol KernelProtocol {
_pipline
=
device
.
pipeLine
(
funcName
:
funcName
,
metalLoadMode
:
initContext
.
metalLoadMode
,
metalLibPath
:
initContext
.
metalLibPath
)
_pipline
=
device
.
pipeLine
(
funcName
:
funcName
,
metalLoadMode
:
initContext
.
metalLoadMode
,
metalLibPath
:
initContext
.
metalLibPath
)
}
}
}
}
func
encodeTransposeInput
(
input
:
Texture
,
toTranspose
:
[
Int
],
commandBuffer
:
MTLCommandBuffer
,
device
:
MTLDevice
,
initContext
:
InitContext
)
->
Texture
?
{
do
{
let
intermediateTexture
=
Texture
(
device
:
device
,
inDim
:
input
.
tensorDim
)
try
intermediateTexture
.
initTexture
(
device
:
device
,
inTranspose
:
toTranspose
,
computePrecision
:
GlobalConfig
.
shared
.
computePrecision
)
let
irank
=
input
.
tensorDim
.
cout
()
let
orank
=
intermediateTexture
.
tensorDim
.
cout
()
var
funcName
=
""
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float32
{
funcName
=
"reshape_
\(
irank
)
_
\(
orank
)
_float"
}
else
if
GlobalConfig
.
shared
.
computePrecision
==
.
Float16
{
funcName
=
"reshape_
\(
irank
)
_
\(
orank
)
_half"
}
else
{
fatalError
()
}
let
intermediatePipeline
=
device
.
pipeLine
(
funcName
:
funcName
,
metalLoadMode
:
initContext
.
metalLoadMode
,
metalLibPath
:
initContext
.
metalLibPath
)
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
throw
PaddleMobileError
.
predictError
(
message
:
" encode is nil"
)
}
encoder
.
setTexture
(
input
.
metalTexture
,
index
:
0
)
encoder
.
setTexture
(
intermediateTexture
.
metalTexture
,
index
:
1
)
var
id
:
[
Int32
]
=
[
1
,
1
,
1
,
1
]
for
i
in
0
..<
input
.
tensorDim
.
cout
()
{
id
[
4
-
input
.
tensorDim
.
cout
()
+
i
]
=
Int32
(
input
.
tensorDim
[
i
])
}
let
it
:
[
Int32
]
=
input
.
transpose
.
map
{
Int32
(
$0
)
}
var
od
:
[
Int32
]
=
[
1
,
1
,
1
,
1
]
for
i
in
0
..<
intermediateTexture
.
tensorDim
.
cout
()
{
od
[
4
-
intermediateTexture
.
tensorDim
.
cout
()
+
i
]
=
Int32
(
intermediateTexture
.
tensorDim
[
i
])
}
let
ot
:
[
Int32
]
=
intermediateTexture
.
transpose
.
map
{
Int32
(
$0
)
}
var
reshapeMetalParam
=
ReshapeMetalParam
.
init
(
idim
:
(
id
[
0
],
id
[
1
],
id
[
2
],
id
[
3
]),
itrans
:
(
it
[
0
],
it
[
1
],
it
[
2
],
it
[
3
]),
odim
:
(
od
[
0
],
od
[
1
],
od
[
2
],
od
[
3
]),
otrans
:
(
ot
[
0
],
ot
[
1
],
ot
[
2
],
ot
[
3
])
)
encoder
.
setBytes
(
&
reshapeMetalParam
,
length
:
MemoryLayout
<
ReshapeMetalParam
>.
size
,
index
:
0
)
encoder
.
dispatch
(
computePipline
:
intermediatePipeline
,
outTexture
:
intermediateTexture
.
metalTexture
)
encoder
.
endEncoding
()
return
intermediateTexture
}
catch
_
{
return
nil
}
}
}
}
@objc
public
class
Shape
:
NSObject
{
@objc
public
class
Shape
:
NSObject
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录