Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
d8b87ec6
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看板
提交
d8b87ec6
编写于
5月 25, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
5月 25, 2020
浏览文件
操作
浏览文件
下载
差异文件
!1423 memset_s pass the actual destination buff size, Initialize the member variable axis_
Merge pull request !1423 from sunsuodong/warn
上级
aff14daf
2601ed30
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
20 addition
and
17 deletion
+20
-17
mindspore/ccsrc/kernel/cpu/concat_cpu_kernel.cc
mindspore/ccsrc/kernel/cpu/concat_cpu_kernel.cc
+8
-6
mindspore/ccsrc/kernel/cpu/concat_cpu_kernel.h
mindspore/ccsrc/kernel/cpu/concat_cpu_kernel.h
+2
-2
mindspore/ccsrc/kernel/cpu/gather_cpu_kernel.cc
mindspore/ccsrc/kernel/cpu/gather_cpu_kernel.cc
+8
-7
mindspore/ccsrc/kernel/cpu/gather_cpu_kernel.h
mindspore/ccsrc/kernel/cpu/gather_cpu_kernel.h
+2
-2
未找到文件。
mindspore/ccsrc/kernel/cpu/concat_cpu_kernel.cc
浏览文件 @
d8b87ec6
...
...
@@ -45,6 +45,7 @@ bool ConcatCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
const
std
::
vector
<
kernel
::
AddressPtr
>
&
/*workspace*/
,
const
std
::
vector
<
kernel
::
AddressPtr
>
&
outputs
)
{
auto
output_addr
=
reinterpret_cast
<
float
*>
(
outputs
[
0
]
->
addr
);
auto
buff_size
=
outputs
[
0
]
->
size
;
size_t
dim0
=
output_shape_
[
0
];
size_t
dim1
=
output_shape_
[
1
];
size_t
dim2
=
output_shape_
[
2
];
...
...
@@ -53,28 +54,28 @@ bool ConcatCPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
for
(
size_t
i
=
0
;
i
<
dim0
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
dim1
;
++
j
)
{
for
(
size_t
k
=
0
;
k
<
dim2
;
++
k
)
{
CopyDataToOutput
(
inputs
,
i
,
j
,
k
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
i
,
j
,
k
,
&
output_addr
,
&
buff_size
);
}
}
}
}
else
if
(
axis_
==
2
)
{
for
(
size_t
i
=
0
;
i
<
dim0
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
dim1
;
++
j
)
{
CopyDataToOutput
(
inputs
,
i
,
j
,
0
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
i
,
j
,
0
,
&
output_addr
,
&
buff_size
);
}
}
}
else
if
(
axis_
==
1
)
{
for
(
size_t
i
=
0
;
i
<
dim0
;
++
i
)
{
CopyDataToOutput
(
inputs
,
i
,
0
,
0
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
i
,
0
,
0
,
&
output_addr
,
&
buff_size
);
}
}
else
if
(
axis_
==
0
)
{
CopyDataToOutput
(
inputs
,
0
,
0
,
0
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
0
,
0
,
0
,
&
output_addr
,
&
buff_size
);
}
return
true
;
}
void
ConcatCPUKernel
::
CopyDataToOutput
(
const
std
::
vector
<
kernel
::
AddressPtr
>
&
inputs
,
size_t
dim0
,
size_t
dim1
,
size_t
dim2
,
float
**
output_addr
)
{
size_t
dim2
,
float
**
output_addr
,
size_t
*
buff_size
)
{
for
(
size_t
i
=
0
;
i
<
input_shape_list_
.
size
();
++
i
)
{
auto
input_i_shape
=
input_shape_list_
[
i
];
auto
input_i_addr
=
reinterpret_cast
<
float
*>
(
inputs
[
i
]
->
addr
);
...
...
@@ -82,11 +83,12 @@ void ConcatCPUKernel::CopyDataToOutput(const std::vector<kernel::AddressPtr> &in
size_t
num
=
CPUKernelUtils
::
GetElementNumOnAxis
(
input_i_shape
,
axis_
);
num
*=
input_i_shape
[
axis_
];
auto
pos
=
CPUKernelUtils
::
CalcOffset
(
input_i_shape
,
dim0
,
dim1
,
dim2
,
0
);
auto
ret
=
memcpy_s
(
*
output_addr
,
num
*
sizeof
(
float
)
,
input_i_addr
+
pos
,
num
*
sizeof
(
float
));
auto
ret
=
memcpy_s
(
*
output_addr
,
*
buff_size
,
input_i_addr
+
pos
,
num
*
sizeof
(
float
));
if
(
ret
!=
EOK
)
{
MS_LOG
(
EXCEPTION
)
<<
"memcpy failed."
;
}
*
output_addr
+=
num
;
*
buff_size
-=
num
*
sizeof
(
float
);
}
}
...
...
mindspore/ccsrc/kernel/cpu/concat_cpu_kernel.h
浏览文件 @
d8b87ec6
...
...
@@ -24,7 +24,7 @@ namespace mindspore {
namespace
kernel
{
class
ConcatCPUKernel
:
public
CPUKernel
{
public:
ConcatCPUKernel
()
=
default
;
ConcatCPUKernel
()
:
axis_
(
0
)
{}
~
ConcatCPUKernel
()
override
=
default
;
void
InitKernel
(
const
CNodePtr
&
kernel_node
)
override
;
...
...
@@ -35,7 +35,7 @@ class ConcatCPUKernel : public CPUKernel {
private:
void
CheckParam
(
const
CNodePtr
&
kernel_node
);
void
CopyDataToOutput
(
const
std
::
vector
<
kernel
::
AddressPtr
>
&
inputs
,
size_t
dim0
,
size_t
dim1
,
size_t
dim2
,
float
**
output_addr
);
float
**
output_addr
,
size_t
*
buff_size
);
int
axis_
;
std
::
vector
<
std
::
vector
<
size_t
>>
input_shape_list_
;
std
::
vector
<
size_t
>
output_shape_
;
...
...
mindspore/ccsrc/kernel/cpu/gather_cpu_kernel.cc
浏览文件 @
d8b87ec6
...
...
@@ -40,7 +40,7 @@ bool GatherV2CPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
const
std
::
vector
<
kernel
::
AddressPtr
>
&
/*workspace*/
,
const
std
::
vector
<
kernel
::
AddressPtr
>
&
outputs
)
{
auto
output_addr
=
reinterpret_cast
<
float
*>
(
outputs
[
0
]
->
addr
);
auto
buff_size
=
outputs
[
0
]
->
size
;
size_t
dim0
=
input_shape_
[
0
];
size_t
dim1
=
input_shape_
[
1
];
size_t
dim2
=
input_shape_
[
2
];
...
...
@@ -49,29 +49,29 @@ bool GatherV2CPUKernel::Launch(const std::vector<kernel::AddressPtr> &inputs,
for
(
size_t
i
=
0
;
i
<
dim0
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
dim1
;
++
j
)
{
for
(
size_t
k
=
0
;
k
<
dim2
;
++
k
)
{
CopyDataToOutput
(
inputs
,
i
,
j
,
k
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
i
,
j
,
k
,
&
output_addr
,
&
buff_size
);
}
}
}
}
else
if
(
axis_
==
2
)
{
for
(
size_t
i
=
0
;
i
<
dim0
;
++
i
)
{
for
(
size_t
j
=
0
;
j
<
dim1
;
++
j
)
{
CopyDataToOutput
(
inputs
,
i
,
j
,
0
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
i
,
j
,
0
,
&
output_addr
,
&
buff_size
);
}
}
}
else
if
(
axis_
==
1
)
{
for
(
size_t
i
=
0
;
i
<
dim0
;
++
i
)
{
CopyDataToOutput
(
inputs
,
i
,
0
,
0
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
i
,
0
,
0
,
&
output_addr
,
&
buff_size
);
}
}
else
if
(
axis_
==
0
)
{
CopyDataToOutput
(
inputs
,
0
,
0
,
0
,
&
output_addr
);
CopyDataToOutput
(
inputs
,
0
,
0
,
0
,
&
output_addr
,
&
buff_size
);
}
return
true
;
}
void
GatherV2CPUKernel
::
CopyDataToOutput
(
const
std
::
vector
<
kernel
::
AddressPtr
>
&
inputs
,
size_t
dim0
,
size_t
dim1
,
size_t
dim2
,
float
**
output_addr
)
{
size_t
dim2
,
float
**
output_addr
,
size_t
*
buff_size
)
{
auto
input_addr
=
reinterpret_cast
<
float
*>
(
inputs
[
0
]
->
addr
);
auto
indices_addr
=
reinterpret_cast
<
int
*>
(
inputs
[
1
]
->
addr
);
...
...
@@ -88,11 +88,12 @@ void GatherV2CPUKernel::CopyDataToOutput(const std::vector<kernel::AddressPtr> &
pos
=
CPUKernelUtils
::
CalcOffset
(
input_shape_
,
index
,
0
,
0
,
0
);
}
size_t
num
=
CPUKernelUtils
::
GetElementNumOnAxis
(
input_shape_
,
axis_
);
auto
ret
=
memcpy_s
(
*
output_addr
,
num
*
sizeof
(
float
)
,
input_addr
+
pos
,
num
*
sizeof
(
float
));
auto
ret
=
memcpy_s
(
*
output_addr
,
*
buff_size
,
input_addr
+
pos
,
num
*
sizeof
(
float
));
if
(
ret
!=
EOK
)
{
MS_LOG
(
EXCEPTION
)
<<
"memcpy failed."
;
}
*
output_addr
+=
num
;
*
buff_size
-=
num
*
sizeof
(
float
);
}
}
...
...
mindspore/ccsrc/kernel/cpu/gather_cpu_kernel.h
浏览文件 @
d8b87ec6
...
...
@@ -24,7 +24,7 @@ namespace mindspore {
namespace
kernel
{
class
GatherV2CPUKernel
:
public
CPUKernel
{
public:
GatherV2CPUKernel
()
=
default
;
GatherV2CPUKernel
()
:
axis_
(
0
)
{}
~
GatherV2CPUKernel
()
override
=
default
;
void
InitKernel
(
const
CNodePtr
&
kernel_node
)
override
;
...
...
@@ -34,7 +34,7 @@ class GatherV2CPUKernel : public CPUKernel {
private:
void
CopyDataToOutput
(
const
std
::
vector
<
kernel
::
AddressPtr
>
&
inputs
,
size_t
dim0
,
size_t
dim1
,
size_t
dim2
,
float
**
output_addr
);
float
**
output_addr
,
size_t
*
buff_size
);
void
CheckParam
(
const
CNodePtr
&
kernel_node
);
std
::
vector
<
size_t
>
input_shape_
;
std
::
vector
<
size_t
>
indices_shape_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录