fix codedex warnings
This commit is contained in:
parent
f0aad6fff1
commit
209dc5f584
|
@ -422,7 +422,6 @@ BaseRef CreateNodeOutputPlaceholder(const AnfNodePtr &anf, const KernelGraphPtr
|
||||||
void CheckInputTensorShape(const TensorPtr &tensor, const CNodePtr &kernel, size_t input_index) {
|
void CheckInputTensorShape(const TensorPtr &tensor, const CNodePtr &kernel, size_t input_index) {
|
||||||
const auto &tensor_shape = tensor->shape();
|
const auto &tensor_shape = tensor->shape();
|
||||||
const auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel, input_index);
|
const auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel, input_index);
|
||||||
|
|
||||||
if (tensor_shape.size() != input_shape.size()) {
|
if (tensor_shape.size() != input_shape.size()) {
|
||||||
MS_LOG(EXCEPTION) << "The input tensor's shape size: " << tensor_shape.size()
|
MS_LOG(EXCEPTION) << "The input tensor's shape size: " << tensor_shape.size()
|
||||||
<< " is not equal to expected size: " << input_shape.size() << " for input[" << input_index
|
<< " is not equal to expected size: " << input_shape.size() << " for input[" << input_index
|
||||||
|
@ -1212,7 +1211,7 @@ void SessionBasic::GetParameterIndex(const KernelGraph *graph, const std::vector
|
||||||
}
|
}
|
||||||
|
|
||||||
void SessionBasic::CreateOutputPlaceholder(
|
void SessionBasic::CreateOutputPlaceholder(
|
||||||
const KernelGraphPtr &kernel_graph, const std::vector<tensor::TensorPtr> &input_tensors, VectorRef *outputs,
|
const KernelGraphPtr &kernel_graph, const std::vector<tensor::TensorPtr> &input_tensors, VectorRef *const outputs,
|
||||||
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes) {
|
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes) {
|
||||||
MS_EXCEPTION_IF_NULL(kernel_graph);
|
MS_EXCEPTION_IF_NULL(kernel_graph);
|
||||||
MS_EXCEPTION_IF_NULL(outputs);
|
MS_EXCEPTION_IF_NULL(outputs);
|
||||||
|
@ -1273,7 +1272,7 @@ void SessionBasic::HandleOpInputs(const std::set<KernelWithIndex> &input_kernel,
|
||||||
void SessionBasic::HandleOpOutputs(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
void SessionBasic::HandleOpOutputs(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
||||||
const std::map<KernelWithIndex, size_t> &ref_count,
|
const std::map<KernelWithIndex, size_t> &ref_count,
|
||||||
std::map<KernelWithIndex, tensor::TensorPtr> *op_output_map,
|
std::map<KernelWithIndex, tensor::TensorPtr> *op_output_map,
|
||||||
GraphOutputInfo *graph_output_info) {
|
GraphOutputInfo *const graph_output_info) {
|
||||||
MS_EXCEPTION_IF_NULL(kernel);
|
MS_EXCEPTION_IF_NULL(kernel);
|
||||||
MS_EXCEPTION_IF_NULL(op_output_map);
|
MS_EXCEPTION_IF_NULL(op_output_map);
|
||||||
MS_EXCEPTION_IF_NULL(graph_output_info);
|
MS_EXCEPTION_IF_NULL(graph_output_info);
|
||||||
|
@ -1410,7 +1409,7 @@ tensor::TensorPtr SessionBasic::GetOpInputTensorByIndex(const CNodePtr &cnode,
|
||||||
const std::map<KernelWithIndex, tensor::TensorPtr> &op_output,
|
const std::map<KernelWithIndex, tensor::TensorPtr> &op_output,
|
||||||
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
||||||
const std::vector<tensor::TensorPtr> &graph_inputs,
|
const std::vector<tensor::TensorPtr> &graph_inputs,
|
||||||
InputTensorInfo *input_tensor_info, size_t input_index) {
|
InputTensorInfo *const input_tensor_info, size_t input_index) {
|
||||||
MS_EXCEPTION_IF_NULL(cnode);
|
MS_EXCEPTION_IF_NULL(cnode);
|
||||||
MS_EXCEPTION_IF_NULL(input_tensor_info);
|
MS_EXCEPTION_IF_NULL(input_tensor_info);
|
||||||
if (input_index >= cnode->inputs().size() - 1) {
|
if (input_index >= cnode->inputs().size() - 1) {
|
||||||
|
|
|
@ -181,7 +181,7 @@ class SessionBasic : public std::enable_shared_from_this<SessionBasic> {
|
||||||
void GetParameterIndex(const KernelGraph *graph, const std::vector<tensor::TensorPtr> &inputs,
|
void GetParameterIndex(const KernelGraph *graph, const std::vector<tensor::TensorPtr> &inputs,
|
||||||
std::map<AnfNodePtr, size_t> *parameter_index);
|
std::map<AnfNodePtr, size_t> *parameter_index);
|
||||||
void CreateOutputPlaceholder(const KernelGraphPtr &kernel_graph, const std::vector<tensor::TensorPtr> &input_tensors,
|
void CreateOutputPlaceholder(const KernelGraphPtr &kernel_graph, const std::vector<tensor::TensorPtr> &input_tensors,
|
||||||
VectorRef *outputs,
|
VectorRef *const outputs,
|
||||||
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes);
|
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes);
|
||||||
void GetRefCount(const KernelGraph *graph, std::map<KernelWithIndex, size_t> *ref_count);
|
void GetRefCount(const KernelGraph *graph, std::map<KernelWithIndex, size_t> *ref_count);
|
||||||
void HandleOpInputs(const std::set<KernelWithIndex> &input_kernel, std::map<KernelWithIndex, size_t> *ref_count,
|
void HandleOpInputs(const std::set<KernelWithIndex> &input_kernel, std::map<KernelWithIndex, size_t> *ref_count,
|
||||||
|
@ -189,7 +189,8 @@ class SessionBasic : public std::enable_shared_from_this<SessionBasic> {
|
||||||
|
|
||||||
void HandleOpOutputs(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
void HandleOpOutputs(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
||||||
const std::map<KernelWithIndex, size_t> &ref_count,
|
const std::map<KernelWithIndex, size_t> &ref_count,
|
||||||
std::map<KernelWithIndex, tensor::TensorPtr> *op_output_map, GraphOutputInfo *graph_output_info);
|
std::map<KernelWithIndex, tensor::TensorPtr> *op_output_map,
|
||||||
|
GraphOutputInfo *const graph_output_info);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Executor;
|
friend class Executor;
|
||||||
|
@ -264,7 +265,7 @@ class SessionBasic : public std::enable_shared_from_this<SessionBasic> {
|
||||||
const std::map<KernelWithIndex, tensor::TensorPtr> &op_output,
|
const std::map<KernelWithIndex, tensor::TensorPtr> &op_output,
|
||||||
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
||||||
const std::vector<tensor::TensorPtr> &graph_inputs,
|
const std::vector<tensor::TensorPtr> &graph_inputs,
|
||||||
InputTensorInfo *input_tensor_info, size_t input_index);
|
InputTensorInfo *const input_tensor_info, size_t input_index);
|
||||||
|
|
||||||
// create a new kernel graph and update the graph sum
|
// create a new kernel graph and update the graph sum
|
||||||
KernelGraphPtr NewKernelGraph();
|
KernelGraphPtr NewKernelGraph();
|
||||||
|
|
|
@ -121,7 +121,7 @@ void KernelActor::RunOpControl(AID *input_control, OpContext<DeviceTensor> *cont
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelActor::RunOpControlWithInputTensor(AID *input_control, OpContext<DeviceTensor> *context,
|
void KernelActor::RunOpControlWithInputTensor(AID *const input_control, OpContext<DeviceTensor> *const context,
|
||||||
const std::vector<TensorPtr> *input_tensors) {
|
const std::vector<TensorPtr> *input_tensors) {
|
||||||
MS_EXCEPTION_IF_NULL(context);
|
MS_EXCEPTION_IF_NULL(context);
|
||||||
MS_EXCEPTION_IF_NULL(input_tensors);
|
MS_EXCEPTION_IF_NULL(input_tensors);
|
||||||
|
@ -140,11 +140,10 @@ void KernelActor::RunOpControlWithInputTensor(AID *input_control, OpContext<Devi
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void AllocateMemory(std::vector<DeviceTensor *> *alloc_list, const DeviceContext *device_context) {
|
void AllocateMemory(const std::vector<DeviceTensor *> &alloc_list, const DeviceContext *device_context) {
|
||||||
MS_EXCEPTION_IF_NULL(alloc_list);
|
|
||||||
MS_EXCEPTION_IF_NULL(device_context);
|
MS_EXCEPTION_IF_NULL(device_context);
|
||||||
|
|
||||||
for (auto &device_tensor : *alloc_list) {
|
for (auto &device_tensor : alloc_list) {
|
||||||
MS_EXCEPTION_IF_NULL(device_tensor);
|
MS_EXCEPTION_IF_NULL(device_tensor);
|
||||||
if ((device_tensor->GetPtr() != nullptr) || (device_tensor->GetSize() == 0)) {
|
if ((device_tensor->GetPtr() != nullptr) || (device_tensor->GetSize() == 0)) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -159,10 +158,9 @@ void AllocateMemory(std::vector<DeviceTensor *> *alloc_list, const DeviceContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FreeMemory(std::vector<DeviceTensor *> *free_list, const DeviceContext *device_context) {
|
void FreeMemory(const std::vector<DeviceTensor *> &free_list, const DeviceContext *device_context) {
|
||||||
MS_EXCEPTION_IF_NULL(free_list);
|
|
||||||
MS_EXCEPTION_IF_NULL(device_context);
|
MS_EXCEPTION_IF_NULL(device_context);
|
||||||
for (auto &device_tensor : *free_list) {
|
for (auto &device_tensor : free_list) {
|
||||||
MS_EXCEPTION_IF_NULL(device_tensor);
|
MS_EXCEPTION_IF_NULL(device_tensor);
|
||||||
if (device_tensor->original_ref_count() == SIZE_MAX) {
|
if (device_tensor->original_ref_count() == SIZE_MAX) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -186,7 +184,7 @@ void KernelActor::SendMemoryAllocReq(OpContext<DeviceTensor> *context) {
|
||||||
Async(memory_manager_aid_, &MemoryManagerActor::AllocateMemory, &memory_alloc_list_, device_context_, context,
|
Async(memory_manager_aid_, &MemoryManagerActor::AllocateMemory, &memory_alloc_list_, device_context_, context,
|
||||||
GetAID());
|
GetAID());
|
||||||
} else {
|
} else {
|
||||||
AllocateMemory(&memory_alloc_list_, device_context_);
|
AllocateMemory(memory_alloc_list_, device_context_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,7 +192,7 @@ void KernelActor::SendMemoryFreeReq(OpContext<DeviceTensor> *context) {
|
||||||
if (strategy_ == GraphExecutionStrategy::kPipeline) {
|
if (strategy_ == GraphExecutionStrategy::kPipeline) {
|
||||||
Async(memory_manager_aid_, &MemoryManagerActor::FreeMemory, &memory_free_list_, device_context_, context);
|
Async(memory_manager_aid_, &MemoryManagerActor::FreeMemory, &memory_free_list_, device_context_, context);
|
||||||
} else {
|
} else {
|
||||||
FreeMemory(&memory_free_list_, device_context_);
|
FreeMemory(memory_free_list_, device_context_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ class KernelActor : public DebugAwareActor {
|
||||||
// The kernel actor run when receive the input control.
|
// The kernel actor run when receive the input control.
|
||||||
void RunOpControl(AID *input_control, OpContext<DeviceTensor> *context) override;
|
void RunOpControl(AID *input_control, OpContext<DeviceTensor> *context) override;
|
||||||
// The kernel actor run when receive the input control and input tensors, used in step mode.
|
// The kernel actor run when receive the input control and input tensors, used in step mode.
|
||||||
void RunOpControlWithInputTensor(AID *input_control, OpContext<DeviceTensor> *context,
|
void RunOpControlWithInputTensor(AID *const input_control, OpContext<DeviceTensor> *const context,
|
||||||
const std::vector<TensorPtr> *input_tensors);
|
const std::vector<TensorPtr> *input_tensors);
|
||||||
|
|
||||||
// The memory related operation interface.
|
// The memory related operation interface.
|
||||||
|
|
|
@ -373,8 +373,9 @@ GraphId GraphCompiler::CompileGraphImpl(const KernelGraphPtr &graph, const Devic
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphId GraphCompiler::CompileGraph(const session::OpRunInfo &op_run_info, const GraphInfo &graph_info,
|
GraphId GraphCompiler::CompileGraph(const session::OpRunInfo &op_run_info, const GraphInfo &graph_info,
|
||||||
const std::vector<int64_t> *tensors_mask, std::vector<TensorPtr> *input_tensors,
|
const std::vector<int64_t> *tensors_mask,
|
||||||
bool *single_op_cache_hit, const DeviceContext *device_context) {
|
std::vector<TensorPtr> *const input_tensors, bool *single_op_cache_hit,
|
||||||
|
const DeviceContext *device_context) {
|
||||||
// Check if the graph cache exists.
|
// Check if the graph cache exists.
|
||||||
auto iter = run_op_graphs_.find(graph_info);
|
auto iter = run_op_graphs_.find(graph_info);
|
||||||
if (iter != run_op_graphs_.end()) {
|
if (iter != run_op_graphs_.end()) {
|
||||||
|
@ -438,7 +439,7 @@ void GraphCompiler::CreateDeviceAddress(const KernelGraphPtr &graph, const Devic
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphCompiler::GetParamAndOutputIndex(
|
void GraphCompiler::GetParamAndOutputIndex(
|
||||||
const KernelGraphPtr &graph, const std::vector<TensorPtr> &inputs, VectorRef *outputs,
|
const KernelGraphPtr &graph, const std::vector<TensorPtr> &inputs, VectorRef *const outputs,
|
||||||
std::map<AnfNodePtr, size_t> *parameter_index,
|
std::map<AnfNodePtr, size_t> *parameter_index,
|
||||||
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes) {
|
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes) {
|
||||||
MS_EXCEPTION_IF_NULL(session_);
|
MS_EXCEPTION_IF_NULL(session_);
|
||||||
|
@ -450,7 +451,7 @@ void GraphCompiler::GetSingleOpInputTensors(const CNodePtr &kernel,
|
||||||
const std::map<KernelWithIndex, TensorPtr> &op_output,
|
const std::map<KernelWithIndex, TensorPtr> &op_output,
|
||||||
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
||||||
const std::vector<TensorPtr> &graph_inputs,
|
const std::vector<TensorPtr> &graph_inputs,
|
||||||
InputTensorInfo *input_tensor_info) {
|
InputTensorInfo *const input_tensor_info) {
|
||||||
MS_EXCEPTION_IF_NULL(session_);
|
MS_EXCEPTION_IF_NULL(session_);
|
||||||
session_->GetOpInputTensors(kernel, op_output, parameter_index, graph_inputs, input_tensor_info);
|
session_->GetOpInputTensors(kernel, op_output, parameter_index, graph_inputs, input_tensor_info);
|
||||||
}
|
}
|
||||||
|
@ -459,14 +460,14 @@ TensorPtr GraphCompiler::GetSingleOpInputTensorByIndex(const CNodePtr &kernel,
|
||||||
const std::map<KernelWithIndex, TensorPtr> &op_output,
|
const std::map<KernelWithIndex, TensorPtr> &op_output,
|
||||||
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
||||||
const std::vector<TensorPtr> &graph_inputs,
|
const std::vector<TensorPtr> &graph_inputs,
|
||||||
InputTensorInfo *input_tensor_info, size_t input_index) {
|
InputTensorInfo *const input_tensor_info, size_t input_index) {
|
||||||
MS_EXCEPTION_IF_NULL(session_);
|
MS_EXCEPTION_IF_NULL(session_);
|
||||||
return session_->GetOpInputTensorByIndex(kernel, op_output, parameter_index, graph_inputs, input_tensor_info,
|
return session_->GetOpInputTensorByIndex(kernel, op_output, parameter_index, graph_inputs, input_tensor_info,
|
||||||
input_index);
|
input_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphCompiler::GetSingleOpRunInfoAndGraphInfo(const CNodePtr &kernel, const std::vector<TensorPtr> &input_tensors,
|
void GraphCompiler::GetSingleOpRunInfoAndGraphInfo(const CNodePtr &kernel, const std::vector<TensorPtr> &input_tensors,
|
||||||
OpRunInfo *run_info, GraphInfo *graph_info) {
|
OpRunInfo *const run_info, GraphInfo *const graph_info) {
|
||||||
MS_EXCEPTION_IF_NULL(session_);
|
MS_EXCEPTION_IF_NULL(session_);
|
||||||
session_->GetSingleOpRunInfo(kernel, run_info);
|
session_->GetSingleOpRunInfo(kernel, run_info);
|
||||||
*graph_info = session_->GetSingleOpGraphInfo(kernel, input_tensors);
|
*graph_info = session_->GetSingleOpGraphInfo(kernel, input_tensors);
|
||||||
|
@ -487,7 +488,7 @@ void GraphCompiler::UpdateRefCount(const std::set<KernelWithIndex> &input_kernel
|
||||||
void GraphCompiler::RecoverGraphOutput(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
void GraphCompiler::RecoverGraphOutput(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
||||||
const std::map<KernelWithIndex, size_t> &ref_count,
|
const std::map<KernelWithIndex, size_t> &ref_count,
|
||||||
std::map<KernelWithIndex, TensorPtr> *op_output_map,
|
std::map<KernelWithIndex, TensorPtr> *op_output_map,
|
||||||
GraphOutputInfo *graph_output_info) const {
|
GraphOutputInfo *const graph_output_info) const {
|
||||||
MS_EXCEPTION_IF_NULL(session_);
|
MS_EXCEPTION_IF_NULL(session_);
|
||||||
session_->HandleOpOutputs(kernel, op_outputs, ref_count, op_output_map, graph_output_info);
|
session_->HandleOpOutputs(kernel, op_outputs, ref_count, op_output_map, graph_output_info);
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ class GraphCompiler {
|
||||||
|
|
||||||
// Construct single op kernel graph and compile the kernel graph in PyNative mode.
|
// Construct single op kernel graph and compile the kernel graph in PyNative mode.
|
||||||
GraphId CompileGraph(const session::OpRunInfo &op_run_info, const GraphInfo &graph_info,
|
GraphId CompileGraph(const session::OpRunInfo &op_run_info, const GraphInfo &graph_info,
|
||||||
const std::vector<int64_t> *tensors_mask, std::vector<TensorPtr> *input_tensors,
|
const std::vector<int64_t> *tensors_mask, std::vector<TensorPtr> *const input_tensors,
|
||||||
bool *single_op_cache_hit, const DeviceContext *device_context);
|
bool *single_op_cache_hit, const DeviceContext *device_context);
|
||||||
|
|
||||||
// Get graph by graph id, if not exist return nullptr, used in Graph mode.
|
// Get graph by graph id, if not exist return nullptr, used in Graph mode.
|
||||||
|
@ -64,24 +64,24 @@ class GraphCompiler {
|
||||||
|
|
||||||
// Cache index for all parameter and output nodes of kernel graph, used to get parameter of single op and
|
// Cache index for all parameter and output nodes of kernel graph, used to get parameter of single op and
|
||||||
// recover output of original complete back propagation kernel graph.
|
// recover output of original complete back propagation kernel graph.
|
||||||
void GetParamAndOutputIndex(const KernelGraphPtr &graph, const std::vector<TensorPtr> &inputs, VectorRef *outputs,
|
void GetParamAndOutputIndex(const KernelGraphPtr &graph, const std::vector<TensorPtr> &inputs,
|
||||||
std::map<AnfNodePtr, size_t> *parameter_index,
|
VectorRef *const outputs, std::map<AnfNodePtr, size_t> *parameter_index,
|
||||||
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes);
|
std::map<KernelWithIndex, std::vector<std::vector<size_t>>> *output_indexes);
|
||||||
|
|
||||||
// Get input tensors for single op compile and run, input tensors may convert from value node and parameter in graph
|
// Get input tensors for single op compile and run, input tensors may convert from value node and parameter in graph
|
||||||
// and prev kernel node's output.
|
// and prev kernel node's output.
|
||||||
void GetSingleOpInputTensors(const CNodePtr &kernel, const std::map<KernelWithIndex, TensorPtr> &op_output,
|
void GetSingleOpInputTensors(const CNodePtr &kernel, const std::map<KernelWithIndex, TensorPtr> &op_output,
|
||||||
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
||||||
const std::vector<TensorPtr> &graph_inputs, InputTensorInfo *input_tensor_info);
|
const std::vector<TensorPtr> &graph_inputs, InputTensorInfo *const input_tensor_info);
|
||||||
// Get one input tensor for single control op, such as bprop_cut.
|
// Get one input tensor for single control op, such as bprop_cut.
|
||||||
TensorPtr GetSingleOpInputTensorByIndex(const CNodePtr &kernel, const std::map<KernelWithIndex, TensorPtr> &op_output,
|
TensorPtr GetSingleOpInputTensorByIndex(const CNodePtr &kernel, const std::map<KernelWithIndex, TensorPtr> &op_output,
|
||||||
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
const std::map<AnfNodePtr, size_t> ¶meter_index,
|
||||||
const std::vector<TensorPtr> &graph_inputs,
|
const std::vector<TensorPtr> &graph_inputs,
|
||||||
InputTensorInfo *input_tensor_info, size_t input_index);
|
InputTensorInfo *const input_tensor_info, size_t input_index);
|
||||||
|
|
||||||
// Get OpRunInfo and GraphInfo for single op compile and run.
|
// Get OpRunInfo and GraphInfo for single op compile and run.
|
||||||
void GetSingleOpRunInfoAndGraphInfo(const CNodePtr &kernel, const std::vector<TensorPtr> &input_tensors,
|
void GetSingleOpRunInfoAndGraphInfo(const CNodePtr &kernel, const std::vector<TensorPtr> &input_tensors,
|
||||||
OpRunInfo *run_info, GraphInfo *graph_info);
|
OpRunInfo *const run_info, GraphInfo *const graph_info);
|
||||||
|
|
||||||
// Calculate ref count of PyNative back propagation operators.
|
// Calculate ref count of PyNative back propagation operators.
|
||||||
void CalculateRefCount(const KernelGraphPtr &graph, std::map<KernelWithIndex, size_t> *ref_count) const;
|
void CalculateRefCount(const KernelGraphPtr &graph, std::map<KernelWithIndex, size_t> *ref_count) const;
|
||||||
|
@ -95,7 +95,7 @@ class GraphCompiler {
|
||||||
void RecoverGraphOutput(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
void RecoverGraphOutput(const AnfNodePtr &kernel, const VectorRef &op_outputs,
|
||||||
const std::map<KernelWithIndex, size_t> &ref_count,
|
const std::map<KernelWithIndex, size_t> &ref_count,
|
||||||
std::map<KernelWithIndex, TensorPtr> *op_output_map,
|
std::map<KernelWithIndex, TensorPtr> *op_output_map,
|
||||||
GraphOutputInfo *graph_output_info) const;
|
GraphOutputInfo *const graph_output_info) const;
|
||||||
|
|
||||||
// Collect output tensors of back propagation graph for allreduce operators to average gradient,
|
// Collect output tensors of back propagation graph for allreduce operators to average gradient,
|
||||||
// used in PyNative distributed training mode.
|
// used in PyNative distributed training mode.
|
||||||
|
|
|
@ -281,7 +281,7 @@ void PrepareDataForControlWeightNode(
|
||||||
}
|
}
|
||||||
|
|
||||||
void EraseValueNodeTensor(const std::vector<int64_t> *tensors_mask, const std::vector<TensorPtr> *input_tensors,
|
void EraseValueNodeTensor(const std::vector<int64_t> *tensors_mask, const std::vector<TensorPtr> *input_tensors,
|
||||||
std::vector<TensorPtr> *input_tensors_without_value_node) {
|
std::vector<TensorPtr> *const input_tensors_without_value_node) {
|
||||||
MS_EXCEPTION_IF_NULL(input_tensors);
|
MS_EXCEPTION_IF_NULL(input_tensors);
|
||||||
if (input_tensors->size() != tensors_mask->size()) {
|
if (input_tensors->size() != tensors_mask->size()) {
|
||||||
MS_LOG(EXCEPTION) << "Input tensors size " << input_tensors->size() << " should be equal to tensors mask size "
|
MS_LOG(EXCEPTION) << "Input tensors size " << input_tensors->size() << " should be equal to tensors mask size "
|
||||||
|
@ -324,12 +324,12 @@ void PrepareDataForHostDataSourceActor(const std::unordered_map<AnfNodePtr, size
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrepareDataForInputData(HostQueueDataSourceActor *host_data_source_actor, const AnfNodePtr &node,
|
void PrepareDataForInputData(const HostQueueDataSourceActor *host_data_source_actor, const AnfNodePtr &node,
|
||||||
const TensorPtr &tensor, std::vector<TensorPtr> *host_tensors,
|
const TensorPtr &tensor, const DeviceContext *device_context,
|
||||||
const DeviceContext *device_context) {
|
std::vector<TensorPtr> *const host_tensors) {
|
||||||
MS_EXCEPTION_IF_NULL(tensor);
|
MS_EXCEPTION_IF_NULL(tensor);
|
||||||
// Fill the host tensors for non weighted parameters.
|
// Fill the host tensors for non weighted parameters.
|
||||||
if (host_data_source_actor) {
|
if (host_data_source_actor != nullptr) {
|
||||||
(*host_tensors)[host_data_source_actor->FetchDataNodePosition(node)] = tensor;
|
(*host_tensors)[host_data_source_actor->FetchDataNodePosition(node)] = tensor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -698,7 +698,7 @@ void GraphScheduler::PrepareRunOp(const ActorSet *actor_set, const GraphCompiler
|
||||||
// Prepare the device data for weights.
|
// Prepare the device data for weights.
|
||||||
PrepareDataForWeightNode(input_node, input_node, input_tensor, device_context);
|
PrepareDataForWeightNode(input_node, input_node, input_tensor, device_context);
|
||||||
} else {
|
} else {
|
||||||
PrepareDataForInputData(host_data_source_actor, input_node, input_tensor, &host_tensors, device_context);
|
PrepareDataForInputData(host_data_source_actor, input_node, input_tensor, device_context, &host_tensors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ void CPUDeviceContext::FreeMemory(DeviceAddress *const &address) const {
|
||||||
address->ptr_ = nullptr;
|
address->ptr_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceAddressPtr CPUDeviceContext::CreateDeviceAddress(void *device_ptr, size_t device_size, const string &format,
|
DeviceAddressPtr CPUDeviceContext::CreateDeviceAddress(void *const device_ptr, size_t device_size, const string &format,
|
||||||
TypeId type_id) const {
|
TypeId type_id) const {
|
||||||
return std::make_shared<CPUDeviceAddress>(device_ptr, device_size, format, type_id);
|
return std::make_shared<CPUDeviceAddress>(device_ptr, device_size, format, type_id);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ bool CPUDeviceContext::LaunchKernelWithProfiling(const CNodePtr &kernel, const s
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUDeviceContext::DoLaunchKernel(KernelMod *kernel_mod, const std::vector<AddressPtr> &inputs,
|
bool CPUDeviceContext::DoLaunchKernel(KernelMod *const kernel_mod, const std::vector<AddressPtr> &inputs,
|
||||||
const std::vector<AddressPtr> &workspace,
|
const std::vector<AddressPtr> &workspace,
|
||||||
const std::vector<AddressPtr> &outputs) const {
|
const std::vector<AddressPtr> &outputs) const {
|
||||||
MS_EXCEPTION_IF_NULL(kernel_mod);
|
MS_EXCEPTION_IF_NULL(kernel_mod);
|
||||||
|
|
|
@ -38,7 +38,7 @@ class CPUDeviceContext : public DeviceContext {
|
||||||
bool AllocateMemory(DeviceAddress *const &address, size_t size) const override;
|
bool AllocateMemory(DeviceAddress *const &address, size_t size) const override;
|
||||||
void FreeMemory(DeviceAddress *const &address) const override;
|
void FreeMemory(DeviceAddress *const &address) const override;
|
||||||
|
|
||||||
DeviceAddressPtr CreateDeviceAddress(void *device_ptr, size_t device_size, const string &format,
|
DeviceAddressPtr CreateDeviceAddress(void *const device_ptr, size_t device_size, const string &format,
|
||||||
TypeId type_id) const override;
|
TypeId type_id) const override;
|
||||||
DeviceAddressType GetDeviceAddressType() const override { return DeviceAddressType::kCPU; }
|
DeviceAddressType GetDeviceAddressType() const override { return DeviceAddressType::kCPU; }
|
||||||
|
|
||||||
|
@ -69,11 +69,10 @@ class CPUDeviceContext : public DeviceContext {
|
||||||
const std::vector<AddressPtr> &outputs) const;
|
const std::vector<AddressPtr> &outputs) const;
|
||||||
|
|
||||||
// Launch a kernel by 'KernelMod' of the kernel.
|
// Launch a kernel by 'KernelMod' of the kernel.
|
||||||
bool DoLaunchKernel(KernelMod *kernel_mod, const std::vector<AddressPtr> &inputs,
|
bool DoLaunchKernel(KernelMod *const kernel_mod, const std::vector<AddressPtr> &inputs,
|
||||||
const std::vector<AddressPtr> &workspace, const std::vector<AddressPtr> &outputs) const;
|
const std::vector<AddressPtr> &workspace, const std::vector<AddressPtr> &outputs) const;
|
||||||
|
|
||||||
mutable std::mutex launch_mutex_;
|
mutable std::mutex launch_mutex_;
|
||||||
uint32_t device_id_;
|
|
||||||
std::shared_ptr<MemoryManager> mem_manager_;
|
std::shared_ptr<MemoryManager> mem_manager_;
|
||||||
bool initialized_;
|
bool initialized_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,7 +65,7 @@ class DeviceContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create concrete device address according different device type.
|
// Create concrete device address according different device type.
|
||||||
virtual DeviceAddressPtr CreateDeviceAddress(void *device_ptr, size_t device_size, const string &format,
|
virtual DeviceAddressPtr CreateDeviceAddress(void *const device_ptr, size_t device_size, const string &format,
|
||||||
TypeId type_id) const = 0;
|
TypeId type_id) const = 0;
|
||||||
|
|
||||||
// Get device address type according different device type, such GPU, Ascend.
|
// Get device address type according different device type, such GPU, Ascend.
|
||||||
|
|
|
@ -198,7 +198,7 @@ bool GPUDeviceContext::AllocateContinuousMemory(const std::vector<DeviceAddressP
|
||||||
return mem_manager_->MallocContinuousMemFromMemPool(addr_list, total_size, size_list);
|
return mem_manager_->MallocContinuousMemFromMemPool(addr_list, total_size, size_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceAddressPtr GPUDeviceContext::CreateDeviceAddress(void *device_ptr, size_t device_size, const string &format,
|
DeviceAddressPtr GPUDeviceContext::CreateDeviceAddress(void *const device_ptr, size_t device_size, const string &format,
|
||||||
TypeId type_id) const {
|
TypeId type_id) const {
|
||||||
return std::make_shared<GPUDeviceAddress>(device_ptr, device_size, format, type_id);
|
return std::make_shared<GPUDeviceAddress>(device_ptr, device_size, format, type_id);
|
||||||
}
|
}
|
||||||
|
@ -361,7 +361,6 @@ void GPUDeviceContext::UpdateDynamicShape(const CNodePtr &kernel) const {
|
||||||
MS_EXCEPTION_IF_NULL(ms_context);
|
MS_EXCEPTION_IF_NULL(ms_context);
|
||||||
bool is_pynative_infer = ms_context->get_param<bool>(MS_CTX_ENABLE_PYNATIVE_INFER);
|
bool is_pynative_infer = ms_context->get_param<bool>(MS_CTX_ENABLE_PYNATIVE_INFER);
|
||||||
bool is_pynative_mode = ms_context->get_param<int>(MS_CTX_EXECUTION_MODE) == kPynativeMode;
|
bool is_pynative_mode = ms_context->get_param<int>(MS_CTX_EXECUTION_MODE) == kPynativeMode;
|
||||||
|
|
||||||
if (is_pynative_infer || is_pynative_mode) {
|
if (is_pynative_infer || is_pynative_mode) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class GPUDeviceContext : public DeviceContext {
|
||||||
bool AllocateContinuousMemory(const std::vector<DeviceAddressPtr> &addr_list, size_t total_size,
|
bool AllocateContinuousMemory(const std::vector<DeviceAddressPtr> &addr_list, size_t total_size,
|
||||||
const std::vector<size_t> &size_list) const override;
|
const std::vector<size_t> &size_list) const override;
|
||||||
|
|
||||||
DeviceAddressPtr CreateDeviceAddress(void *device_ptr, size_t device_size, const string &format,
|
DeviceAddressPtr CreateDeviceAddress(void *const device_ptr, size_t device_size, const string &format,
|
||||||
TypeId type_id) const override;
|
TypeId type_id) const override;
|
||||||
DeviceAddressType GetDeviceAddressType() const override { return DeviceAddressType::kGPU; }
|
DeviceAddressType GetDeviceAddressType() const override { return DeviceAddressType::kGPU; }
|
||||||
|
|
||||||
|
|
|
@ -388,7 +388,7 @@ void MindRTBackend::CompileGraph(const FuncGraphPtr &func_graph) {
|
||||||
MS_EXCEPTION_IF_NULL(graph_partition_);
|
MS_EXCEPTION_IF_NULL(graph_partition_);
|
||||||
MS_EXCEPTION_IF_NULL(graph_compiler_);
|
MS_EXCEPTION_IF_NULL(graph_compiler_);
|
||||||
|
|
||||||
bool contain_multi_target;
|
bool contain_multi_target = false;
|
||||||
// Split graph to segments.
|
// Split graph to segments.
|
||||||
const auto &segments = graph_partition_->Partition(func_graph, &contain_multi_target);
|
const auto &segments = graph_partition_->Partition(func_graph, &contain_multi_target);
|
||||||
MS_LOG(INFO) << "Compile graph: " << func_graph->ToString() << ", Split segments size:" << segments.size();
|
MS_LOG(INFO) << "Compile graph: " << func_graph->ToString() << ", Split segments size:" << segments.size();
|
||||||
|
@ -450,7 +450,7 @@ const ActorInfo &MindRTBackend::CompileGraph(const OpRunInfo &op_run_info, const
|
||||||
device::DeviceContextManager::GetInstance().GetOrCreateDeviceContext({device_name_, device_id_});
|
device::DeviceContextManager::GetInstance().GetOrCreateDeviceContext({device_name_, device_id_});
|
||||||
device_context->Initialize();
|
device_context->Initialize();
|
||||||
|
|
||||||
bool single_op_cache_hit;
|
bool single_op_cache_hit = true;
|
||||||
auto graph_id = graph_compiler_->CompileGraph(op_run_info, graph_info, tensors_mask, input_tensors,
|
auto graph_id = graph_compiler_->CompileGraph(op_run_info, graph_info, tensors_mask, input_tensors,
|
||||||
&single_op_cache_hit, device_context);
|
&single_op_cache_hit, device_context);
|
||||||
// The actor set name: graph_id + single operator name.
|
// The actor set name: graph_id + single operator name.
|
||||||
|
@ -592,9 +592,8 @@ void RunControlOperator(const std::shared_ptr<GraphCompiler> graph_compiler, con
|
||||||
VectorRef args;
|
VectorRef args;
|
||||||
GetControlOpInput(graph_compiler, cnode, kernel, op_output_map, parameter_index, graph_inputs, input_tensor_info,
|
GetControlOpInput(graph_compiler, cnode, kernel, op_output_map, parameter_index, graph_inputs, input_tensor_info,
|
||||||
&args);
|
&args);
|
||||||
|
|
||||||
BaseRef out = prim->RunHookFunction(args);
|
BaseRef out = prim->RunHookFunction(args);
|
||||||
|
// Convert pyobject output to tensor.
|
||||||
if (utils::isa<PyObjectRef>(out)) {
|
if (utils::isa<PyObjectRef>(out)) {
|
||||||
PyObjectRef py_ref = utils::cast<PyObjectRef>(out);
|
PyObjectRef py_ref = utils::cast<PyObjectRef>(out);
|
||||||
auto out_py_tuple = py_ref.object_;
|
auto out_py_tuple = py_ref.object_;
|
||||||
|
|
Loading…
Reference in New Issue