Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
34f21226
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
34f21226
编写于
8月 28, 2020
作者:
C
chenjianping
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
caffeprelu rename to prelu
上级
29070d60
变更
24
显示空白变更内容
内联
并排
Showing
24 changed file
with
71 addition
and
243 deletion
+71
-243
mindspore/lite/schema/model.fbs
mindspore/lite/schema/model.fbs
+1
-2
mindspore/lite/schema/ops.fbs
mindspore/lite/schema/ops.fbs
+1
-5
mindspore/lite/src/ops/p_relu.cc
mindspore/lite/src/ops/p_relu.cc
+5
-5
mindspore/lite/src/ops/p_relu.h
mindspore/lite/src/ops/p_relu.h
+11
-11
mindspore/lite/src/ops/prelu.cc
mindspore/lite/src/ops/prelu.cc
+0
-35
mindspore/lite/src/ops/prelu.h
mindspore/lite/src/ops/prelu.h
+0
-72
mindspore/lite/src/ops/primitive_c.cc
mindspore/lite/src/ops/primitive_c.cc
+10
-10
mindspore/lite/src/populate_parameter.cc
mindspore/lite/src/populate_parameter.cc
+9
-12
mindspore/lite/src/runtime/kernel/arm/base/leaky_relu_base.cc
...spore/lite/src/runtime/kernel/arm/base/leaky_relu_base.cc
+3
-3
mindspore/lite/src/runtime/kernel/arm/fp32/gather.cc
mindspore/lite/src/runtime/kernel/arm/fp32/gather.cc
+5
-2
mindspore/lite/src/runtime/kernel/arm/fp32/gather.h
mindspore/lite/src/runtime/kernel/arm/fp32/gather.h
+1
-1
mindspore/lite/src/runtime/kernel/arm/fp32/leaky_relu.cc
mindspore/lite/src/runtime/kernel/arm/fp32/leaky_relu.cc
+0
-2
mindspore/lite/src/runtime/kernel/arm/fp32/prelu.cc
mindspore/lite/src/runtime/kernel/arm/fp32/prelu.cc
+3
-3
mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc
...spore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc
+13
-7
mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.h
mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.h
+0
-1
mindspore/lite/src/runtime/kernel/opencl/kernel/prelu.cc
mindspore/lite/src/runtime/kernel/opencl/kernel/prelu.cc
+2
-2
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/prelu_int8_tests.cc
...e/test/ut/src/runtime/kernel/arm/int8/prelu_int8_tests.cc
+2
-2
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc
.../converter/parser/tflite/tflite_activation_parser_test.cc
+0
-9
mindspore/lite/tools/common/node_util.cc
mindspore/lite/tools/common/node_util.cc
+1
-1
mindspore/lite/tools/converter/parser/caffe/caffe_prelu_parser.cc
...e/lite/tools/converter/parser/caffe/caffe_prelu_parser.cc
+2
-2
mindspore/lite/tools/converter/parser/onnx/onnx_relu_parser.cc
...pore/lite/tools/converter/parser/onnx/onnx_relu_parser.cc
+2
-2
mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc
...tools/converter/parser/tflite/tflite_activation_parser.cc
+0
-41
mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.h
.../tools/converter/parser/tflite/tflite_activation_parser.h
+0
-12
mindspore/lite/tools/converter/parser/tflite/tflite_util.cc
mindspore/lite/tools/converter/parser/tflite/tflite_util.cc
+0
-1
未找到文件。
mindspore/lite/schema/model.fbs
浏览文件 @
34f21226
...
...
@@ -80,7 +80,7 @@ union PrimitiveType {
Pad,
Maximum,
Minimum,
Caffe
PReLU,
PReLU,
LeakyReLU,
ArgMax,
ArgMin,
...
...
@@ -126,7 +126,6 @@ union PrimitiveType {
Broadcast,
BroadcastTo,
Lrn,
Prelu,
ZerosLike,
TopK,
SpaceToDepth,
...
...
mindspore/lite/schema/ops.fbs
浏览文件 @
34f21226
...
...
@@ -540,7 +540,7 @@ table MatMul {
transposeB : bool = false;
}
table
Caffe
PReLU {
table PReLU {
channelShared : bool = false;
slope: [float];
}
...
...
@@ -650,10 +650,6 @@ table Reduce {
mode: ReduceMode;
}
table Prelu {
slope: [float];
}
table Transpose {
perm: [int];
conjugate: bool = false;
...
...
mindspore/lite/src/ops/
caffe_
p_relu.cc
→
mindspore/lite/src/ops/p_relu.cc
浏览文件 @
34f21226
...
...
@@ -14,20 +14,20 @@
* limitations under the License.
*/
#include "src/ops/
caffe_
p_relu.h"
#include "src/ops/p_relu.h"
namespace
mindspore
{
namespace
lite
{
#ifdef PRIMITIVE_WRITEABLE
bool
CaffePReLU
::
GetChannelShared
()
const
{
return
this
->
primitive_
->
value
.
AsCaffe
PReLU
()
->
channelShared
;
}
bool
PReLU
::
GetChannelShared
()
const
{
return
this
->
primitive_
->
value
.
As
PReLU
()
->
channelShared
;
}
void
Caffe
PReLU
::
SetChannelShared
(
bool
channel_shared
)
{
this
->
primitive_
->
value
.
As
Caffe
PReLU
()
->
channelShared
=
channel_shared
;
void
PReLU
::
SetChannelShared
(
bool
channel_shared
)
{
this
->
primitive_
->
value
.
AsPReLU
()
->
channelShared
=
channel_shared
;
}
#else
bool
CaffePReLU
::
GetChannelShared
()
const
{
return
this
->
primitive_
->
value_as_Caffe
PReLU
()
->
channelShared
();
}
bool
PReLU
::
GetChannelShared
()
const
{
return
this
->
primitive_
->
value_as_
PReLU
()
->
channelShared
();
}
#endif
}
// namespace lite
...
...
mindspore/lite/src/ops/
caffe_
p_relu.h
→
mindspore/lite/src/ops/p_relu.h
浏览文件 @
34f21226
...
...
@@ -14,8 +14,8 @@
* limitations under the License.
*/
#ifndef LITE_MINDSPORE_LITE_C_OPS_
CAFFE_P_RE_L_
U_H_
#define LITE_MINDSPORE_LITE_C_OPS_
CAFFE_P_RE_L_
U_H_
#ifndef LITE_MINDSPORE_LITE_C_OPS_
P_REL
U_H_
#define LITE_MINDSPORE_LITE_C_OPS_
P_REL
U_H_
#include <vector>
#include <set>
...
...
@@ -26,21 +26,21 @@
namespace
mindspore
{
namespace
lite
{
class
Caffe
PReLU
:
public
Activation
{
class
PReLU
:
public
Activation
{
public:
#ifdef PRIMITIVE_WRITEABLE
MS_DECLARE_PARENT
(
Caffe
PReLU
,
Activation
);
Caffe
PReLU
()
=
default
;
explicit
Caffe
PReLU
(
schema
::
PrimitiveT
*
primitive
)
:
Activation
(
primitive
)
{}
MS_DECLARE_PARENT
(
PReLU
,
Activation
);
PReLU
()
=
default
;
explicit
PReLU
(
schema
::
PrimitiveT
*
primitive
)
:
Activation
(
primitive
)
{}
void
SetChannelShared
(
bool
channel_shared
);
#else
explicit
Caffe
PReLU
(
schema
::
Primitive
*
primitive
)
:
Activation
(
primitive
)
{}
explicit
PReLU
(
schema
::
Primitive
*
primitive
)
:
Activation
(
primitive
)
{}
schema
::
Primitive
*
Init
(
schema
::
Primitive
*
primitive
)
{
flatbuffers
::
FlatBufferBuilder
fbb
(
1024
);
auto
attr
=
primitive
->
value_as_
Caffe
PReLU
();
auto
attr
=
primitive
->
value_as_PReLU
();
MS_ASSERT
(
attr
!=
nullptr
);
auto
slope
=
std
::
make_unique
<
std
::
vector
<
float
>>
();
...
...
@@ -48,8 +48,8 @@ class CaffePReLU : public Activation {
slope
->
push_back
(
attr
->
slope
()
->
data
()[
i
]);
}
auto
val_offset
=
schema
::
Create
Caffe
PReLUDirect
(
fbb
,
attr
->
channelShared
(),
slope
.
release
());
auto
prim_offset
=
schema
::
CreatePrimitive
(
fbb
,
schema
::
PrimitiveType_
Caffe
PReLU
,
val_offset
.
o
);
auto
val_offset
=
schema
::
CreatePReLUDirect
(
fbb
,
attr
->
channelShared
(),
slope
.
release
());
auto
prim_offset
=
schema
::
CreatePrimitive
(
fbb
,
schema
::
PrimitiveType_PReLU
,
val_offset
.
o
);
fbb
.
Finish
(
prim_offset
);
auto
buf
=
fbb
.
GetBufferPointer
();
...
...
@@ -70,4 +70,4 @@ class CaffePReLU : public Activation {
}
// namespace lite
}
// namespace mindspore
#endif // LITE_MINDSPORE_LITE_C_OPS_
CAFFE_P_RE_L_
U_H_
#endif // LITE_MINDSPORE_LITE_C_OPS_
P_REL
U_H_
mindspore/lite/src/ops/prelu.cc
已删除
100644 → 0
浏览文件 @
29070d60
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "src/ops/prelu.h"
namespace
mindspore
{
namespace
lite
{
#ifdef PRIMITIVE_WRITEABLE
std
::
vector
<
float
>
Prelu
::
GetSlope
()
const
{
return
this
->
primitive_
->
value
.
AsPrelu
()
->
slope
;
}
void
Prelu
::
SetSlope
(
const
std
::
vector
<
float
>
&
slope
)
{
this
->
primitive_
->
value
.
AsPrelu
()
->
slope
=
slope
;
}
#else
std
::
vector
<
float
>
Prelu
::
GetSlope
()
const
{
auto
fb_vector
=
this
->
primitive_
->
value_as_Prelu
()
->
slope
();
return
std
::
vector
<
float
>
(
fb_vector
->
begin
(),
fb_vector
->
end
());
}
#endif
}
// namespace lite
}
// namespace mindspore
mindspore/lite/src/ops/prelu.h
已删除
100644 → 0
浏览文件 @
29070d60
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef LITE_MINDSPORE_LITE_C_OPS_PRELU_H_
#define LITE_MINDSPORE_LITE_C_OPS_PRELU_H_
#include <vector>
#include <set>
#include <cmath>
#include <memory>
#include "ir/dtype/type_id.h"
#include "src/ops/activation.h"
namespace
mindspore
{
namespace
lite
{
class
Prelu
:
public
Activation
{
public:
#ifdef PRIMITIVE_WRITEABLE
MS_DECLARE_PARENT
(
Prelu
,
PrimitiveC
);
Prelu
()
=
default
;
explicit
Prelu
(
schema
::
PrimitiveT
*
primitive
)
:
Activation
(
primitive
)
{}
void
SetSlope
(
const
std
::
vector
<
float
>
&
slope
);
#else
explicit
Prelu
(
schema
::
Primitive
*
primitive
)
:
Activation
(
primitive
)
{}
schema
::
Primitive
*
Init
(
schema
::
Primitive
*
primitive
)
{
flatbuffers
::
FlatBufferBuilder
fbb
(
1024
);
auto
attr
=
primitive
->
value_as_Prelu
();
MS_ASSERT
(
attr
!=
nullptr
);
auto
slope
=
std
::
make_unique
<
std
::
vector
<
float
>>
();
for
(
int
i
=
0
;
i
<
static_cast
<
int
>
(
attr
->
slope
()
->
size
());
i
++
)
{
slope
->
push_back
(
attr
->
slope
()
->
data
()[
i
]);
}
auto
val_offset
=
schema
::
CreatePreluDirect
(
fbb
,
slope
.
release
());
auto
prim_offset
=
schema
::
CreatePrimitive
(
fbb
,
schema
::
PrimitiveType_Prelu
,
val_offset
.
o
);
fbb
.
Finish
(
prim_offset
);
auto
buf
=
fbb
.
GetBufferPointer
();
MS_ASSERT
(
buf
!=
nullptr
);
auto
buf_bak
=
new
char
[
fbb
.
GetSize
()];
memcpy
(
buf_bak
,
buf
,
fbb
.
GetSize
());
auto
root
=
flatbuffers
::
GetRoot
<
schema
::
Primitive
>
(
buf_bak
);
auto
prim
=
const_cast
<
schema
::
Primitive
*>
(
root
);
delete
[]
buf_bak
;
fbb
.
Clear
();
return
prim
;
}
#endif
std
::
vector
<
float
>
GetSlope
()
const
;
};
}
// namespace lite
}
// namespace mindspore
#endif // LITE_MINDSPORE_LITE_C_OPS_PRELU_H_
mindspore/lite/src/ops/primitive_c.cc
浏览文件 @
34f21226
...
...
@@ -72,8 +72,8 @@
#include "src/ops/gather_nd.h"
#include "src/ops/local_response_normalization.h"
#include "src/ops/pad.h"
#include "src/ops/prelu.h"
#include "src/ops/
caffe_p
_relu.h"
#include "src/ops/p
_
relu.h"
#include "src/ops/
leaky
_relu.h"
#include "src/ops/reverse_sequence.h"
#include "src/ops/dedepthwise_conv2d.h"
#include "src/ops/depthwise_conv2d.h"
...
...
@@ -346,10 +346,10 @@ PrimitiveC *PrimitiveC::UnPackFromSchemaPrimitiveT(mindspore::schema::PrimitiveT
return
new
Minimum
(
primitive
);
case
schema
::
PrimitiveType_StridedSlice
:
return
new
StridedSlice
(
primitive
);
case
schema
::
PrimitiveType_
Prelu
:
return
new
Prelu
(
primitive
);
case
schema
::
PrimitiveType_
Caffe
PReLU
:
return
new
Caffe
PReLU
(
primitive
);
case
schema
::
PrimitiveType_
LeakyReLU
:
return
new
(
std
::
nothrow
)
LeakyReLU
(
primitive
);
case
schema
::
PrimitiveType_PReLU
:
return
new
(
std
::
nothrow
)
PReLU
(
primitive
);
case
schema
::
PrimitiveType_Round
:
return
new
Round
(
primitive
);
case
schema
::
PrimitiveType_Reverse
:
...
...
@@ -554,10 +554,10 @@ PrimitiveC *PrimitiveC::UnPackFromSchemaPrimitive(mindspore::schema::Primitive *
return
new
Minimum
(
const_cast
<
schema
::
Primitive
*>
(
primitive
));
case
schema
::
PrimitiveType_StridedSlice
:
return
new
StridedSlice
(
const_cast
<
schema
::
Primitive
*>
(
primitive
));
case
schema
::
PrimitiveType_
Prelu
:
return
new
Prelu
(
const_cast
<
schema
::
Primitive
*>
(
primitive
));
case
schema
::
PrimitiveType_
Caffe
PReLU
:
return
new
Caffe
PReLU
(
const_cast
<
schema
::
Primitive
*>
(
primitive
));
case
schema
::
PrimitiveType_
LeakyReLU
:
return
new
(
std
::
nothrow
)
LeakyReLU
(
const_cast
<
schema
::
Primitive
*>
(
primitive
));
case
schema
::
PrimitiveType_PReLU
:
return
new
(
std
::
nothrow
)
PReLU
(
const_cast
<
schema
::
Primitive
*>
(
primitive
));
case
schema
::
PrimitiveType_Round
:
return
new
Round
(
const_cast
<
schema
::
Primitive
*>
(
primitive
));
case
schema
::
PrimitiveType_Reverse
:
...
...
mindspore/lite/src/populate_parameter.cc
浏览文件 @
34f21226
...
...
@@ -75,8 +75,8 @@
#include "src/ops/gather_nd.h"
#include "src/ops/local_response_normalization.h"
#include "src/ops/pad.h"
#include "src/ops/
p
relu.h"
#include "src/ops/
caffe_
p_relu.h"
#include "src/ops/
leaky_
relu.h"
#include "src/ops/p_relu.h"
#include "src/ops/reverse_sequence.h"
#include "src/ops/dedepthwise_conv2d.h"
#include "src/ops/depthwise_conv2d.h"
...
...
@@ -233,7 +233,7 @@ OpParameter *PopulateExpandDimsParameter(const mindspore::lite::PrimitiveC *prim
}
OpParameter
*
PopulatePReLUParameter
(
const
mindspore
::
lite
::
PrimitiveC
*
primitive
)
{
auto
param
=
dynamic_cast
<
const
mindspore
::
lite
::
Caffe
PReLU
*>
(
primitive
);
auto
param
=
dynamic_cast
<
const
mindspore
::
lite
::
PReLU
*>
(
primitive
);
PReluParameter
*
prelu_param
=
reinterpret_cast
<
PReluParameter
*>
(
malloc
(
sizeof
(
PReluParameter
)));
if
(
prelu_param
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"malloc PReluParameter failed."
;
...
...
@@ -246,7 +246,7 @@ OpParameter *PopulatePReLUParameter(const mindspore::lite::PrimitiveC *primitive
}
OpParameter
*
PopulateLeakyReluParameter
(
const
mindspore
::
lite
::
PrimitiveC
*
primitive
)
{
auto
param
=
dynamic_cast
<
const
mindspore
::
lite
::
Prelu
*>
(
primitive
);
auto
param
=
dynamic_cast
<
const
mindspore
::
lite
::
LeakyReLU
*>
(
primitive
);
LeakyReluParameter
*
leaky_relu_param
=
reinterpret_cast
<
LeakyReluParameter
*>
(
malloc
(
sizeof
(
LeakyReluParameter
)));
if
(
leaky_relu_param
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"malloc LeakyReluParameter failed."
;
...
...
@@ -254,17 +254,14 @@ OpParameter *PopulateLeakyReluParameter(const mindspore::lite::PrimitiveC *primi
}
memset
(
leaky_relu_param
,
0
,
sizeof
(
LeakyReluParameter
));
leaky_relu_param
->
op_parameter_
.
type_
=
primitive
->
Type
();
auto
temp
=
param
->
GetSlope
();
leaky_relu_param
->
slope_
=
reinterpret_cast
<
float
*>
(
malloc
(
temp
.
size
()
*
sizeof
(
float
)));
leaky_relu_param
->
slope_
=
reinterpret_cast
<
float
*>
(
malloc
(
sizeof
(
float
)));
if
(
leaky_relu_param
->
slope_
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"malloc relu slope fail!"
;
free
(
leaky_relu_param
);
return
nullptr
;
}
for
(
size_t
i
=
0
;
i
<
temp
.
size
();
i
++
)
{
leaky_relu_param
->
slope_
[
i
]
=
temp
[
i
];
}
leaky_relu_param
->
slope_num_
=
temp
.
size
();
leaky_relu_param
->
slope_
[
0
]
=
param
->
GetNegativeSlope
();
leaky_relu_param
->
slope_num_
=
1
;
return
reinterpret_cast
<
OpParameter
*>
(
leaky_relu_param
);
}
...
...
@@ -1598,8 +1595,8 @@ PopulateParameterRegistry::PopulateParameterRegistry() {
populate_parameter_funcs_
[
schema
::
PrimitiveType_ScatterND
]
=
PopulateScatterNDParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_Squeeze
]
=
PopulateSqueezeParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_Split
]
=
PopulateSplitParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_
Caffe
PReLU
]
=
PopulatePReLUParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_
Prelu
]
=
PopulateLeakyReluParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_PReLU
]
=
PopulatePReLUParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_
LeakyReLU
]
=
PopulateLeakyReluParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_PriorBox
]
=
PopulatePriorBoxParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_QuantDTypeCast
]
=
PopulateQuantDTypeCastParameter
;
populate_parameter_funcs_
[
schema
::
PrimitiveType_Lstm
]
=
PopulateLstmParameter
;
...
...
mindspore/lite/src/runtime/kernel/arm/base/leaky_relu_base.cc
浏览文件 @
34f21226
...
...
@@ -29,7 +29,7 @@ using mindspore::schema::PrimitiveType_LeakyReLU;
namespace
mindspore
::
kernel
{
int
LeakyReluBaseCPUKernel
::
Init
()
{
return
RET_OK
;
}
kernel
::
LiteKernel
*
Cpu
Pr
eluInt8KernelCreator
(
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
kernel
::
LiteKernel
*
Cpu
LeakyR
eluInt8KernelCreator
(
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
inputs
,
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
OpParameter
*
opParameter
,
const
Context
*
ctx
,
const
kernel
::
KernelKey
&
desc
,
...
...
@@ -41,7 +41,7 @@ kernel::LiteKernel *CpuPreluInt8KernelCreator(const std::vector<lite::tensor::Te
MS_ASSERT
(
desc
.
type
==
schema
::
PrimitiveType_LeakyRelu
);
auto
*
kernel
=
new
(
std
::
nothrow
)
LeakyReluInt8CPUKernel
(
opParameter
,
inputs
,
outputs
,
ctx
,
primitive
);
if
(
kernel
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"new
Prelu
CPUKernel fail!"
;
MS_LOG
(
ERROR
)
<<
"new
LeakyReluInt8
CPUKernel fail!"
;
return
nullptr
;
}
auto
ret
=
kernel
->
Init
();
...
...
@@ -54,5 +54,5 @@ kernel::LiteKernel *CpuPreluInt8KernelCreator(const std::vector<lite::tensor::Te
return
kernel
;
}
REG_KERNEL
(
kCPU
,
kNumberTypeInt8
,
PrimitiveType_LeakyReLU
,
Cpu
Pr
eluInt8KernelCreator
)
REG_KERNEL
(
kCPU
,
kNumberTypeInt8
,
PrimitiveType_LeakyReLU
,
Cpu
LeakyR
eluInt8KernelCreator
)
}
// namespace mindspore::kernel
mindspore/lite/src/runtime/kernel/arm/fp32/gather.cc
浏览文件 @
34f21226
...
...
@@ -38,7 +38,10 @@ int GatherCPUKernel::Init() {
}
GatherCPUKernel
::~
GatherCPUKernel
()
{
context_
->
allocator
->
Free
(
indices_data_
);
if
(
indices_data_
!=
nullptr
)
{
free
(
indices_data_
);
indices_data_
=
nullptr
;
}
}
int
GatherCPUKernel
::
ReSize
()
{
return
RET_OK
;
}
...
...
@@ -102,7 +105,7 @@ int GatherCPUKernel::Run() {
}
auto
indices_tensor
=
in_tensors_
.
at
(
1
);
indices_data_
=
reinterpret_cast
<
int
*>
(
context_
->
allocator
->
M
alloc
(
indices_tensor
->
Size
()));
indices_data_
=
reinterpret_cast
<
int
*>
(
m
alloc
(
indices_tensor
->
Size
()));
if
(
indices_data_
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"Memory allocation failed"
;
return
RET_ERROR
;
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/gather.h
浏览文件 @
34f21226
...
...
@@ -36,7 +36,7 @@ class GatherCPUKernel : public LiteKernel {
int
DoGather
(
int
task_id
);
private:
int
*
indices_data_
;
int
*
indices_data_
=
nullptr
;
};
}
// namespace mindspore::kernel
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/leaky_relu.cc
浏览文件 @
34f21226
...
...
@@ -26,7 +26,6 @@ using mindspore::lite::KernelRegistrar;
using
mindspore
::
lite
::
RET_ERROR
;
using
mindspore
::
lite
::
RET_OK
;
using
mindspore
::
schema
::
PrimitiveType_LeakyReLU
;
using
mindspore
::
schema
::
PrimitiveType_Prelu
;
namespace
mindspore
::
kernel
{
namespace
{
...
...
@@ -100,5 +99,4 @@ kernel::LiteKernel *CpuLeakyReluFp32KernelCreator(const std::vector<lite::tensor
}
REG_KERNEL
(
kCPU
,
kNumberTypeFloat32
,
PrimitiveType_LeakyReLU
,
CpuLeakyReluFp32KernelCreator
)
REG_KERNEL
(
kCPU
,
kNumberTypeFloat32
,
PrimitiveType_Prelu
,
CpuLeakyReluFp32KernelCreator
)
}
// namespace mindspore::kernel
mindspore/lite/src/runtime/kernel/arm/fp32/prelu.cc
浏览文件 @
34f21226
...
...
@@ -24,7 +24,7 @@ using mindspore::kernel::KERNEL_ARCH::kCPU;
using
mindspore
::
lite
::
KernelRegistrar
;
using
mindspore
::
lite
::
RET_ERROR
;
using
mindspore
::
lite
::
RET_OK
;
using
mindspore
::
schema
::
PrimitiveType_
Caffe
PReLU
;
using
mindspore
::
schema
::
PrimitiveType_PReLU
;
namespace
mindspore
::
kernel
{
namespace
{
...
...
@@ -155,7 +155,7 @@ kernel::LiteKernel *CpuPReluFp32KernelCreator(const std::vector<lite::tensor::Te
MS_LOG
(
ERROR
)
<<
"input param is nullptr!"
;
return
nullptr
;
}
MS_ASSERT
(
desc
.
type
==
schema
::
PrimitiveType_Prelu
);
auto
*
kernel
=
new
(
std
::
nothrow
)
PReluCPUKernel
(
param
,
inputs
,
outputs
,
ctx
,
primitive
);
if
(
kernel
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"new PReluCPUKernel fail!"
;
...
...
@@ -171,5 +171,5 @@ kernel::LiteKernel *CpuPReluFp32KernelCreator(const std::vector<lite::tensor::Te
return
kernel
;
}
REG_KERNEL
(
kCPU
,
kNumberTypeFloat32
,
PrimitiveType_
Caffe
PReLU
,
CpuPReluFp32KernelCreator
)
REG_KERNEL
(
kCPU
,
kNumberTypeFloat32
,
PrimitiveType_PReLU
,
CpuPReluFp32KernelCreator
)
}
// namespace mindspore::kernel
mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.cc
浏览文件 @
34f21226
...
...
@@ -25,9 +25,20 @@ using mindspore::kernel::KERNEL_ARCH::kCPU;
using
mindspore
::
lite
::
KernelRegistrar
;
using
mindspore
::
lite
::
RET_ERROR
;
using
mindspore
::
lite
::
RET_OK
;
using
mindspore
::
schema
::
PrimitiveType_Prelu
;
namespace
mindspore
::
kernel
{
namespace
{
int
LeakyReluInt8Run
(
void
*
cdata
,
int
task_id
)
{
if
(
cdata
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"input cdata is nullptr!"
;
return
RET_ERROR
;
}
auto
relu
=
reinterpret_cast
<
LeakyReluInt8CPUKernel
*>
(
cdata
);
relu
->
DoExecute
(
task_id
);
return
RET_OK
;
}
}
// namespace
int
LeakyReluInt8CPUKernel
::
Init
()
{
LeakyReluBaseCPUKernel
::
Init
();
LeakyReluParameter
*
param
=
reinterpret_cast
<
LeakyReluParameter
*>
(
op_parameter_
);
...
...
@@ -82,17 +93,12 @@ int LeakyReluInt8CPUKernel::Run() {
MS_LOG
(
ERROR
)
<<
"Prepare fail!ret: "
<<
ret
;
return
ret
;
}
ret
=
ParallelLaunch
(
THREAD_POOL_DEFAULT
,
Pr
eluInt8Run
,
this
,
op_parameter_
->
thread_num_
);
ret
=
ParallelLaunch
(
THREAD_POOL_DEFAULT
,
LeakyR
eluInt8Run
,
this
,
op_parameter_
->
thread_num_
);
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"RunPreluParam failed. errorcode: "
;
}
return
RET_OK
;
}
int
PreluInt8Run
(
void
*
cdata
,
int
task_id
)
{
auto
prelu
=
reinterpret_cast
<
LeakyReluInt8CPUKernel
*>
(
cdata
);
prelu
->
DoExecute
(
task_id
);
return
RET_OK
;
}
int
LeakyReluInt8CPUKernel
::
DoExecute
(
int
task_id
)
{
auto
input_tensor
=
in_tensors_
.
at
(
kInputIndex
);
...
...
mindspore/lite/src/runtime/kernel/arm/int8/leaky_relu_int8.h
浏览文件 @
34f21226
...
...
@@ -41,7 +41,6 @@ class LeakyReluInt8CPUKernel : public LeakyReluBaseCPUKernel {
private:
LeakyReluQuantArg
quant_prelu_parm_
;
};
int
PreluInt8Run
(
void
*
cdata
,
int
task_id
);
}
// namespace mindspore::kernel
#endif // MINDSPORE_LITE_SRC_RUNTIME_KERNEL_ARM_INT8_PRELU_INT8_H_
mindspore/lite/src/runtime/kernel/opencl/kernel/prelu.cc
浏览文件 @
34f21226
...
...
@@ -29,7 +29,7 @@ using mindspore::kernel::KERNEL_ARCH::kGPU;
using
mindspore
::
lite
::
KernelRegistrar
;
using
mindspore
::
lite
::
RET_ERROR
;
using
mindspore
::
lite
::
RET_OK
;
using
mindspore
::
schema
::
PrimitiveType_P
relu
;
using
mindspore
::
schema
::
PrimitiveType_P
ReLU
;
namespace
mindspore
::
kernel
{
...
...
@@ -154,5 +154,5 @@ kernel::LiteKernel *OpenCLPReluKernelCreator(const std::vector<lite::tensor::Ten
return
kernel
;
}
REG_KERNEL
(
kGPU
,
kNumberTypeFloat32
,
PrimitiveType_P
relu
,
OpenCLPReluKernelCreator
)
REG_KERNEL
(
kGPU
,
kNumberTypeFloat32
,
PrimitiveType_P
ReLU
,
OpenCLPReluKernelCreator
)
}
// namespace mindspore::kernel
mindspore/lite/test/ut/src/runtime/kernel/arm/int8/prelu_int8_tests.cc
浏览文件 @
34f21226
...
...
@@ -65,14 +65,14 @@ TEST_F(TestPreluInt8, prelu_1) {
outputs_tensor
[
0
]
=
output0_tensor
;
LeakyReluQuantArg
op_param
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_
Prelu
;
op_param
.
op_parameter_
.
type_
=
schema
::
PrimitiveType_
LeakyReLU
;
op_param
.
slope_
=
reinterpret_cast
<
float
*>
(
malloc
(
sizeof
(
float
)));
op_param
.
slope_
[
0
]
=
0.25
;
lite
::
Context
*
ctx
=
new
lite
::
Context
;
ctx
->
thread_num_
=
2
;
op_param
.
axis_
=
0.25
;
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_
Prelu
};
kernel
::
KernelKey
desc
=
{
kernel
::
KERNEL_ARCH
::
kCPU
,
kNumberTypeInt8
,
schema
::
PrimitiveType_
LeakyReLU
};
auto
creator
=
lite
::
KernelRegistry
::
GetInstance
()
->
GetCreator
(
desc
);
ASSERT_NE
(
creator
,
nullptr
);
kernel
::
LiteKernel
*
kernel
=
...
...
mindspore/lite/test/ut/tools/converter/parser/tflite/tflite_activation_parser_test.cc
浏览文件 @
34f21226
...
...
@@ -119,15 +119,6 @@ TEST_F(TestTfliteParserPrelu, OpType) {
ASSERT_NE
(
meta_graph
,
nullptr
);
ASSERT_GT
(
meta_graph
->
nodes
.
size
(),
0
);
ASSERT_NE
(
meta_graph
->
nodes
.
front
()
->
primitive
.
get
(),
nullptr
);
ASSERT_EQ
(
meta_graph
->
nodes
.
front
()
->
primitive
->
value
.
type
,
schema
::
PrimitiveType_Prelu
)
<<
"wrong Op Type"
;
}
TEST_F
(
TestTfliteParserPrelu
,
AttrValue
)
{
ASSERT_NE
(
meta_graph
->
nodes
.
front
()
->
primitive
->
value
.
AsPrelu
(),
nullptr
);
auto
val
=
meta_graph
->
nodes
.
front
()
->
primitive
->
value
;
std
::
vector
<
float
>
slope
(
20
,
0
);
ASSERT_EQ
(
val
.
AsPrelu
()
->
slope
,
slope
);
ASSERT_EQ
(
val
.
type
,
schema
::
PrimitiveType_Prelu
);
}
class
TestTfliteParserLeakyRelu
:
public
TestTfliteParser
{
...
...
mindspore/lite/tools/common/node_util.cc
浏览文件 @
34f21226
...
...
@@ -29,7 +29,7 @@ static const std::vector<schema::PrimitiveType> nhwcOpList = {
schema
::
PrimitiveType_DepthwiseConv2D
,
schema
::
PrimitiveType_DeDepthwiseConv2D
,
schema
::
PrimitiveType_Pooling
,
schema
::
PrimitiveType_Resize
,
schema
::
PrimitiveType_BatchNorm
,
schema
::
PrimitiveType_FusedBatchNorm
,
schema
::
PrimitiveType_
Caffe
PReLU
};
schema
::
PrimitiveType_PReLU
};
static
const
std
::
vector
<
schema
::
PrimitiveType
>
fp32FullOpList
=
{
schema
::
PrimitiveType_Concat
,
schema
::
PrimitiveType_Add
,
...
...
mindspore/lite/tools/converter/parser/caffe/caffe_prelu_parser.cc
浏览文件 @
34f21226
...
...
@@ -34,7 +34,7 @@ STATUS CaffePReluParser::Parse(const caffe::LayerParameter &proto,
return
RET_NULL_PTR
;
}
std
::
unique_ptr
<
schema
::
CaffePReLUT
>
attr
=
std
::
make_unique
<
schema
::
Caffe
PReLUT
>
();
std
::
unique_ptr
<
schema
::
PReLUT
>
attr
=
std
::
make_unique
<
schema
::
PReLUT
>
();
if
(
attr
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"new op failed"
;
return
RET_NULL_PTR
;
...
...
@@ -60,7 +60,7 @@ STATUS CaffePReluParser::Parse(const caffe::LayerParameter &proto,
weightVec
->
push_back
(
slope
);
op
->
name
=
proto
.
name
();
op
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_
Caffe
PReLU
;
op
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_PReLU
;
op
->
primitive
->
value
.
value
=
attr
.
release
();
return
RET_OK
;
}
...
...
mindspore/lite/tools/converter/parser/onnx/onnx_relu_parser.cc
浏览文件 @
34f21226
...
...
@@ -73,7 +73,7 @@ STATUS OnnxPReluParser::Parse(const onnx::GraphProto &onnx_graph, const onnx::No
MS_LOG
(
ERROR
)
<<
"input num should be 2"
;
return
RET_ERROR
;
}
std
::
unique_ptr
<
schema
::
CaffePReLUT
>
attr
=
std
::
make_unique
<
schema
::
Caffe
PReLUT
>
();
std
::
unique_ptr
<
schema
::
PReLUT
>
attr
=
std
::
make_unique
<
schema
::
PReLUT
>
();
std
::
vector
<
onnx
::
TensorProto
>
params
;
const
auto
&
input_name
=
onnx_node
.
input
(
1
);
for
(
const
auto
&
it
:
onnx_graph
.
initializer
())
{
...
...
@@ -102,7 +102,7 @@ STATUS OnnxPReluParser::Parse(const onnx::GraphProto &onnx_graph, const onnx::No
}
}
op
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_
Caffe
PReLU
;
op
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_PReLU
;
op
->
primitive
->
value
.
value
=
attr
.
release
();
return
RET_OK
;
}
...
...
mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.cc
浏览文件 @
34f21226
...
...
@@ -84,52 +84,11 @@ STATUS TfliteActivationParser::Parse(const std::unique_ptr<tflite::OperatorT> &t
return
RET_OK
;
}
STATUS
TflitePreluParser
::
Parse
(
const
std
::
unique_ptr
<
tflite
::
OperatorT
>
&
tflite_op
,
const
std
::
vector
<
std
::
unique_ptr
<
tflite
::
TensorT
>>
&
tflite_tensors
,
const
std
::
vector
<
std
::
unique_ptr
<
tflite
::
BufferT
>>
&
tflite_model_buffer
,
schema
::
CNodeT
*
op
,
std
::
vector
<
int32_t
>
*
tensors_id
,
std
::
vector
<
schema
::
Format
>
*
tensors_format
,
std
::
map
<
int
,
int
>
*
tensors_id_map
)
{
MS_LOG
(
DEBUG
)
<<
"parse TflitePreluParser"
;
if
(
op
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"op is null"
;
return
RET_NULL_PTR
;
}
op
->
primitive
=
std
::
make_unique
<
schema
::
PrimitiveT
>
();
if
(
op
->
primitive
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"op->primitive is null"
;
return
RET_NULL_PTR
;
}
std
::
unique_ptr
<
schema
::
PreluT
>
attr
=
std
::
make_unique
<
schema
::
PreluT
>
();
if
(
attr
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"new op failed"
;
return
RET_NULL_PTR
;
}
if
(
GetTfliteData
(
tflite_op
->
inputs
[
1
],
tflite_tensors
,
tflite_model_buffer
,
attr
->
slope
))
{
MS_LOG
(
ERROR
)
<<
"get pRelu -> slope failed"
;
return
RET_ERROR
;
}
op
->
primitive
->
value
.
type
=
schema
::
PrimitiveType_Prelu
;
op
->
primitive
->
value
.
value
=
attr
.
release
();
AddOpInput
(
op
,
tensors_id
,
tensors_format
,
tensors_id_map
,
tflite_op
->
inputs
[
0
],
tensors_id
->
size
(),
tflite_tensors
.
size
(),
schema
::
Format_NHWC
);
AddOpOutput
(
op
,
tensors_id
,
tensors_format
,
tensors_id_map
,
tflite_op
->
outputs
[
0
],
tensors_id
->
size
(),
tflite_tensors
.
size
(),
schema
::
Format_NHWC
);
return
RET_OK
;
}
TfliteNodeRegister
g_TfliteReluParser
(
"Relu"
,
new
TfliteReluParser
());
TfliteNodeRegister
g_TfliteRelu6Parser
(
"Relu6"
,
new
TfliteRelu6Parser
());
TfliteNodeRegister
g_TfliteTanhParser
(
"Tanh"
,
new
TfliteTanhParser
());
TfliteNodeRegister
g_TfliteHardSwishParser
(
"HardSwish"
,
new
TfliteHardSwishParser
());
TfliteNodeRegister
g_tfliteLogisticParser
(
"Logistic"
,
new
TfliteLogisticParser
());
TfliteNodeRegister
g_tflitePreluParser
(
"Prelu"
,
new
TflitePreluParser
());
TfliteNodeRegister
g_TfliteLeakyReluParser
(
"LeakyRelu"
,
new
TfliteLeakyReluParser
());
}
// namespace lite
}
// namespace mindspore
mindspore/lite/tools/converter/parser/tflite/tflite_activation_parser.h
浏览文件 @
34f21226
...
...
@@ -68,18 +68,6 @@ class TfliteLeakyReluParser : public TfliteActivationParser {
TfliteLeakyReluParser
()
:
TfliteActivationParser
()
{}
};
class
TflitePreluParser
:
public
TfliteNodeParser
{
public:
TflitePreluParser
()
:
TfliteNodeParser
(
"Prelu"
)
{}
STATUS
Parse
(
const
std
::
unique_ptr
<
tflite
::
OperatorT
>
&
tflite_op
,
const
std
::
vector
<
std
::
unique_ptr
<
tflite
::
TensorT
>>
&
tflite_tensors
,
const
std
::
vector
<
std
::
unique_ptr
<
tflite
::
BufferT
>>
&
tflite_model_buffer
,
schema
::
CNodeT
*
op
,
std
::
vector
<
int32_t
>
*
tensors_id
,
std
::
vector
<
schema
::
Format
>
*
tensors_format
,
std
::
map
<
int
,
int
>
*
tensors_id_map
)
override
;
};
}
// namespace lite
}
// namespace mindspore
...
...
mindspore/lite/tools/converter/parser/tflite/tflite_util.cc
浏览文件 @
34f21226
...
...
@@ -107,7 +107,6 @@ std::map<tflite::BuiltinOperator, std::string> tfMsOpTypeMap{
{
tflite
::
BuiltinOperator_DEPTH_TO_SPACE
,
"DepthToSpace"
},
{
tflite
::
BuiltinOperator_SPACE_TO_BATCH_ND
,
"SpaceToBatchND"
},
{
tflite
::
BuiltinOperator_SPACE_TO_DEPTH
,
"SpaceToDepth"
},
{
tflite
::
BuiltinOperator_PRELU
,
"Prelu"
},
{
tflite
::
BuiltinOperator_ROUND
,
"Round"
},
{
tflite
::
BuiltinOperator_WHERE
,
"Where"
},
{
tflite
::
BuiltinOperator_SPARSE_TO_DENSE
,
"SparseToDense"
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录