Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
2823ec80
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看板
提交
2823ec80
编写于
5月 13, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
5月 13, 2020
浏览文件
操作
浏览文件
下载
差异文件
!1092 add rts kernel of labelset/labelgoto/labelswitch
Merge pull request !1092 from dengwentao/rts_kerenl
上级
18019ad6
06bac6f1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
350 addition
and
0 deletion
+350
-0
mindspore/ccsrc/kernel/mng/label_goto.cc
mindspore/ccsrc/kernel/mng/label_goto.cc
+63
-0
mindspore/ccsrc/kernel/mng/label_goto.h
mindspore/ccsrc/kernel/mng/label_goto.h
+47
-0
mindspore/ccsrc/kernel/mng/label_set.cc
mindspore/ccsrc/kernel/mng/label_set.cc
+63
-0
mindspore/ccsrc/kernel/mng/label_set.h
mindspore/ccsrc/kernel/mng/label_set.h
+47
-0
mindspore/ccsrc/kernel/mng/label_switch.cc
mindspore/ccsrc/kernel/mng/label_switch.cc
+76
-0
mindspore/ccsrc/kernel/mng/label_switch.h
mindspore/ccsrc/kernel/mng/label_switch.h
+49
-0
mindspore/ccsrc/utils/utils.h
mindspore/ccsrc/utils/utils.h
+5
-0
未找到文件。
mindspore/ccsrc/kernel/mng/label_goto.cc
0 → 100644
浏览文件 @
2823ec80
/**
* Copyright 2019 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 "kernel/mng/label_goto.h"
#include <asm-generic/param.h>
#include <memory>
#include "runtime/stream.h"
#include "framework/ge_runtime/task_info.h"
#include "session/anf_runtime_algorithm.h"
#include "common/utils.h"
using
ge
::
model_runner
::
LabelGotoTaskInfo
;
using
LabelGotoTaskInfoPtr
=
std
::
shared_ptr
<
LabelGotoTaskInfo
>
;
namespace
mindspore
{
namespace
kernel
{
LabelGotoKernel
::
LabelGotoKernel
()
{
label_
=
0
;
}
LabelGotoKernel
::~
LabelGotoKernel
()
{}
bool
LabelGotoKernel
::
Init
(
const
AnfNodePtr
&
anf_node
)
{
MS_EXCEPTION_IF_NULL
(
anf_node
);
MS_LOG
(
INFO
)
<<
"LabelGotoKernel init"
;
if
(
!
AnfAlgo
::
HasNodeAttr
(
kAttrLabelIndex
,
anf_node
))
{
MS_LOG
(
EXCEPTION
)
<<
"LabelGotoKernel has no attr label_index"
;
}
auto
primitive
=
AnfAlgo
::
GetCNodePrimitive
(
anf_node
);
MS_EXCEPTION_IF_NULL
(
primitive
);
label_
=
GetValue
<
uint32_t
>
(
primitive
->
GetAttr
(
kAttrLabelIndex
));
MS_LOG
(
INFO
)
<<
"LabelGotoKernel get attr label:"
<<
label_
;
return
true
;
}
bool
LabelGotoKernel
::
Launch
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uintptr_t
stream_ptr
)
{
MS_LOG
(
INFO
)
<<
"LabelGotoKernel launch"
;
return
true
;
}
std
::
vector
<
TaskInfoPtr
>
LabelGotoKernel
::
GenTask
(
const
std
::
vector
<
AddressPtr
>
&
,
const
std
::
vector
<
AddressPtr
>
&
,
const
std
::
vector
<
AddressPtr
>
&
,
uint32_t
stream_id
)
{
MS_LOG
(
INFO
)
<<
"LabelGotoKernel GenTask label:"
<<
label_
<<
", stream id:"
<<
stream_id
;
std
::
vector
<
TaskInfoPtr
>
task_info_list
;
std
::
shared_ptr
<
LabelGotoTaskInfo
>
task_info_ptr
=
std
::
make_shared
<
LabelGotoTaskInfo
>
(
stream_id
,
label_
);
MS_EXCEPTION_IF_NULL
(
task_info_ptr
);
task_info_list
.
emplace_back
(
task_info_ptr
);
return
task_info_list
;
}
}
// namespace kernel
}
// namespace mindspore
mindspore/ccsrc/kernel/mng/label_goto.h
0 → 100644
浏览文件 @
2823ec80
/**
* Copyright 2019 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 MINDSPORE_CCSRC_KERNEL_MNG_LABEL_GOTO_H
#define MINDSPORE_CCSRC_KERNEL_MNG_LABEL_GOTO_H
#include <memory>
#include <vector>
#include "kernel/mng/rt_kernel.h"
#include "kernel/mng/rt_kernel_info.h"
namespace
mindspore
{
namespace
kernel
{
class
LabelGotoKernel
:
public
RtKernel
{
public:
LabelGotoKernel
();
~
LabelGotoKernel
()
override
;
bool
Init
(
const
AnfNodePtr
&
anf_node
)
override
;
bool
Launch
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uintptr_t
stream_ptr
)
override
;
std
::
vector
<
TaskInfoPtr
>
GenTask
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uint32_t
stream_id
)
override
;
private:
uint32_t
label_
;
};
MS_REG_RTKERNEL
(
labelgoto
,
LabelGotoKernel
);
}
// namespace kernel
}
// namespace mindspore
#endif // MINDSPORE_CCSRC_KERNEL_MNG_LABEL_GOTO_H
mindspore/ccsrc/kernel/mng/label_set.cc
0 → 100644
浏览文件 @
2823ec80
/**
* Copyright 2019 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 "kernel/mng/label_set.h"
#include <asm-generic/param.h>
#include <memory>
#include "runtime/stream.h"
#include "framework/ge_runtime/task_info.h"
#include "session/anf_runtime_algorithm.h"
#include "common/utils.h"
using
ge
::
model_runner
::
LabelSetTaskInfo
;
using
LabelSetTaskInfoPtr
=
std
::
shared_ptr
<
LabelSetTaskInfo
>
;
namespace
mindspore
{
namespace
kernel
{
LabelSetKernel
::
LabelSetKernel
()
{
label_
=
0
;
}
LabelSetKernel
::~
LabelSetKernel
()
{}
bool
LabelSetKernel
::
Init
(
const
AnfNodePtr
&
anf_node
)
{
MS_EXCEPTION_IF_NULL
(
anf_node
);
MS_LOG
(
INFO
)
<<
"LabelSetKernel init"
;
if
(
!
AnfAlgo
::
HasNodeAttr
(
kAttrLabelIndex
,
anf_node
))
{
MS_LOG
(
EXCEPTION
)
<<
"LabelSetKernel has no attr label_index"
;
}
auto
primitive
=
AnfAlgo
::
GetCNodePrimitive
(
anf_node
);
MS_EXCEPTION_IF_NULL
(
primitive
);
label_
=
GetValue
<
uint32_t
>
(
primitive
->
GetAttr
(
kAttrLabelIndex
));
MS_LOG
(
INFO
)
<<
"LabelSetKernel get attr label:"
<<
label_
;
return
true
;
}
bool
LabelSetKernel
::
Launch
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uintptr_t
stream_ptr
)
{
MS_LOG
(
INFO
)
<<
"LabelSetKernel launch"
;
return
true
;
}
std
::
vector
<
TaskInfoPtr
>
LabelSetKernel
::
GenTask
(
const
std
::
vector
<
AddressPtr
>
&
,
const
std
::
vector
<
AddressPtr
>
&
,
const
std
::
vector
<
AddressPtr
>
&
,
uint32_t
stream_id
)
{
MS_LOG
(
INFO
)
<<
"LabelSetKernel GenTask label:"
<<
label_
<<
", stream id:"
<<
stream_id
;
std
::
vector
<
TaskInfoPtr
>
task_info_list
;
std
::
shared_ptr
<
LabelSetTaskInfo
>
task_info_ptr
=
std
::
make_shared
<
LabelSetTaskInfo
>
(
stream_id
,
label_
);
MS_EXCEPTION_IF_NULL
(
task_info_ptr
);
task_info_list
.
emplace_back
(
task_info_ptr
);
return
task_info_list
;
}
}
// namespace kernel
}
// namespace mindspore
mindspore/ccsrc/kernel/mng/label_set.h
0 → 100644
浏览文件 @
2823ec80
/**
* Copyright 2019 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 MINDSPORE_CCSRC_KERNEL_MNG_LABEL_SET_H
#define MINDSPORE_CCSRC_KERNEL_MNG_LABEL_SET_H
#include <memory>
#include <vector>
#include "kernel/mng/rt_kernel.h"
#include "kernel/mng/rt_kernel_info.h"
namespace
mindspore
{
namespace
kernel
{
class
LabelSetKernel
:
public
RtKernel
{
public:
LabelSetKernel
();
~
LabelSetKernel
()
override
;
bool
Init
(
const
AnfNodePtr
&
anf_node
)
override
;
bool
Launch
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uintptr_t
stream_ptr
)
override
;
std
::
vector
<
TaskInfoPtr
>
GenTask
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uint32_t
stream_id
)
override
;
private:
uint32_t
label_
;
};
MS_REG_RTKERNEL
(
labelset
,
LabelSetKernel
);
}
// namespace kernel
}
// namespace mindspore
#endif // MINDSPORE_CCSRC_KERNEL_MNG_LABEL_SET_H
mindspore/ccsrc/kernel/mng/label_switch.cc
0 → 100644
浏览文件 @
2823ec80
/**
* Copyright 2019 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 "kernel/mng/label_switch.h"
#include <asm-generic/param.h>
#include <memory>
#include "runtime/stream.h"
#include "framework/ge_runtime/task_info.h"
#include "session/anf_runtime_algorithm.h"
#include "common/utils.h"
using
ge
::
model_runner
::
LabelSwitchTaskInfo
;
using
LabelSwitchTaskInfoPtr
=
std
::
shared_ptr
<
LabelSwitchTaskInfo
>
;
namespace
mindspore
{
namespace
kernel
{
LabelSwitchKernel
::
LabelSwitchKernel
()
{
label_list_
=
{};
cond_
=
nullptr
;
label_size_
=
0
;
}
LabelSwitchKernel
::~
LabelSwitchKernel
()
{}
bool
LabelSwitchKernel
::
Init
(
const
AnfNodePtr
&
anf_node
)
{
MS_EXCEPTION_IF_NULL
(
anf_node
);
MS_LOG
(
INFO
)
<<
"LabelSwitchKernel init"
;
if
(
!
AnfAlgo
::
HasNodeAttr
(
kAttrLabelSwitchList
,
anf_node
))
{
MS_LOG
(
EXCEPTION
)
<<
"LabelSwitchKernel has no attr label_switch_list"
;
}
auto
primitive
=
AnfAlgo
::
GetCNodePrimitive
(
anf_node
);
MS_EXCEPTION_IF_NULL
(
primitive
);
label_list_
=
GetValue
<
std
::
vector
<
uint32_t
>>
(
primitive
->
GetAttr
(
kAttrLabelSwitchList
));
label_size_
=
label_list_
.
size
();
MS_LOG
(
INFO
)
<<
"LabelSwitchKernel get attr label size:"
<<
label_size_
;
for
(
auto
label
:
label_list_
)
{
MS_LOG
(
INFO
)
<<
"label: "
<<
label
;
}
return
true
;
}
bool
LabelSwitchKernel
::
Launch
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uintptr_t
stream_ptr
)
{
MS_LOG
(
INFO
)
<<
"LabelSwitchKernel launch"
;
return
true
;
}
std
::
vector
<
TaskInfoPtr
>
LabelSwitchKernel
::
GenTask
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uint32_t
stream_id
)
{
MS_LOG
(
INFO
)
<<
"LabelSwitchKernel GenTask label size:"
<<
label_size_
<<
", stream id:"
<<
stream_id
;
std
::
vector
<
TaskInfoPtr
>
task_info_list
;
cond_
=
inputs
[
0
]
->
addr
;
// std::shared_ptr<LabelSwitchTaskInfo> task_info_ptr =
// std::make_shared<LabelSwitchTaskInfo>(stream_id, label_size_, &label_list_, cond_);
// need updata ge task info define
std
::
shared_ptr
<
LabelSwitchTaskInfo
>
task_info_ptr
=
std
::
make_shared
<
LabelSwitchTaskInfo
>
(
stream_id
,
label_size_
);
MS_EXCEPTION_IF_NULL
(
task_info_ptr
);
task_info_list
.
emplace_back
(
task_info_ptr
);
return
task_info_list
;
}
}
// namespace kernel
}
// namespace mindspore
mindspore/ccsrc/kernel/mng/label_switch.h
0 → 100644
浏览文件 @
2823ec80
/**
* Copyright 2019 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 MINDSPORE_CCSRC_KERNEL_MNG_LABEL_SWITCH_H
#define MINDSPORE_CCSRC_KERNEL_MNG_LABEL_SWITCH_H
#include <memory>
#include <vector>
#include "kernel/mng/rt_kernel.h"
#include "kernel/mng/rt_kernel_info.h"
namespace
mindspore
{
namespace
kernel
{
class
LabelSwitchKernel
:
public
RtKernel
{
public:
LabelSwitchKernel
();
~
LabelSwitchKernel
()
override
;
bool
Init
(
const
AnfNodePtr
&
anf_node
)
override
;
bool
Launch
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uintptr_t
stream_ptr
)
override
;
std
::
vector
<
TaskInfoPtr
>
GenTask
(
const
std
::
vector
<
AddressPtr
>
&
inputs
,
const
std
::
vector
<
AddressPtr
>
&
workspace
,
const
std
::
vector
<
AddressPtr
>
&
outputs
,
uint32_t
stream_id
)
override
;
private:
std
::
vector
<
uint32_t
>
label_list_
;
uint32_t
label_size_
;
void
*
cond_
;
};
MS_REG_RTKERNEL
(
labelswitch
,
LabelSwitchKernel
);
}
// namespace kernel
}
// namespace mindspore
#endif // MINDSPORE_CCSRC_KERNEL_MNG_LABEL_SWITCH_H
mindspore/ccsrc/utils/utils.h
浏览文件 @
2823ec80
...
...
@@ -136,6 +136,9 @@ constexpr auto kPadOpName = "Pad";
constexpr
auto
kConv2DBackpropInputOpName
=
"Conv2DBackpropInput"
;
constexpr
auto
kFusionOpConv2DBackpropInputReluGradV2Name
=
"FusionOp_Conv2DBackpropInput_ReluGradV2"
;
constexpr
auto
kFusionOpConv2DBackpropInputAddNReluGradV2Name
=
"FusionOp_Conv2DBackpropInput_AddN_ReluGradV2"
;
constexpr
auto
kLabelSetOpName
=
"LabelSet"
;
constexpr
auto
kLabelSwitchOpName
=
"LabelSwitch"
;
constexpr
auto
kLabelGotoOpName
=
"LabelGoto"
;
// attr key name
constexpr
auto
kAttrInputNames
=
"input_names"
;
...
...
@@ -174,6 +177,8 @@ constexpr auto kAttrGroup = "group";
constexpr
auto
kAttrOp
=
"op"
;
constexpr
auto
kAttrIsTraining
=
"is_training"
;
constexpr
auto
kAttrFusionId
=
"fusion_id"
;
constexpr
auto
kAttrLabelIndex
=
"label_index"
;
constexpr
auto
kAttrLabelSwitchList
=
"label_switch_list"
;
// attr value
constexpr
auto
kValueTargetSwitch
=
"target_switch"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录