• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2019-2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "runtime/device/ascend/ge_runtime/task/label_set_task.h"
18 #include "runtime/device/ascend/ge_runtime/task/task_factory.h"
19 
20 namespace mindspore::ge::model_runner {
LabelSetTask(const ModelContext & model_context,const std::shared_ptr<LabelSetTaskInfo> & task_info)21 LabelSetTask::LabelSetTask(const ModelContext &model_context, const std::shared_ptr<LabelSetTaskInfo> &task_info)
22     : TaskRepeater<LabelSetTaskInfo>(model_context, task_info),
23       task_info_(task_info),
24       stream_(nullptr),
25       label_(nullptr) {
26   MS_EXCEPTION_IF_NULL(task_info_);
27   auto stream_list = model_context.stream_list();
28   auto label_list = model_context.label_list();
29   uint32_t stream_id = task_info->stream_id();
30   uint32_t label_id = task_info->label_id();
31   MS_LOG(INFO) << "Stream list size: " << stream_list.size() << ", stream id: " << stream_id;
32   MS_LOG(INFO) << "Label list size: " << label_list.size() << ", label id: " << label_id;
33   if (stream_id >= stream_list.size() || label_id >= label_list.size()) {
34     MS_LOG(EXCEPTION) << "Stream/Label id invalid.";
35   }
36   stream_ = stream_list[stream_id];
37   label_ = label_list[label_id];
38 }
39 
~LabelSetTask()40 LabelSetTask::~LabelSetTask() {}
41 
Distribute()42 void LabelSetTask::Distribute() {
43   MS_LOG(INFO) << "LabelSetTask Distribute start.";
44   MS_EXCEPTION_IF_NULL(stream_);
45   MS_EXCEPTION_IF_NULL(label_);
46 
47   rtError_t rt_ret = rtLabelSet(label_, stream_);
48   if (rt_ret != RT_ERROR_NONE) {
49     MS_LOG(EXCEPTION) << "Call rt api rtLabelSet failed, ret: " << rt_ret;
50   }
51 
52   MS_LOG(INFO) << "DistributeTask end.";
53 }
54 
55 REGISTER_TASK(TaskInfoType::LABEL_SET, LabelSetTask, LabelSetTaskInfo);
56 }  // namespace mindspore::ge::model_runner
57