Browse Source

!31317 Fix pclint.

Merge pull request !31317 from gaoyong10/dynamic_shape_01
r1.7
i-robot Gitee 4 years ago
parent
commit
6e4d2e0469
No known key found for this signature in database GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 16 additions and 15 deletions
  1. +1
    -1
      mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/control_actor.cc
  2. +3
    -3
      mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/control_actor.h
  3. +5
    -4
      mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/exit_actor.cc
  4. +1
    -1
      mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/exit_actor.h
  5. +5
    -5
      mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/stack_actor.cc
  6. +1
    -1
      mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/switch_actor.cc

+ 1
- 1
mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/control_actor.cc View File

@@ -446,7 +446,7 @@ void ControlActor::UpdateDynamicShapeInParameter() {

auto shape = input_device_tensors_[i]->host_shape();
std::vector<size_t> shape_tmp;
std::transform(shape.begin(), shape.end(), std::back_inserter(shape_tmp), IntToSize);
(void)std::transform(shape.begin(), shape.end(), std::back_inserter(shape_tmp), IntToSize);

for (const auto &parameter : backend_parameters_[i]) {
common::AnfAlgo::SetOutputInferTypeAndShape({input_device_tensors_[i]->type_id()}, {shape_tmp}, parameter.get());


+ 3
- 3
mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/control_actor.h View File

@@ -75,7 +75,9 @@ class ControlActor : public MemoryAwareActor {
const std::map<size_t, std::set<DeviceTensorPtr>> &ref_node_formal_parameter_device_tensors() const {
return ref_node_formal_parameter_device_tensors_;
}
size_t branch_id() const { return output_branch_id_; }
int branch_id() const { return output_branch_id_; }
// Free memory by the dynamic ref count decremented. It corresponds to the EraseInput.
void SendMemoryFreeReq(OpContext<DeviceTensor> *const context) override;

protected:
friend class ControlNodeScheduler;
@@ -107,8 +109,6 @@ class ControlActor : public MemoryAwareActor {

// Increase the dynamic ref count by the outputs. It corresponds to the SendOutput.
virtual void IncreaseDynamicRefCounts(OpContext<DeviceTensor> *const context);
// Free memory by the dynamic ref count decremented. It corresponds to the EraseInput.
void SendMemoryFreeReq(OpContext<DeviceTensor> *const context) override;

// Input data.
// 1.Input partial.


+ 5
- 4
mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/exit_actor.cc View File

@@ -14,6 +14,7 @@
* limitations under the License.
*/

#include <algorithm>
#include "runtime/graph_scheduler/actor/control_flow/exit_actor.h"
#include "runtime/graph_scheduler/actor/output_actor.h"

@@ -179,7 +180,7 @@ void ExitActor::CopyDeviceAddress(OpContext<DeviceTensor> *const context) {
<< " for actor:" << GetAID();
auto shape_tmp = common::AnfAlgo::GetOutputInferShape(node_with_index.first, node_with_index.second);
host_shape.clear();
std::transform(shape_tmp.begin(), shape_tmp.end(), std::back_inserter(host_shape), IntToSize);
(void)std::transform(shape_tmp.begin(), shape_tmp.end(), std::back_inserter(host_shape), IntToSize);
}
// Create the new device tensor to take over the input_device_tensors which are the outputs of kernel graphs.
auto new_device_tensor =
@@ -224,11 +225,11 @@ void ExitActor::CopyDeviceAddress(OpContext<DeviceTensor> *const context) {
continue;
}

const auto &data = input_device_tensors_[i];
MS_EXCEPTION_IF_NULL(data);
const auto &device_tensor = input_device_tensors_[i];
MS_EXCEPTION_IF_NULL(device_tensor);
for (auto &output_data : output_data_by_output_index_[i]) {
MS_EXCEPTION_IF_NULL(output_data);
output_data->data_ = data;
output_data->data_ = device_tensor;
}
}
}


+ 1
- 1
mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/exit_actor.h View File

@@ -50,13 +50,13 @@ class ExitActor : public ControlActor {
return output_branch_partial_arrows_;
}
const std::vector<bool> &is_need_copy_device_tensors() const { return is_need_copy_device_tensors_; }
void OnMemoryAllocFinish(OpContext<DeviceTensor> *const context) override;

protected:
void Init() override;
void FetchInput(OpContext<DeviceTensor> *const context) override;
void SendOutput(OpContext<DeviceTensor> *const context) override;
void IncreaseDynamicRefCounts(OpContext<DeviceTensor> *const context) override;
void OnMemoryAllocFinish(OpContext<DeviceTensor> *const context) override;

private:
friend class ControlNodeScheduler;


+ 5
- 5
mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/stack_actor.cc View File

@@ -343,14 +343,14 @@ void StackActor::EraseInput(const OpContext<DeviceTensor> *const context) {
MS_LOG(ERROR) << "Input stack control aid:" << stack_iter->first << " is null in actor:" << GetAID();
return;
} else if (stack_iter->second == 1) {
control_iter->second.erase(stack_iter++);
(void)control_iter->second.erase(stack_iter++);
} else {
stack_iter->second--;
stack_iter++;
(void)stack_iter++;
}
}
if (control_iter->second.empty()) {
input_stack_controls_.erase(control_iter);
(void)input_stack_controls_.erase(control_iter);
}
}
}
@@ -361,7 +361,7 @@ void StackActor::SendMemoryFreeReq(OpContext<DeviceTensor> *const context) {

// Collect the input device tensors.
std::vector<DeviceTensor *> memory_free_list;
if (input_op_datas_.count(sequential_num) > 0) {
if (input_op_datas_.find(sequential_num) != input_op_datas_.end()) {
for (auto &input_data : input_op_datas_[sequential_num]) {
MS_EXCEPTION_IF_NULL(input_data);
MS_EXCEPTION_IF_NULL(input_data->data_);
@@ -369,7 +369,7 @@ void StackActor::SendMemoryFreeReq(OpContext<DeviceTensor> *const context) {
}
}

if (input_op_partials_.count(sequential_num) > 0) {
if (input_op_partials_.find(sequential_num) != input_op_partials_.end()) {
for (auto &input_partial_pair : input_op_partials_[sequential_num]) {
GetAllDeviceTensors(input_partial_pair.second, &memory_free_list);
}


+ 1
- 1
mindspore/ccsrc/runtime/graph_scheduler/actor/control_flow/switch_actor.cc View File

@@ -87,7 +87,7 @@ size_t SwitchActor::GetIndex(const OpContext<DeviceTensor> *const context) const
char buf[kMaxSwitchCondSize] = {0};
ShapeVector host_shape;
if (!device_tensor->SyncDeviceToHost(host_shape, size, type_id, static_cast<void *>(buf))) {
MS_LOG(ERROR) << GetAID().Name() << " get index from device address failed, type id:" << std::to_string(type_id)
MS_LOG(ERROR) << GetAID().Name() << " get index from device address failed, type id:" << type_id
<< ", device type:" << std::to_string(static_cast<int>(device_contexts_[0]->GetDeviceAddressType()));
return 0;
}


Loading…
Cancel
Save