Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
9fbdede6
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看板
未验证
提交
9fbdede6
编写于
5月 28, 2019
作者:
Y
Yanzhan Yang
提交者:
GitHub
5月 28, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
1. lazy load for mpsimage. (#1666)
上级
bfca5725
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
13 deletion
+30
-13
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddReluKernel.swift
...ddle-mobile/Src/Operators/Kernels/ConvAddReluKernel.swift
+19
-10
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ScaleOpKernel.swift
...e/paddle-mobile/Src/Operators/Kernels/ScaleOpKernel.swift
+11
-3
未找到文件。
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ConvAddReluKernel.swift
浏览文件 @
9fbdede6
...
...
@@ -147,19 +147,28 @@ class ConvAddReluKernel<P: PrecisionProtocol>: Kernel, Computable {
}
}
var
inputImage
:
AnyObject
?
var
outputImage
:
AnyObject
?
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ConvAddReluParam
<
P
>
)
throws
{
if
#available(iOS 10.0, *)
{
if
let
conv
=
mpsConvOp
as?
MPSCNNConvolution
{
let
inputImage
=
MPSImage
.
init
(
texture
:
param
.
input
.
metalTexture
,
featureChannels
:
param
.
input
.
tensorDim
[
1
])
let
outputImage
=
MPSImage
.
init
(
texture
:
param
.
output
.
metalTexture
,
featureChannels
:
param
.
output
.
tensorDim
[
1
])
conv
.
encode
(
commandBuffer
:
commandBuffer
,
sourceImage
:
inputImage
,
destinationImage
:
outputImage
)
if
#available(iOS 11.3, *)
{
if
let
add
=
mpsAddOp
as?
MPSCNNAdd
,
let
y
=
param
.
y
{
let
biasImage
=
MPSImage
.
init
(
texture
:
y
.
metalTexture
,
featureChannels
:
y
.
tensorDim
[
1
])
add
.
encode
(
commandBuffer
:
commandBuffer
,
primaryImage
:
outputImage
,
secondaryImage
:
biasImage
,
destinationImage
:
outputImage
)
}
if
let
relu
=
mpsReluOp
as?
MPSCNNNeuronReLU
{
relu
.
encode
(
commandBuffer
:
commandBuffer
,
sourceImage
:
outputImage
,
destinationImage
:
outputImage
)
if
inputImage
==
nil
{
inputImage
=
MPSImage
.
init
(
texture
:
param
.
input
.
metalTexture
,
featureChannels
:
param
.
input
.
tensorDim
[
1
])
}
if
outputImage
==
nil
{
outputImage
=
MPSImage
.
init
(
texture
:
param
.
output
.
metalTexture
,
featureChannels
:
param
.
output
.
tensorDim
[
1
])
}
if
let
inputImage
=
inputImage
as?
MPSImage
,
let
outputImage
=
outputImage
as?
MPSImage
{
conv
.
encode
(
commandBuffer
:
commandBuffer
,
sourceImage
:
inputImage
,
destinationImage
:
outputImage
)
if
#available(iOS 11.3, *)
{
if
let
add
=
mpsAddOp
as?
MPSCNNAdd
,
let
y
=
param
.
y
{
let
biasImage
=
MPSImage
.
init
(
texture
:
y
.
metalTexture
,
featureChannels
:
y
.
tensorDim
[
1
])
add
.
encode
(
commandBuffer
:
commandBuffer
,
primaryImage
:
outputImage
,
secondaryImage
:
biasImage
,
destinationImage
:
outputImage
)
}
if
let
relu
=
mpsReluOp
as?
MPSCNNNeuronReLU
{
relu
.
encode
(
commandBuffer
:
commandBuffer
,
sourceImage
:
outputImage
,
destinationImage
:
outputImage
)
}
}
}
return
...
...
metal/paddle-mobile/paddle-mobile/Src/Operators/Kernels/ScaleOpKernel.swift
浏览文件 @
9fbdede6
...
...
@@ -23,6 +23,8 @@ struct ScaleMetalParam {
class
ScaleOpKernel
<
P
:
PrecisionProtocol
>
:
Kernel
,
Computable
{
var
metalParam
:
ScaleMetalParam
var
mpsScaleOp
:
AnyObject
?
var
inputImage
:
AnyObject
?
var
outputImage
:
AnyObject
?
required
init
(
device
:
MTLDevice
,
param
:
ScaleParam
<
P
>
,
initContext
:
InitContext
)
throws
{
do
{
...
...
@@ -67,9 +69,15 @@ class ScaleOpKernel<P: PrecisionProtocol>: Kernel, Computable{
func
compute
(
commandBuffer
:
MTLCommandBuffer
,
param
:
ScaleParam
<
P
>
)
throws
{
if
#available(iOS 10.0, *)
,
let
mpsScaleOp
=
mpsScaleOp
as?
MPSCNNNeuronLinear
{
let
inputImage
=
MPSImage
.
init
(
texture
:
param
.
input
.
metalTexture
,
featureChannels
:
param
.
input
.
tensorDim
[
1
])
let
outputImage
=
MPSImage
.
init
(
texture
:
param
.
output
.
metalTexture
,
featureChannels
:
param
.
output
.
tensorDim
[
1
])
mpsScaleOp
.
encode
(
commandBuffer
:
commandBuffer
,
sourceImage
:
inputImage
,
destinationImage
:
outputImage
)
if
inputImage
==
nil
{
inputImage
=
MPSImage
.
init
(
texture
:
param
.
input
.
metalTexture
,
featureChannels
:
param
.
input
.
tensorDim
[
1
])
}
if
outputImage
==
nil
{
outputImage
=
MPSImage
.
init
(
texture
:
param
.
output
.
metalTexture
,
featureChannels
:
param
.
output
.
tensorDim
[
1
])
}
if
let
inputImage
=
inputImage
as?
MPSImage
,
let
outputImage
=
outputImage
as?
MPSImage
{
mpsScaleOp
.
encode
(
commandBuffer
:
commandBuffer
,
sourceImage
:
inputImage
,
destinationImage
:
outputImage
)
}
return
}
guard
let
encoder
=
commandBuffer
.
makeComputeCommandEncoder
()
else
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录