Fix pclints.

This commit is contained in:
gaoyong10 2022-07-27 11:52:31 +08:00
parent d61999ab33
commit 00a7535397
20 changed files with 76 additions and 82 deletions

View File

@ -121,7 +121,7 @@ void AbstractActor::InitOutputData() {
// Identify whether the output data flag is kOutputDataFlagToStack.
bool is_to_stack = (to_op_name.find(kStackActorNameSuffix) != std::string::npos);
int output_data_flag = (is_to_stack == true) ? kOutputDataFlagToStack : kOutputDataFlagInit;
size_t output_data_flag = (is_to_stack == true) ? kOutputDataFlagToStack : kOutputDataFlagInit;
// Add the batch output data.
if (TEST_FLAG(data_arrow->flag_, kOutputDataFlagBatch)) {
@ -172,7 +172,7 @@ void AbstractActor::SendOutput(OpContext<DeviceTensor> *const context) {
// The index of output data will be modified the real actor input index in the fusion actor, so need recovery the
// fusion actor index before sending output data to the fusion actor.
if (TEST_FLAG(output_data.second, kOutputDataFlagToFusion)) {
output_data.first->index_ = data_arrow_to_fusion_actor_indexs_.at(output_data_arrow.get());
output_data.first->index_ = SizeToInt(data_arrow_to_fusion_actor_indexs_.at(output_data_arrow.get()));
}
if (TEST_FLAG(output_data.second, kOutputDataFlagLastBatch)) {
@ -231,7 +231,7 @@ void AbstractActor::SendOutput(OpContext<DeviceTensor> *const context) {
}
}
AbstractActor *AbstractActor::FetchSubActorInFusionActor(const std::string &sub_actor_name) {
AbstractActor *AbstractActor::FetchSubActorInFusionActor(const std::string &sub_actor_name) const {
if (parent_fusion_actor_ == nullptr) {
return nullptr;
}

View File

@ -35,17 +35,17 @@ namespace runtime {
using mindspore::device::DeviceContext;
// The flag of output data.
constexpr int kOutputDataFlagInit = 0;
constexpr size_t kOutputDataFlagInit = 0;
// Indicates that the output data destination is stack actor, and the output data cannot be reused.
constexpr int kOutputDataFlagToStack = 1;
constexpr size_t kOutputDataFlagToStack = 1;
// Indicates that the output data is the batch data, and send data in batches to increase the sending performance.
constexpr int kOutputDataFlagBatch = 2;
constexpr size_t kOutputDataFlagBatch = 2;
// Indicates that the output data is the last data in the batch.
constexpr int kOutputDataFlagLastBatch = 4;
constexpr size_t kOutputDataFlagLastBatch = 4;
// Indicates that the output data destination is the internal fusion actor, and uses the synchronous sending interface.
constexpr int kOutputDataFlagBetweenFusion = 8;
constexpr size_t kOutputDataFlagBetweenFusion = 8;
// Indicates that the output data destination is the fusion actor, and needs to use the fusion output index.
constexpr int kOutputDataFlagToFusion = 16;
constexpr size_t kOutputDataFlagToFusion = 16;
// The abstract common attributes of actors. The actor inheritance relationship: OpActor --> AbstractActor -->
// MemoryAwareActor --> DebugAwareActor --> KernelActor/DataSourceActor/CopyActor/LoopCountActor/OutputActor.
@ -89,7 +89,7 @@ class AbstractActor : public OpActor<DeviceTensor> {
const mindspore::HashMap<std::string, std::vector<DataArrowPtr>> &batch_output_data_arrows() const {
return batch_output_data_arrows_;
}
AbstractActor *parent_fusion_actor() const { return parent_fusion_actor_; }
const AbstractActor *parent_fusion_actor() const { return parent_fusion_actor_; }
const mindspore::HashMap<std::string, std::shared_ptr<AbstractActor>> &sub_actors() const { return sub_actors_; }
const std::unordered_set<std::string> &dependent_actors() const { return dependent_actors_; }
@ -117,7 +117,7 @@ class AbstractActor : public OpActor<DeviceTensor> {
virtual void SendRecorderInfo(OpContext<DeviceTensor> *const context) const {}
// Fetch the sub actor in the fusion actor by the name.
AbstractActor *FetchSubActorInFusionActor(const std::string &sub_actor_name);
AbstractActor *FetchSubActorInFusionActor(const std::string &sub_actor_name) const;
KernelTransformType type_;
@ -130,7 +130,7 @@ class AbstractActor : public OpActor<DeviceTensor> {
// The output_data_nodes_ and output_data_ corresponds to the output_data_arrows_ one by one.
std::vector<AnfNodePtr> output_data_nodes_;
// The second of pair indicates the output data falg. See constant prefixed with kOutputDataFalg for details.
std::vector<std::pair<OpDataUniquePtr<DeviceTensor>, int>> output_data_;
std::vector<std::pair<OpDataUniquePtr<DeviceTensor>, size_t>> output_data_;
// Record the fusion output index for output data arrow.
mindspore::HashMap<DataArrow *, size_t> data_arrow_to_fusion_actor_indexs_;
// Used to send batch data in the message which RunBatchOpData needs, the key is the actor name of destination actor.

View File

@ -104,7 +104,7 @@ enum class KernelTransformType {
#define SET_FLAG(value, flag) ((value) = ((value) | (flag)))
#define TEST_FLAG(value, flag) (((value) & (flag)) == (flag))
#define CLEAR_FLAG(value, flag) ((value) = ((value) & (~flag)))
#define CLEAR_FLAG(value, flag) ((value) = ((value) & (~(flag))))
#define SET_OPCONTEXT_FAIL_RET_WITH_ERROR(op_context, message) \
{ \
@ -121,8 +121,8 @@ enum class KernelTransformType {
#define SET_OPCONTEXT_FAIL_RET_WITH_ERROR_BY_STRATEGY(strategy, op_context, message) \
{ \
if (strategy == GraphExecutionStrategy::kStep) { \
MS_LOG(EXCEPTION) << message; \
if ((strategy) == GraphExecutionStrategy::kStep) { \
MS_LOG(EXCEPTION) << (message); \
} \
(op_context).error_info_ = message; \
(op_context).SetFailed(kFailure); \
@ -133,14 +133,14 @@ enum class KernelTransformType {
{ \
std::string message = ""; \
if ((device_context).device_context_key().device_name_ == "CPU") { \
message = "Memory isn't enough and alloc failed, kernel name: " + kernel_name + \
message = "Memory isn't enough and alloc failed, kernel name: " + (kernel_name) + \
", alloc size: " + std::to_string(alloc_size) + "B."; \
} else { \
message = "Device(id:" + std::to_string((device_context).device_context_key().device_id_) + \
") memory isn't enough and alloc failed, kernel name: " + kernel_name + \
") memory isn't enough and alloc failed, kernel name: " + (kernel_name) + \
", alloc size: " + std::to_string(alloc_size) + "B."; \
} \
if (strategy == GraphExecutionStrategy::kStep) { \
if ((strategy) == GraphExecutionStrategy::kStep) { \
MS_LOG(EXCEPTION) << message; \
} \
(op_context).error_info_ = message; \
@ -195,7 +195,6 @@ class ActorDispatcher {
template <typename T, typename... Args0, typename... Args1>
static void SendSync(const AID &aid, void (T::*method)(Args0...), Args1 &&... args) {
auto actor_manager = ActorMgr::GetActorMgrRef();
MS_EXCEPTION_IF_NULL(actor_manager);
auto base_actor = actor_manager->GetActor(aid);
T *actor = static_cast<T *>(base_actor.get());
MS_EXCEPTION_IF_NULL(actor);

View File

@ -20,7 +20,6 @@
#include <vector>
#include <string>
#include <memory>
#include <utility>
#include <fstream>
#include "runtime/graph_scheduler/actor/abstract_actor.h"
#include "runtime/graph_scheduler/actor/data_prepare_actor.h"

View File

@ -71,7 +71,7 @@ void ControlActor::GetAllDeviceTensors(const OpRealParameterWithBranchID &op_rea
}
}
void ControlActor::IncreaseDynamicRefCount(const OpData<DeviceTensor> *op_data) {
void ControlActor::IncreaseDynamicRefCount(const OpData<DeviceTensor> *op_data) const {
MS_EXCEPTION_IF_NULL(op_data);
MS_EXCEPTION_IF_NULL(op_data->data_);
op_data->data_->IncreaseDynamicRefCount(GetAID().Name());
@ -294,7 +294,7 @@ void ControlActor::IncreaseDynamicRefCounts(OpContext<DeviceTensor> *const conte
" current:" + std::to_string(input_partials_.size()) + " for actor:" + GetAID().Name();
SET_OPCONTEXT_FAIL_RET_WITH_ERROR((*context), error_info);
}
auto output_partial = input_partials_[output_partial_arrow->from_output_index_];
auto output_partial = input_partials_[IntToSize(output_partial_arrow->from_output_index_)];
IncreaseDynamicRefCount(output_partial);
}
}

View File

@ -91,7 +91,7 @@ class ControlActor : public MemoryAwareActor {
void GetAllDeviceTensors(const OpPartialPtr &op_partial, std::vector<DeviceTensor *> *device_tensors);
void GetAllDeviceTensors(const OpRealParameterWithBranchID &op_real_parameter,
std::vector<DeviceTensor *> *device_tensors);
void IncreaseDynamicRefCount(const OpData<DeviceTensor> *op_data);
void IncreaseDynamicRefCount(const OpData<DeviceTensor> *op_data) const;
void IncreaseDynamicRefCount(const OpPartialPtr &op_partial);
void IncreaseDynamicRefCount(const OpRealParameterWithBranchID &op_real_parameter);

View File

@ -56,7 +56,8 @@ void EntranceActor::RunOpRealParameterWithBranchID(const OpRealParameterWithBran
void EntranceActor::ClearDataOnStepEnd(AID *const input_control, OpContext<DeviceTensor> *const context) {
MS_EXCEPTION_IF_NULL(context);
MS_LOG(DEBUG) << "Actor(" << GetAID().Name() << ") receive the message of clearing data.";
MS_LOG(DEBUG) << "Actor(" << GetAID().Name()
<< ") receive the message of clearing data from:" << input_control->Name() << ".";
is_loop_body_execution_ = false;

View File

@ -20,7 +20,6 @@
#include <vector>
#include <string>
#include <memory>
#include <utility>
#include "utils/hash_map.h"
#include "runtime/graph_scheduler/actor/actor_common.h"
#include "runtime/graph_scheduler/actor/memory_aware_actor.h"

View File

@ -15,7 +15,7 @@
*/
#include <algorithm>
#include <set>
#include "runtime/graph_scheduler/actor/data_prepare_actor.h"
#include "runtime/graph_scheduler/actor/memory_manager_actor.h"
#include "runtime/graph_scheduler/actor/kernel_actor.h"
@ -123,8 +123,8 @@ void ValueTupleToValue(const ValuePtr &value, std::vector<ValuePtr> *const value
(void)values->emplace_back(csr_tensor->GetIndptr());
(void)values->emplace_back(csr_tensor->GetIndices());
(void)values->emplace_back(csr_tensor->GetValues());
std::transform(csr_tensor->shape().begin(), csr_tensor->shape().end(), std::back_inserter(*values),
[](int64_t n) { return std::make_shared<Int64Imm>(n); });
(void)std::transform(csr_tensor->shape().begin(), csr_tensor->shape().end(), std::back_inserter(*values),
[](int64_t n) { return std::make_shared<Int64Imm>(n); });
} else if (value->isa<tensor::COOTensor>()) {
auto coo_tensor = value->cast<tensor::COOTensorPtr>();
MS_EXCEPTION_IF_NULL(coo_tensor);
@ -132,8 +132,8 @@ void ValueTupleToValue(const ValuePtr &value, std::vector<ValuePtr> *const value
MS_EXCEPTION_IF_NULL(coo_tensor->GetValues());
(void)values->emplace_back(coo_tensor->GetIndices());
(void)values->emplace_back(coo_tensor->GetValues());
std::transform(coo_tensor->shape().begin(), coo_tensor->shape().end(), std::back_inserter(*values),
[](int64_t n) { return std::make_shared<Int64Imm>(n); });
(void)std::transform(coo_tensor->shape().begin(), coo_tensor->shape().end(), std::back_inserter(*values),
[](int64_t n) { return std::make_shared<Int64Imm>(n); });
} else {
(void)values->emplace_back(value);
}
@ -572,7 +572,7 @@ void DataPrepareActor::PrepareDataForHostTensorQueue(const std::vector<std::vect
// The branch processing of PrepareDataForValueNode that value type is tensor.
void DataPrepareActor::PrepareDataForValueNodeTensor(const ValueNodePtr &node, const ValuePtr &node_value,
const AnfNodePtr &front_node, const DeviceContext *device_context,
OpContext<DeviceTensor> *const context) {
OpContext<DeviceTensor> *const context) const {
MS_EXCEPTION_IF_NULL(node);
MS_EXCEPTION_IF_NULL(node_value);
MS_EXCEPTION_IF_NULL(device_context);
@ -607,7 +607,7 @@ void DataPrepareActor::PrepareDataForValueNodeTensor(const ValueNodePtr &node, c
void DataPrepareActor::PrepareDataForControlValueNode(const KernelWithIndex &node_with_index,
const DeviceContext *device_context,
OpContext<DeviceTensor> *const context) {
OpContext<DeviceTensor> *const context) const {
MS_EXCEPTION_IF_NULL(device_context);
MS_EXCEPTION_IF_NULL(context);
MS_EXCEPTION_IF_NULL(node_with_index.first);
@ -666,7 +666,7 @@ void DataPrepareActor::PrepareDataForControlValueNode(const KernelWithIndex &nod
// Prepare the device data for persistent device tensor of value node.
void DataPrepareActor::PrepareDataForValueNode(const ValueNodePtr &node, const AnfNodePtr &front_node,
const DeviceContext *device_context,
OpContext<DeviceTensor> *const context) {
OpContext<DeviceTensor> *const context) const {
MS_EXCEPTION_IF_NULL(node);
MS_EXCEPTION_IF_NULL(front_node);
MS_EXCEPTION_IF_NULL(device_context);
@ -743,7 +743,7 @@ void DataPrepareActor::CopyDataFromDeviceTensorStore(const AnfNodePtr &front_nod
// Prepare the device data for persistent device tensor of weight node from host tensor.
void DataPrepareActor::PrepareDataForWeightNode(const AnfNodePtr &backend_node, const AnfNodePtr &front_node,
const TensorPtr &tensor, const DeviceContext *device_context,
OpContext<DeviceTensor> *const context) {
OpContext<DeviceTensor> *const context) const {
MS_EXCEPTION_IF_NULL(backend_node);
MS_EXCEPTION_IF_NULL(front_node);
MS_EXCEPTION_IF_NULL(device_context);
@ -814,7 +814,7 @@ void DataPrepareActor::PrepareDataForWeightNode(const AnfNodePtr &backend_node,
void DataPrepareActor::PrepareDeviceTensorStoreForControlNode(const ControlNodeParserPtr &control_node_parser,
const std::vector<TensorPtr> &tensors,
OpContext<DeviceTensor> *const context) {
OpContext<DeviceTensor> *const context) const {
MS_EXCEPTION_IF_NULL(control_node_parser);
if (!control_node_parser->IsInited()) {
return;

View File

@ -86,25 +86,25 @@ class DataPrepareActor : public DebugAwareActor {
// Prepare the device data for persistent device tensor of weight node from host tensor.
void PrepareDataForWeightNode(const AnfNodePtr &backend_node, const AnfNodePtr &front_node, const TensorPtr &tensor,
const DeviceContext *device_context, OpContext<DeviceTensor> *const context);
const DeviceContext *device_context, OpContext<DeviceTensor> *const context) const;
// Prepare the device data for persistent device tensor of value node.
void PrepareDataForValueNode(const ValueNodePtr &node, const AnfNodePtr &front_node,
const DeviceContext *device_context, OpContext<DeviceTensor> *const context);
const DeviceContext *device_context, OpContext<DeviceTensor> *const context) const;
// The branch processing of PrepareDataForValueNode that value type is tensor.
void PrepareDataForValueNodeTensor(const ValueNodePtr &node, const ValuePtr &node_value, const AnfNodePtr &front_node,
const DeviceContext *device_context, OpContext<DeviceTensor> *const context);
const DeviceContext *device_context, OpContext<DeviceTensor> *const context) const;
// The data prepare in the control flow scene.
// If the parameters in the root graph are only used by the control node, these parameters will not be initialized
// by the kernel graph, and addresses need to be specially allocated for these parameters.
void PrepareDeviceTensorStoreForControlNode(const ControlNodeParserPtr &control_node_parser,
const std::vector<TensorPtr> &tensors,
OpContext<DeviceTensor> *const context);
OpContext<DeviceTensor> *const context) const;
void PrepareHostTensorQueueForControlNode(const std::vector<TensorPtr> &tensors,
std::vector<TensorPtr> *const host_tensors,
OpContext<DeviceTensor> *const context);
void PrepareDataForControlValueNode(const KernelWithIndex &node_with_index, const DeviceContext *device_context,
OpContext<DeviceTensor> *const context);
OpContext<DeviceTensor> *const context) const;
// The device tensor stores may exist the two device tensors and need copy data in the heterogeneous scene.
void CopyDataFromDeviceTensorStore(const AnfNodePtr &front_node, const AnfNodePtr &backend_node,

View File

@ -67,7 +67,7 @@ void DataSourceActor::UpdateOutputData(OpData<DeviceTensor> *const output_data,
auto position = FetchNodePosition({output_node, data_arrow->from_output_index_});
// Host data souruce actor uses the node position, device data source actor uses the output index.
auto output_position = (position != 0) ? position : data_arrow->from_output_index_;
auto output_position = (position != 0) ? position : IntToSize(data_arrow->from_output_index_);
if (output_position >= output_device_tensors.size()) {
SET_OPCONTEXT_FAIL_RET_WITH_ERROR((*context), "The output index is of range.");
}

View File

@ -27,9 +27,9 @@ void FusionActor::RunOpData(OpData<DeviceTensor> *const input_data, OpContext<De
SET_OPCONTEXT_FAIL_RET_WITH_ERROR((*context), "The input index is out of range.");
}
// Update the input data using the real input info.
auto &real_input_data = real_input_data_[input_data->index_];
auto &real_input_data = real_input_data_[IntToSize(input_data->index_)];
MS_EXCEPTION_IF_NULL(real_input_data.first);
input_data->index_ = real_input_data.second;
input_data->index_ = SizeToInt(real_input_data.second);
real_input_data.first->RunOpData(input_data, context);
}

View File

@ -94,8 +94,8 @@ void KernelActor::Init() {
if (IntToSize(data_arrow->from_output_index_) >= output_device_tensors_.size()) {
MS_LOG(EXCEPTION) << "The output index is out of range: " << GetAID().Name();
}
data->data_ = output_device_tensors_[data_arrow->from_output_index_];
(void)output_data_by_output_index_[data_arrow->from_output_index_].emplace_back(data);
data->data_ = output_device_tensors_[IntToSize(data_arrow->from_output_index_)];
(void)output_data_by_output_index_[IntToSize(data_arrow->from_output_index_)].emplace_back(data);
++output_data_index;
}
@ -308,7 +308,7 @@ void KernelActor::CopyInputDeviceTensor(const OpData<DeviceTensor> *input_data,
if (IntToSize(input_data->index_) >= real_input_data_infos_.size()) {
SET_OPCONTEXT_FAIL_RET_WITH_ERROR_BY_STRATEGY(strategy_, *context, "The input index is of range.");
}
auto &real_input_info = real_input_data_infos_[input_data->index_];
auto &real_input_info = real_input_data_infos_[IntToSize(input_data->index_)];
MS_EXCEPTION_IF_NULL(real_input_info);
if ((input_data->data_->GetDeviceType() == device_contexts_[0]->GetDeviceType()) &&
(input_data->data_->format() == real_input_info->format_)) {
@ -318,18 +318,19 @@ void KernelActor::CopyInputDeviceTensor(const OpData<DeviceTensor> *input_data,
if (IntToSize(input_data->index_) >= copy_input_device_tensors_.size()) {
SET_OPCONTEXT_FAIL_RET_WITH_ERROR_BY_STRATEGY(strategy_, *context, "The input index is of range.");
}
if (copy_input_device_tensors_[input_data->index_] == nullptr) {
copy_input_device_tensors_[input_data->index_] = device_contexts_[0]->device_res_manager_->CreateDeviceAddress(
nullptr, real_input_info->size_, real_input_info->format_, real_input_info->type_id_, real_input_info->shape_);
if (copy_input_device_tensors_[IntToSize(input_data->index_)] == nullptr) {
copy_input_device_tensors_[IntToSize(input_data->index_)] =
device_contexts_[0]->device_res_manager_->CreateDeviceAddress(
nullptr, real_input_info->size_, real_input_info->format_, real_input_info->type_id_, real_input_info->shape_);
}
auto &new_device_tensor = copy_input_device_tensors_[input_data->index_];
auto &new_device_tensor = copy_input_device_tensors_[IntToSize(input_data->index_)];
MS_EXCEPTION_IF_NULL(new_device_tensor);
// Dynamic shape need update size.
if (IsDynamic(real_input_info->shape_)) {
new_device_tensor->SetSize(input_data->data_->GetSize());
}
// Update the input device tensor.
input_device_tensors_[input_data->index_] = new_device_tensor.get();
input_device_tensors_[IntToSize(input_data->index_)] = new_device_tensor.get();
device::DynamicMemAllocatorDebugInfo::SetDebugInfo(GetAID().Name(), device::AllocatorType::kKernelOutput,
input_data->index_);
@ -364,9 +365,9 @@ void KernelActor::FetchInputDeviceTensor(OpContext<DeviceTensor> *const context)
SET_OPCONTEXT_FAIL_RET_WITH_ERROR_BY_STRATEGY(strategy_, (*context), "The input index is out of range.");
}
if (input_device_tensors_[input_data->index_] != input_data->data_) {
input_device_tensors_[input_data->index_] = input_data->data_;
memory_free_list_[input_data->index_] = input_data->data_;
if (input_device_tensors_[IntToSize(input_data->index_)] != input_data->data_) {
input_device_tensors_[IntToSize(input_data->index_)] = input_data->data_;
memory_free_list_[IntToSize(input_data->index_)] = input_data->data_;
}
CopyInputDeviceTensor(input_data, context);
}

View File

@ -17,7 +17,6 @@
#ifndef MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_MEMORY_AWARE_ACTOR_H_
#define MINDSPORE_CCSRC_RUNTIME_FRAMEWORK_ACTOR_MEMORY_AWARE_ACTOR_H_
#include <utility>
#include <string>
#include "runtime/graph_scheduler/actor/abstract_actor.h"
#include "runtime/graph_scheduler/device_tensor_store.h"

View File

@ -106,7 +106,7 @@ void MemoryManagerActor::AllocateContinuousMemory(const std::vector<std::vector<
}
auto new_dev_addr = device_context->device_res_manager_->CreateDeviceAddress(
dev_ptr_list[index], old_size, old_dev_addr->format(), old_dev_addr->type_id(), old_dev_addr->host_shape());
new_dev_addr->SyncDeviceToDevice(old_dev_addr.get());
(void)new_dev_addr->SyncDeviceToDevice(old_dev_addr.get());
device_context->device_res_manager_->FreeMemory(old_dev_addr.get());
}
alloc_list[index]->set_ptr(dev_ptr_list[index]);

View File

@ -16,7 +16,6 @@
#include "runtime/graph_scheduler/actor/recorder_actor.h"
#include <string>
#include <utility>
#ifdef ENABLE_DUMP_IR
#include "include/common/debug/rdr/recorder_manager.h"
#include "debug/rdr/mem_address_recorder.h"

View File

@ -77,7 +77,7 @@ void SuperKernelActor::Init() {
MS_EXCEPTION_IF_NULL(data_arrow);
MS_EXCEPTION_IF_NULL(output_node);
MS_EXCEPTION_IF_NULL(data);
auto device_address = AnfAlgo::GetMutableOutputAddr(output_node, data_arrow->from_output_index_, false);
auto device_address = AnfAlgo::GetMutableOutputAddr(output_node, IntToSize(data_arrow->from_output_index_), false);
data->data_ = device_address.get();
}
@ -128,7 +128,6 @@ void SuperKernelActor::Run(OpContext<DeviceTensor> *const context) {
}
try {
// @TODO: @TBD: run graph with inputs and outputs
const std::vector<tensor::Tensor> inputs;
std::vector<tensor::Tensor> outputs;
const std::map<string, string> compile_options;
@ -186,7 +185,7 @@ bool SuperKernelActor::CopyInputData(const OpContext<DeviceTensor> *context) {
MS_LOG(ERROR) << "The input index:" << dst_index << "is out of range:" << input_nodes.size() << ".";
return false;
}
auto dst_node = input_nodes[dst_index];
auto dst_node = input_nodes[IntToSize(dst_index)];
MS_EXCEPTION_IF_NULL(dst_node);
auto dst_param = dst_node->cast<ParameterPtr>();

View File

@ -114,7 +114,7 @@ ControlActorSetPtr ControlNodeScheduler::Build(const GraphCompilerInfo &graph_co
return control_actors;
}
std::vector<SwitchActorPtr> ControlNodeScheduler::BuildSwitchActor(const GraphCompilerInfo &graph_compiler_info) {
std::vector<SwitchActorPtr> ControlNodeScheduler::BuildSwitchActor(const GraphCompilerInfo &graph_compiler_info) const {
std::vector<SwitchActorPtr> switch_actors;
const auto &control_nodes = graph_compiler_info.control_nodes_;
@ -213,7 +213,7 @@ void ControlNodeScheduler::BuildDataSourceActorForControlNode(
}
}
std::vector<GatherActorPtr> ControlNodeScheduler::BuildGatherActor(const GraphCompilerInfo &graph_compiler_info) {
std::vector<GatherActorPtr> ControlNodeScheduler::BuildGatherActor(const GraphCompilerInfo &graph_compiler_info) const {
std::vector<GatherActorPtr> gather_actors;
const auto &control_nodes = graph_compiler_info.control_nodes_;
const auto &parser = graph_compiler_info.control_node_parser_;
@ -250,7 +250,8 @@ std::vector<GatherActorPtr> ControlNodeScheduler::BuildGatherActor(const GraphCo
return gather_actors;
}
std::vector<EntranceActorPtr> ControlNodeScheduler::BuildEntranceActor(const GraphCompilerInfo &graph_compiler_info) {
std::vector<EntranceActorPtr> ControlNodeScheduler::BuildEntranceActor(
const GraphCompilerInfo &graph_compiler_info) const {
const auto &parser = graph_compiler_info.control_node_parser_;
MS_EXCEPTION_IF_NULL(parser);
const auto &call_node_to_func_graphs = parser->call_node_to_func_graphs_;
@ -315,7 +316,7 @@ std::vector<EntranceActorPtr> ControlNodeScheduler::BuildEntranceActor(const Gra
return entrance_actors;
}
std::vector<ExitActorPtr> ControlNodeScheduler::BuildExitActor(const GraphCompilerInfo &graph_compiler_info) {
std::vector<ExitActorPtr> ControlNodeScheduler::BuildExitActor(const GraphCompilerInfo &graph_compiler_info) const {
std::vector<ExitActorPtr> exit_actors;
const auto &control_nodes = graph_compiler_info.control_nodes_;
const auto &parser = graph_compiler_info.control_node_parser_;
@ -386,7 +387,7 @@ std::vector<ExitActorPtr> ControlNodeScheduler::BuildExitActor(const GraphCompil
return exit_actors;
}
std::vector<StackActorPtr> ControlNodeScheduler::BuildStackActor(const GraphCompilerInfo &graph_compiler_info) {
std::vector<StackActorPtr> ControlNodeScheduler::BuildStackActor(const GraphCompilerInfo &graph_compiler_info) const {
std::vector<StackActorPtr> stack_actors;
const auto &parser = graph_compiler_info.control_node_parser_;
MS_EXCEPTION_IF_NULL(parser);
@ -436,7 +437,7 @@ std::vector<StackActorPtr> ControlNodeScheduler::BuildStackActor(const GraphComp
}
void ControlNodeScheduler::BuildStackActorForControlNode(const GraphCompilerInfo &graph_compiler_info,
std::vector<StackActorPtr> *const stack_actors) {
std::vector<StackActorPtr> *const stack_actors) const {
const auto &parser = graph_compiler_info.control_node_parser_;
MS_EXCEPTION_IF_NULL(parser);
@ -529,7 +530,7 @@ void ControlNodeScheduler::BuildStackActorForControlNode(const GraphCompilerInfo
}
}
void ControlNodeScheduler::Link(ActorSet *const actor_set, const GraphCompilerInfo &graph_compiler_info) {
void ControlNodeScheduler::Link(ActorSet *const actor_set, const GraphCompilerInfo &graph_compiler_info) const {
MS_EXCEPTION_IF_NULL(actor_set);
MS_EXCEPTION_IF_NULL(actor_set->control_actors_);
MS_LOG(DEBUG) << "Control node scheduler link start.";
@ -599,7 +600,7 @@ void ControlNodeScheduler::LinkControlArrowForCustomActor(ActorSet *const actor_
}
}
void ControlNodeScheduler::ClearActorData(const ControlActorSet *control_actor_set) {
void ControlNodeScheduler::ClearActorData(const ControlActorSet *control_actor_set) const {
if (control_actor_set == nullptr) {
return;
}
@ -1397,7 +1398,7 @@ void ControlNodeScheduler::LinkDataArrowForCustomActor(const ActorSet *actor_set
MS_EXCEPTION_IF_NULL(base_node);
auto dynamic_shape_depends = abstract::GetValueDependArgIndices(base_node);
for (auto iter = dynamic_shape_depends.begin(); iter != dynamic_shape_depends.end(); ++iter) {
auto input_node = common::AnfAlgo::GetInputNode(base_node, *iter);
auto input_node = common::AnfAlgo::GetInputNode(base_node, LongToSize(*iter));
MS_EXCEPTION_IF_NULL(input_node);
KernelWithIndex from_kernel_with_index = common::AnfAlgo::VisitKernelWithReturnType(input_node, 0, false);
const AnfNodePtr real_input_node = from_kernel_with_index.first;
@ -1435,7 +1436,7 @@ void ControlNodeScheduler::LinkDataArrowForCustomActor(const ActorSet *actor_set
size_t from_index = from_actor->FetchNodePosition(front_node_with_index);
MS_LOG(DEBUG) << "Link data arrow from actor:" << from_actor->GetAID()
<< " to custom actor:" << custom_actor->GetAID();
SchedulerHelper::AddDataArrow(from_actor, custom_actor.get(), from_index, *iter);
SchedulerHelper::AddDataArrow(from_actor, custom_actor.get(), from_index, LongToSize(*iter));
}
}
}

View File

@ -40,7 +40,7 @@ class ControlNodeScheduler {
// Transform the control nodes to control actors.
ControlActorSetPtr Build(const GraphCompilerInfo &graph_compiler_info, const AID &memory_manager_aid);
// Link control actors.
void Link(ActorSet *const actor_set, const GraphCompilerInfo &graph_compiler_info);
void Link(ActorSet *const actor_set, const GraphCompilerInfo &graph_compiler_info) const;
void BuildDataSourceActorForControlNode(const GraphCompilerInfo &graph_compiler_info,
const HostTensorQueuePtr &host_queue,
@ -48,17 +48,17 @@ class ControlNodeScheduler {
std::vector<DataSourceActorPtr> *data_source_actors) const;
// The control flow actor will generate some data in the loop body execution, so need clear on the end of execution.
void ClearActorData(const ControlActorSet *control_actor_set);
void ClearActorData(const ControlActorSet *control_actor_set) const;
private:
// Interface to create control actors.
std::vector<SwitchActorPtr> BuildSwitchActor(const GraphCompilerInfo &graph_compiler_info);
std::vector<GatherActorPtr> BuildGatherActor(const GraphCompilerInfo &graph_compiler_info);
std::vector<EntranceActorPtr> BuildEntranceActor(const GraphCompilerInfo &graph_compiler_info);
std::vector<ExitActorPtr> BuildExitActor(const GraphCompilerInfo &graph_compiler_info);
std::vector<StackActorPtr> BuildStackActor(const GraphCompilerInfo &graph_compiler_info);
std::vector<SwitchActorPtr> BuildSwitchActor(const GraphCompilerInfo &graph_compiler_info) const;
std::vector<GatherActorPtr> BuildGatherActor(const GraphCompilerInfo &graph_compiler_info) const;
std::vector<EntranceActorPtr> BuildEntranceActor(const GraphCompilerInfo &graph_compiler_info) const;
std::vector<ExitActorPtr> BuildExitActor(const GraphCompilerInfo &graph_compiler_info) const;
std::vector<StackActorPtr> BuildStackActor(const GraphCompilerInfo &graph_compiler_info) const;
void BuildStackActorForControlNode(const GraphCompilerInfo &graph_compiler_info,
std::vector<StackActorPtr> *const stack_actors);
std::vector<StackActorPtr> *const stack_actors) const;
// Interface to link control actors.
void LinkControlArrowForControlActor(ActorSet *const actor_set, const GraphCompilerInfo &graph_compiler_info) const;
void LinkControlArrowForEntranceActor(ActorSet *const actor_set, const GraphCompilerInfo &graph_compiler_info) const;

View File

@ -46,7 +46,6 @@ abstract::BaseShapePtr AdaptiveMaxPool2DInferShape(const PrimitivePtr &primitive
if (input_args.size() != 1) {
MS_EXCEPTION(ValueError) << "For primitive[AdaptiveMaxPool2D], the num of input args should be 1, but got "
<< input_args.size();
return std::make_shared<abstract::Shape>(std::vector<int64_t>());
}
auto shape_map = CheckAndConvertUtils::ConvertShapePtrToShapeMap(input_args[0]->BuildShape());
@ -69,14 +68,13 @@ abstract::BaseShapePtr AdaptiveMaxPool2DInferShape(const PrimitivePtr &primitive
MS_EXCEPTION(ValueError) << "For primitive[AdaptiveMaxPool2D], the shape size of input argument[input_x] must be 3 "
"or 4 and the size of attr[output_size] must be 2, but got shape size:"
<< in_shape_vector.size() << " and output_size size:" << output_size.size();
return nullptr;
}
// Update the output shape by output size and input shape.
if (in_shape_vector.size() != 1) {
auto input_size_iter = in_shape_vector.rbegin();
auto output_size_iter = output_size.rbegin();
for (; output_size_iter != output_size.rend(); output_size_iter++, input_size_iter++) {
for (; output_size_iter != output_size.rend(); ++output_size_iter, ++input_size_iter) {
// If output size is none, the input shape should be used.
if (*output_size_iter != kPyValueNone) {
*input_size_iter = *output_size_iter;
@ -101,7 +99,6 @@ TypePtr AdaptiveMaxPool2DInferType(const PrimitivePtr &prim, const std::vector<A
if (input_args.size() != 1) {
MS_EXCEPTION(ValueError) << "For primitive[AdaptiveMaxPool2D], the num of input args should be 1, but got "
<< input_args.size();
return nullptr;
}
const std::set<TypePtr> valid_types = {kFloat16, kFloat32, kFloat64};