forked from huawei/mindspore2022
!20648 clean pclint warnings
Merge pull request !20648 from zyli2020/mindrt_debug
This commit is contained in:
commit
59322811fd
|
|
@ -329,10 +329,10 @@ std::vector<KernelWithIndex> AnfRuntimeAlgorithm::GetAllOutputWithIndex(const An
|
|||
auto value_tuple = value->cast<ValueTuplePtr>();
|
||||
auto value_tuple_size = CountValueNum(value_tuple);
|
||||
for (size_t i = 0; i < value_tuple_size; ++i) {
|
||||
ret.push_back({node, i});
|
||||
ret.emplace_back(node, i);
|
||||
}
|
||||
} else {
|
||||
ret.push_back({node, 0});
|
||||
ret.emplace_back(node, 0);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ void KernelActor::RunOpControlWithInputTensor(AID *const input_control, OpContex
|
|||
MS_EXCEPTION_IF_NULL(context);
|
||||
MS_EXCEPTION_IF_NULL(input_tensors);
|
||||
auto &sequential_num = context->sequential_num_;
|
||||
input_op_controls_[sequential_num].emplace_back(input_control);
|
||||
(void)input_op_controls_[sequential_num].emplace_back(input_control);
|
||||
|
||||
PushInputDeviceTensor(input_tensors);
|
||||
// When all the inputs are collected, then allocate memory and callback launch.
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void CreateParameterDeviceAddress(const DeviceContext *device_context, const Ker
|
|||
MS_EXCEPTION_IF_NULL(graph);
|
||||
std::vector<AnfNodePtr> graph_inputs = graph->inputs();
|
||||
const std::vector<bool> &graph_valid_input = graph->valid_inputs();
|
||||
graph_inputs.insert(graph_inputs.end(), graph->child_graph_result().begin(), graph->child_graph_result().end());
|
||||
(void)graph_inputs.insert(graph_inputs.end(), graph->child_graph_result().begin(), graph->child_graph_result().end());
|
||||
|
||||
// Anf nodes which need create device address.
|
||||
std::vector<AnfNodePtr> nodes_list;
|
||||
|
|
@ -408,7 +408,7 @@ GraphId GraphCompiler::CompileGraph(const session::OpRunInfo &op_run_info, const
|
|||
auto &outputs_with_index = run_op_graph_output_nodes_[graph->graph_id()];
|
||||
for (auto &node : output_nodes) {
|
||||
MS_EXCEPTION_IF_NULL(node);
|
||||
outputs_with_index.emplace_back(AnfAlgo::VisitKernelWithReturnType(node, 0, false));
|
||||
(void)outputs_with_index.emplace_back(AnfAlgo::VisitKernelWithReturnType(node, 0, false));
|
||||
}
|
||||
|
||||
UpdateRefCountForGraphOutput(outputs_with_index);
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ void EraseValueNodeTensor(const std::vector<int64_t> *tensors_mask, const std::v
|
|||
}
|
||||
for (size_t index = 0; index < tensors_mask->size(); ++index) {
|
||||
if (tensors_mask->at(index) != kValueNodeTensorMask) {
|
||||
input_tensors_without_value_node->emplace_back(input_tensors->at(index));
|
||||
(void)input_tensors_without_value_node->emplace_back(input_tensors->at(index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2173,7 +2173,7 @@ void GraphScheduler::LinkArrowByControlNode(const GraphCompilerInfo &graph_compi
|
|||
LinkDataArrowByControlNode(graph_compiler_info, input_with_index, from_func_graph, gather_actor, i);
|
||||
}
|
||||
}
|
||||
LinkBranchArrowForSwitchActor(graph_compiler_info, actor_set);
|
||||
LinkBranchArrowForSwitchActor(graph_compiler_info);
|
||||
|
||||
LinkBranchArrowForGatherActor(graph_compiler_info, actor_set);
|
||||
|
||||
|
|
@ -2482,7 +2482,7 @@ void GraphScheduler::LinkControlArrowForSwitchActor(std::vector<SwitchActorPtr>
|
|||
if (actor != nullptr) {
|
||||
const auto &gather_actor = dynamic_cast<GatherActor *>(actor);
|
||||
MS_EXCEPTION_IF_NULL(gather_actor);
|
||||
switch_actor->output_branch_control_arrows_[i].emplace_back(gather_actor->GetAID());
|
||||
(void)switch_actor->output_branch_control_arrows_[i].emplace_back(gather_actor->GetAID());
|
||||
gather_actor->input_controls_num_++;
|
||||
}
|
||||
}
|
||||
|
|
@ -2516,13 +2516,12 @@ void GraphScheduler::LinkControlArrowForSwitchActor(std::vector<SwitchActorPtr>
|
|||
switch_actor->branch_id_to_index_[kMainBranchID] = branch_index;
|
||||
}
|
||||
|
||||
switch_actor->output_branch_control_arrows_[branch_index].emplace_back(to_actor->GetAID());
|
||||
(void)switch_actor->output_branch_control_arrows_[branch_index].emplace_back(to_actor->GetAID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphScheduler::LinkBranchArrowForSwitchActor(const GraphCompilerInfo &graph_compiler_info,
|
||||
const ActorSet *actor_set) {
|
||||
void GraphScheduler::LinkBranchArrowForSwitchActor(const GraphCompilerInfo &graph_compiler_info) {
|
||||
for (const auto &control_node : graph_compiler_info.control_nodes_) {
|
||||
if (AnfAlgo::CheckPrimitiveType(control_node, prim::kPrimSwitch) ||
|
||||
AnfAlgo::CheckPrimitiveType(control_node, prim::kPrimSwitchLayer)) {
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ class GraphScheduler {
|
|||
const KernelMapPosition &origin_outputs_order);
|
||||
// In control flow, there are scenarios where there are multi-branch outputs, and the gather actor needs to
|
||||
// send the branch id to the loop count actor.
|
||||
void LinkBranchArrowForSwitchActor(const GraphCompilerInfo &graph_compiler_info, const ActorSet *actor_set);
|
||||
void LinkBranchArrowForSwitchActor(const GraphCompilerInfo &graph_compiler_info);
|
||||
void LinkBranchArrowForGatherActor(const GraphCompilerInfo &graph_compiler_info, const ActorSet *actor_set);
|
||||
void LinkOutputResultArrowForSwitchActor(const GraphCompilerInfo &graph_compiler_info, const ActorSet *actor_set);
|
||||
void PrepareDataForControlNode(HostQueueDataSourceActor *host_data_source_actor,
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@ namespace device {
|
|||
namespace cpu {
|
||||
using mindspore::kernel::KernelBuildInfo;
|
||||
|
||||
bool CPUDeviceContext::Initialize() {
|
||||
void CPUDeviceContext::Initialize() {
|
||||
if (initialized_) {
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
mem_manager_ = std::make_shared<CPUMemoryManager>();
|
||||
|
|
@ -55,7 +55,6 @@ bool CPUDeviceContext::Initialize() {
|
|||
#endif
|
||||
|
||||
initialized_ = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPUDeviceContext::AllocateMemory(DeviceAddress *const &address, size_t size) const {
|
||||
|
|
@ -130,14 +129,14 @@ void SetControlOpInfo(const CNodePtr &kernel_node) {
|
|||
std::vector<TypeId> inputs_type;
|
||||
size_t input_num = AnfAlgo::GetInputTensorNum(kernel_node);
|
||||
for (size_t input_index = 0; input_index < input_num; ++input_index) {
|
||||
inputs_format.emplace_back(kOpFormat_DEFAULT);
|
||||
(void)inputs_format.emplace_back(kOpFormat_DEFAULT);
|
||||
inputs_type.push_back(AnfAlgo::GetPrevNodeOutputInferDataType(kernel_node, input_index));
|
||||
}
|
||||
std::vector<std::string> outputs_format;
|
||||
std::vector<TypeId> outputs_type;
|
||||
size_t output_num = AnfAlgo::GetOutputTensorNum(kernel_node);
|
||||
for (size_t output_index = 0; output_index < output_num; ++output_index) {
|
||||
outputs_format.emplace_back(kOpFormat_DEFAULT);
|
||||
(void)outputs_format.emplace_back(kOpFormat_DEFAULT);
|
||||
outputs_type.push_back(AnfAlgo::GetOutputInferDataType(kernel_node, output_index));
|
||||
}
|
||||
|
||||
|
|
@ -240,7 +239,7 @@ bool CPUDeviceContext::LaunchKernelWithProfiling(const CNodePtr &kernel, const s
|
|||
auto kernel_mod = AnfAlgo::GetKernelMod(kernel);
|
||||
MS_EXCEPTION_IF_NULL(kernel_mod);
|
||||
|
||||
uint32_t pid = getpid();
|
||||
uint32_t pid = IntToUint(getpid());
|
||||
profiler_inst->OpDataProducerBegin(kernel->fullname_with_scope(), pid);
|
||||
bool ret = DoLaunchKernel(kernel_mod, inputs, workspace, outputs);
|
||||
profiler_inst->OpDataProducerEnd();
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class CPUDeviceContext : public DeviceContext {
|
|||
: DeviceContext(device_context_key), mem_manager_(nullptr), initialized_(false) {}
|
||||
~CPUDeviceContext() override = default;
|
||||
|
||||
bool Initialize() override;
|
||||
void Initialize() override;
|
||||
|
||||
bool AllocateMemory(DeviceAddress *const &address, size_t size) const override;
|
||||
void FreeMemory(DeviceAddress *const &address) const override;
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ class DeviceContext {
|
|||
explicit DeviceContext(const DeviceContextKey &device_context_key) : device_context_key_(device_context_key) {}
|
||||
virtual ~DeviceContext() = default;
|
||||
|
||||
// Initialize the device context and return success or not.
|
||||
virtual bool Initialize() = 0;
|
||||
// Initialize the device context.
|
||||
virtual void Initialize() = 0;
|
||||
|
||||
// Destroy device context and release device resource.
|
||||
virtual void Destroy() {}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ void DeviceContextManager::UpdateDeviceContextKey(const DeviceContextKey &old_ke
|
|||
}
|
||||
|
||||
handle.key() = new_key_str;
|
||||
device_contexts_.insert(std::move(handle));
|
||||
(void)device_contexts_.insert(std::move(handle));
|
||||
}
|
||||
} // namespace device
|
||||
} // namespace mindspore
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ using KernelGraph = mindspore::session::KernelGraph;
|
|||
|
||||
static thread_local bool cur_thread_device_inited{false};
|
||||
|
||||
bool GPUDeviceContext::Initialize() {
|
||||
void GPUDeviceContext::Initialize() {
|
||||
if (initialized_ == true) {
|
||||
if (!BindDeviceToCurrentThread()) {
|
||||
return false;
|
||||
MS_LOG(EXCEPTION) << "BindDeviceToCurrentThread failed.";
|
||||
}
|
||||
GPUMemoryAllocator::GetInstance().CheckMaxDeviceMemory();
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Set device id
|
||||
|
|
@ -74,10 +74,8 @@ bool GPUDeviceContext::Initialize() {
|
|||
}
|
||||
|
||||
// Set device id and initialize device resource.
|
||||
bool ret = InitDevice();
|
||||
if (!ret) {
|
||||
MS_LOG(ERROR) << "GPU InitDevice failed.";
|
||||
return ret;
|
||||
if (!InitDevice()) {
|
||||
MS_LOG(EXCEPTION) << "GPU InitDevice failed.";
|
||||
}
|
||||
|
||||
// Initialize memory pool.
|
||||
|
|
@ -101,7 +99,6 @@ bool GPUDeviceContext::Initialize() {
|
|||
json_parser.CopyMSCfgJsonToDir(rank_id);
|
||||
|
||||
initialized_ = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool GPUDeviceContext::InitDevice() {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class GPUDeviceContext : public DeviceContext {
|
|||
~GPUDeviceContext() override = default;
|
||||
|
||||
// Set device id and initialize device resource, such as stream, cudnn and cublas handle.
|
||||
bool Initialize() override;
|
||||
void Initialize() override;
|
||||
|
||||
// Release device memory, stream, cudnn and cublas handle, etc.
|
||||
void Destroy() override;
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ const ActorInfo &MindRTBackend::CompileGraphs(const FuncGraphPtr &func_graph) {
|
|||
}
|
||||
MS_EXCEPTION_IF_NULL(graph_compiler_info);
|
||||
const ActorInfo &actor_info = graph_compiler_info->name_;
|
||||
actor_to_graph_compiler_info_.emplace(graph_compiler_info->name_, std::move(graph_compiler_info));
|
||||
(void)actor_to_graph_compiler_info_.emplace(graph_compiler_info->name_, std::move(graph_compiler_info));
|
||||
return actor_info;
|
||||
}
|
||||
|
||||
|
|
@ -531,7 +531,7 @@ void PlantTensorTupleToVector(const py::tuple &tuple_inputs, std::vector<tensor:
|
|||
}
|
||||
auto tensor = py::cast<tensor::TensorPtr>(input_object);
|
||||
MS_EXCEPTION_IF_NULL(tensor);
|
||||
tensors->emplace_back(tensor);
|
||||
(void)tensors->emplace_back(tensor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -547,7 +547,7 @@ void ConvertValueTupleToTensor(const py::object &input_object, std::vector<tenso
|
|||
MS_EXCEPTION_IF_NULL(value_tuple);
|
||||
tensor::TensorPtr tensor_ptr = opt::CreateTupleTensor(value_tuple);
|
||||
MS_EXCEPTION_IF_NULL(tensor_ptr);
|
||||
tensors->emplace_back(tensor_ptr);
|
||||
(void)tensors->emplace_back(tensor_ptr);
|
||||
}
|
||||
|
||||
void ConvertMultiPyObjectToTensor(const py::object &input_object, std::vector<tensor::TensorPtr> *tensors) {
|
||||
|
|
@ -714,7 +714,7 @@ void MindRTBackend::RunGraphBySingleOp(const std::vector<KernelGraphPtr> &graphs
|
|||
auto iter = cnode_ref_counts_.find(graph->graph_id());
|
||||
if (iter == cnode_ref_counts_.end()) {
|
||||
graph_compiler_->CalculateRefCount(graph, &cnode_ref_count);
|
||||
cnode_ref_counts_.emplace(graph->graph_id(), cnode_ref_count);
|
||||
(void)cnode_ref_counts_.emplace(graph->graph_id(), cnode_ref_count);
|
||||
} else {
|
||||
cnode_ref_count = iter->second;
|
||||
}
|
||||
|
|
@ -944,7 +944,7 @@ std::unique_ptr<GraphCompilerInfo> MindRTBackend::ConstructGraphCompilerInfo(con
|
|||
std::vector<AnfNodePtr> call_nodes;
|
||||
size_t call_output_num = runtime::FetchOutputSizebyCallNode(root_output, &call_nodes);
|
||||
for (size_t i = 0; i < call_output_num; ++i) {
|
||||
outputs.push_back({root_output, i});
|
||||
(void)outputs.emplace_back(root_output, i);
|
||||
}
|
||||
}
|
||||
outputs_num = outputs.size();
|
||||
|
|
@ -952,7 +952,7 @@ std::unique_ptr<GraphCompilerInfo> MindRTBackend::ConstructGraphCompilerInfo(con
|
|||
if (outputs_order.count(output) == 0) {
|
||||
outputs_order[output] = {position++};
|
||||
} else {
|
||||
outputs_order[output].emplace_back(position++);
|
||||
(void)outputs_order[output].emplace_back(position++);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -983,7 +983,7 @@ std::unique_ptr<GraphCompilerInfo> MindRTBackend::ConstructGraphCompilerInfo(
|
|||
if (outputs_order.count(output) == 0) {
|
||||
outputs_order[output] = {position++};
|
||||
} else {
|
||||
outputs_order[output].emplace_back(position++);
|
||||
(void)outputs_order[output].emplace_back(position++);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1021,7 +1021,7 @@ void MindRTBackend::RunGraph(const ActorInfo &actor_info, OpRunInfo *op_run_info
|
|||
}
|
||||
for (size_t index = 0; index < tensors_mask->size(); ++index) {
|
||||
if (tensors_mask->at(index) != kValueNodeTensorMask) {
|
||||
tensors_without_value_node.emplace_back(input_tensors->at(index));
|
||||
(void)tensors_without_value_node.emplace_back(input_tensors->at(index));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue