Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
33784fef
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看板
提交
33784fef
编写于
8月 11, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 11, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4214 modify arm cpu op: embedding lookup and elu
Merge pull request !4214 from 陶云浩/modify
上级
2cab58fd
3eee337f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
64 addition
and
30 deletion
+64
-30
mindspore/lite/src/runtime/kernel/arm/fp32/elu.cc
mindspore/lite/src/runtime/kernel/arm/fp32/elu.cc
+13
-2
mindspore/lite/src/runtime/kernel/arm/fp32/embedding_lookup.cc
...pore/lite/src/runtime/kernel/arm/fp32/embedding_lookup.cc
+32
-14
mindspore/lite/src/runtime/kernel/arm/fp32/embedding_lookup.h
...spore/lite/src/runtime/kernel/arm/fp32/embedding_lookup.h
+8
-1
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/elu.cc
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/elu.cc
+0
-1
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/elu.h
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/elu.h
+2
-2
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/embedding_lookup.cc
...ite/src/runtime/kernel/arm/nnacl/fp32/embedding_lookup.cc
+0
-1
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/embedding_lookup.h
...lite/src/runtime/kernel/arm/nnacl/fp32/embedding_lookup.h
+9
-9
未找到文件。
mindspore/lite/src/runtime/kernel/arm/fp32/elu.cc
浏览文件 @
33784fef
...
...
@@ -28,12 +28,18 @@ namespace mindspore::kernel {
int
EluCPUKernel
::
Init
()
{
elu_parameter_
=
reinterpret_cast
<
EluParameter
*>
(
opParameter
);
elu_parameter_
->
thread_num_
=
thread_count_
;
if
(
!
InferShapeDone
())
{
return
RET_OK
;
}
return
ReSize
();
}
int
EluCPUKernel
::
ReSize
()
{
elu_parameter_
->
in_size_
=
inputs_
.
front
()
->
ElementsNum
();
return
RET_OK
;
}
int
EluCPUKernel
::
ReSize
()
{
return
RET_OK
;
}
int
EluCPUKernel
::
DoExcute
(
int
task_id
)
{
Elu
(
input_addr
,
output_addr
,
elu_parameter_
,
task_id
);
}
int
EluRun
(
int
task_id
,
LiteParallelGroupEnv
*
penv
,
void
*
cdata
)
{
...
...
@@ -47,6 +53,11 @@ int EluRun(int task_id, LiteParallelGroupEnv *penv, void *cdata) {
}
int
EluCPUKernel
::
Run
()
{
auto
prepare_ret
=
Prepare
();
if
(
prepare_ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Prepare fail!ret: "
<<
prepare_ret
;
return
prepare_ret
;
}
input_addr
=
reinterpret_cast
<
float
*>
(
inputs_
.
front
()
->
Data
());
output_addr
=
reinterpret_cast
<
float
*>
(
outputs_
.
front
()
->
Data
());
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/embedding_lookup.cc
浏览文件 @
33784fef
...
...
@@ -26,12 +26,16 @@ using mindspore::schema::PrimitiveType_EmbeddingLookup;
namespace
mindspore
::
kernel
{
int
EmbeddingLookupCPUKernel
::
Init
()
{
if
(
context_
->
infer_shape_interrupt_
&&
!
context_
->
running_
)
{
SetNeedReInit
();
return
RET_OK
;
}
embedding_lookup_parameter_
=
reinterpret_cast
<
EmbeddingLookupParameter
*>
(
opParameter
);
embedding_lookup_parameter_
->
thread_num
=
thread_count_
;
if
(
!
InferShapeDone
())
{
return
RET_OK
;
}
return
ReSize
();
}
int
EmbeddingLookupCPUKernel
::
ReSize
()
{
embedding_lookup_parameter_
->
ids_size_
=
inputs_
.
back
()
->
ElementsNum
();
embedding_lookup_parameter_
->
layer_size_
=
1
;
...
...
@@ -45,18 +49,34 @@ int EmbeddingLookupCPUKernel::Init() {
embedding_lookup_parameter_
->
layer_num_
+=
inputs_
[
i
]
->
shape
()[
0
];
}
input_addr_
=
reinterpret_cast
<
float
*>
(
std
::
malloc
(
sizeof
(
float
)
*
embedding_lookup_parameter_
->
layer_size_
*
embedding_lookup_parameter_
->
layer_num_
));
if
(
input_addr_
!=
nullptr
)
{
free
(
input_addr_
);
}
if
(
context_
!=
nullptr
&&
context_
->
allocator
!=
nullptr
)
{
input_addr_
=
reinterpret_cast
<
float
*>
(
context_
->
allocator
->
Malloc
(
sizeof
(
float
)
*
embedding_lookup_parameter_
->
layer_size_
*
embedding_lookup_parameter_
->
layer_num_
));
}
else
{
input_addr_
=
reinterpret_cast
<
float
*>
(
malloc
(
sizeof
(
float
)
*
embedding_lookup_parameter_
->
layer_size_
*
embedding_lookup_parameter_
->
layer_num_
));
}
if
(
input_addr_
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"
Create memory
failed"
;
return
mindspore
::
lite
::
RET_MEMORY_FAILED
;
MS_LOG
(
ERROR
)
<<
"
Malloc buffer
failed"
;
return
RET_ERROR
;
}
embedding_lookup_parameter_
->
is_regulated_
=
reinterpret_cast
<
bool
*>
(
std
::
malloc
(
sizeof
(
bool
)
*
embedding_lookup_parameter_
->
layer_num_
));
if
(
embedding_lookup_parameter_
->
is_regulated_
!=
nullptr
)
{
free
(
embedding_lookup_parameter_
->
is_regulated_
);
}
if
(
context_
!=
nullptr
&&
context_
->
allocator
!=
nullptr
)
{
embedding_lookup_parameter_
->
is_regulated_
=
reinterpret_cast
<
bool
*>
(
context_
->
allocator
->
Malloc
(
sizeof
(
bool
)
*
embedding_lookup_parameter_
->
layer_num_
));
}
else
{
embedding_lookup_parameter_
->
is_regulated_
=
reinterpret_cast
<
bool
*>
(
malloc
(
sizeof
(
bool
)
*
embedding_lookup_parameter_
->
layer_num_
));
}
if
(
embedding_lookup_parameter_
->
is_regulated_
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"
Create memory
failed"
;
return
mindspore
::
lite
::
RET_MEMORY_FAILED
;
MS_LOG
(
ERROR
)
<<
"
Malloc buffer
failed"
;
return
RET_ERROR
;
}
for
(
int
i
=
0
;
i
<
embedding_lookup_parameter_
->
layer_num_
;
++
i
)
{
...
...
@@ -66,8 +86,6 @@ int EmbeddingLookupCPUKernel::Init() {
return
RET_OK
;
}
int
EmbeddingLookupCPUKernel
::
ReSize
()
{
return
RET_OK
;
}
int
EmbeddingLookupCPUKernel
::
DoExcute
(
int
task_id
)
{
int
error_code
=
EmbeddingLookup
(
input_addr_
,
ids_addr_
,
output_addr_
,
embedding_lookup_parameter_
,
task_id
);
if
(
error_code
!=
RET_OK
)
{
...
...
mindspore/lite/src/runtime/kernel/arm/fp32/embedding_lookup.h
浏览文件 @
33784fef
...
...
@@ -28,7 +28,14 @@ class EmbeddingLookupCPUKernel : public LiteKernel {
const
std
::
vector
<
lite
::
tensor
::
Tensor
*>
&
outputs
,
const
lite
::
Context
*
ctx
,
const
lite
::
Primitive
*
primitive
)
:
LiteKernel
(
parameter
,
inputs
,
outputs
,
ctx
,
primitive
),
ctx_
(
ctx
),
thread_count_
(
ctx
->
thread_num_
)
{}
~
EmbeddingLookupCPUKernel
()
override
{};
~
EmbeddingLookupCPUKernel
()
override
{
if
(
input_addr_
!=
nullptr
)
{
free
(
input_addr_
);
}
if
(
embedding_lookup_parameter_
->
is_regulated_
!=
nullptr
)
{
free
(
embedding_lookup_parameter_
->
is_regulated_
);
}
};
int
Init
()
override
;
int
ReSize
()
override
;
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/elu.cc
浏览文件 @
33784fef
...
...
@@ -15,7 +15,6 @@
*/
#include "src/runtime/kernel/arm/nnacl/fp32/elu.h"
#include <string.h>
#include "include/errorcode.h"
#include "src/runtime/kernel/arm/nnacl/errorcode.h"
#include "mindspore/core/utils/log_adapter.h"
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/elu.h
浏览文件 @
33784fef
...
...
@@ -19,12 +19,12 @@
#include "src/runtime/kernel/arm/nnacl/op_base.h"
struct
EluParameter
{
typedef
struct
{
OpParameter
op_parameter_
;
float
alpha_
;
int
thread_num_
;
int
in_size_
;
};
}
EluParameter
;
int
Elu
(
float
*
input_data
,
float
*
output_data
,
EluParameter
*
parameter
,
int
task_id
);
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/embedding_lookup.cc
浏览文件 @
33784fef
...
...
@@ -15,7 +15,6 @@
*/
#include "src/runtime/kernel/arm/nnacl/fp32/embedding_lookup.h"
#include <string.h>
#include "include/errorcode.h"
#include "src/runtime/kernel/arm/nnacl/errorcode.h"
#include "mindspore/core/utils/log_adapter.h"
...
...
mindspore/lite/src/runtime/kernel/arm/nnacl/fp32/embedding_lookup.h
浏览文件 @
33784fef
...
...
@@ -19,15 +19,15 @@
#include "src/runtime/kernel/arm/nnacl/op_base.h"
struct
EmbeddingLookupParameter
{
OpParameter
op_parameter_
;
bool
*
is_regulated_
;
float
max_norm_
;
int
ids_size_
;
int
layer_size_
;
int
layer_num_
;
int
thread_num
;
};
typedef
struct
{
OpParameter
op_parameter_
;
bool
*
is_regulated_
;
float
max_norm_
;
int
ids_size_
;
int
layer_size_
;
int
layer_num_
;
int
thread_num
;
}
EmbeddingLookupParameter
;
int
EmbeddingLookup
(
float
*
input_data
,
int
*
ids
,
float
*
output_data
,
EmbeddingLookupParameter
*
parameter
,
int
task_id
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录