Browse Source

adjust dynamic shape attr

Signed-off-by: zhupuxu <zhupuxu@huawei.com>
feature/build-system-rewrite
zhupuxu 4 years ago
parent
commit
506dd2f47e
19 changed files with 58 additions and 64 deletions
  1. +2
    -3
      mindspore/ccsrc/backend/common/pass/add_dynamic_shape_attr.cc
  2. +35
    -26
      mindspore/ccsrc/backend/common/session/anf_runtime_algorithm.cc
  3. +0
    -1
      mindspore/ccsrc/backend/common/session/anf_runtime_algorithm.h
  4. +2
    -2
      mindspore/ccsrc/common/graph_kernel/core/graph_kernel_utils.cc
  5. +1
    -1
      mindspore/ccsrc/pipeline/jit/action.cc
  6. +9
    -0
      mindspore/ccsrc/plugin/device/ascend/hal/device/kernel_build_ascend.cc
  7. +1
    -1
      mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_adapter.h
  8. +1
    -11
      mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_dynaminc_shape_util.cc
  9. +0
    -1
      mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_dynaminc_shape_util.h
  10. +0
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/ascend_helper.cc
  11. +2
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/enhancer/insert_tensor_move_for_cascade.cc
  12. +2
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/enhancer/insert_tensor_move_for_getnext.cc
  13. +2
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/enhancer/insert_tensor_move_for_hccl_op.cc
  14. +0
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_grad_split.cc
  15. +0
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_split.cc
  16. +0
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/gather_v2_ds_fission.cc
  17. +0
    -2
      mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/layer_norm_grad_split.cc
  18. +1
    -1
      mindspore/ccsrc/plugin/device/ascend/optimizer/mindir/update_input_names_strided_slice_grad.cc
  19. +0
    -1
      mindspore/ccsrc/plugin/device/cpu/optimizer/insert_cast_cpu.cc

+ 2
- 3
mindspore/ccsrc/backend/common/pass/add_dynamic_shape_attr.cc View File

@@ -26,9 +26,8 @@ const AnfNodePtr AddDynamicShapeAttr::Process(const FuncGraphPtr &func_graph, co
const EquivPtr &) const {
MS_EXCEPTION_IF_NULL(func_graph);
MS_EXCEPTION_IF_NULL(node);
if (AnfAlgo::IsNodeDynamicShape(node)) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), node);
MS_LOG(INFO) << "Set Dynamic Shape Attr to Node:" << node->fullname_with_scope();
if (AnfAlgo::IsDynamicShape(node)) {
MS_LOG(DEBUG) << "Set Dynamic Shape Attr to Node:" << node->fullname_with_scope();
auto kernel_graph = func_graph->cast<KernelGraphPtr>();
MS_EXCEPTION_IF_NULL(kernel_graph);
kernel_graph->SetGraphDynamicAttr(true);


+ 35
- 26
mindspore/ccsrc/backend/common/session/anf_runtime_algorithm.cc View File

@@ -236,6 +236,26 @@ std::vector<KernelWithIndex> GetAllOutputWithIndexInner(const AnfNodePtr &node)
}
return ret;
}

bool IsNodeDynamicShape(const AnfNodePtr &node) {
MS_EXCEPTION_IF_NULL(node);
if (!node->isa<CNode>()) {
MS_LOG(DEBUG) << "Node is not a cnode";
return false;
}
auto cnode = node->cast<CNodePtr>();
auto in_dynamic = AnfAlgo::IsNodeInputDynamicShape(cnode);
auto out_dynamic = AnfUtils::IsNodeOutputDynamicShape(cnode);
if (in_dynamic && !AnfAlgo::HasNodeAttr(kAttrInputIsDynamicShape, cnode)) {
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), cnode);
MS_LOG(DEBUG) << "Set Input Dynamic Shape Attr to Node:" << cnode->fullname_with_scope();
}
if (out_dynamic && !AnfAlgo::HasNodeAttr(kAttrOutputIsDynamicShape, cnode)) {
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), cnode);
MS_LOG(DEBUG) << "Set Output Dynamic Shape Attr to Node:" << cnode->fullname_with_scope();
}
return in_dynamic || out_dynamic;
}
} // namespace

AnfNodePtr AnfRuntimeAlgorithm::MakeMonadValueNode(const KernelGraphPtr &kg) {
@@ -1573,7 +1593,7 @@ size_t AnfRuntimeAlgorithm::GetRealInputIndex(const mindspore::AnfNodePtr &anf_n
size_t ret = cur_index;
auto node_name = AnfAlgo::GetCNodeName(anf_node);
if (AnfAlgo::GetKernelType(anf_node) == TBE_KERNEL) {
if (AnfAlgo::IsNodeDynamicShape(anf_node) || AnfAlgo::IsDynamicShape(anf_node)) {
if (IsDynamicShape(anf_node)) {
auto find_dynamic = spec_dynamic_node_list.find(node_name);
if (find_dynamic != spec_dynamic_node_list.end()) {
auto dyn_index_converter = find_dynamic->second;
@@ -1597,7 +1617,7 @@ size_t AnfRuntimeAlgorithm::GetOriginalInputIndex(const mindspore::AnfNodePtr &a
size_t ret = cur_index;
auto node_name = AnfAlgo::GetCNodeName(anf_node);
if (AnfAlgo::GetKernelType(anf_node) == TBE_KERNEL) {
if (AnfAlgo::IsNodeDynamicShape(anf_node) || AnfAlgo::IsDynamicShape(anf_node)) {
if (IsDynamicShape(anf_node)) {
auto find_dynamic = spec_dynamic_node_list.find(node_name);
if (find_dynamic != spec_dynamic_node_list.end()) {
auto dyn_index_converter = find_dynamic->second;
@@ -2004,13 +2024,22 @@ bool AnfRuntimeAlgorithm::HasDynamicShapeFlag(const PrimitivePtr &prim) {
}
return GetValue<bool>(primitive->GetAttr(attr_name));
};
return get_bool_attr(prim, kAttrInputIsDynamicShape) || get_bool_attr(prim, kAttrOutputIsDynamicShape) ||
get_bool_attr(prim, kAttrIsDynamicShape);
return get_bool_attr(prim, kAttrInputIsDynamicShape) || get_bool_attr(prim, kAttrOutputIsDynamicShape);
}

bool AnfRuntimeAlgorithm::IsDynamicShape(const AnfNodePtr &node) {
return GetBooleanAttr(node, kAttrInputIsDynamicShape) || GetBooleanAttr(node, kAttrOutputIsDynamicShape) ||
GetBooleanAttr(node, kAttrIsDynamicShape);
MS_EXCEPTION_IF_NULL(node);
if (!node->isa<CNode>()) {
MS_LOG(DEBUG) << "Node is not a cnode.";
return false;
}
auto cnode = node->cast<CNodePtr>();
if ((!HasNodeAttr(kAttrInputIsDynamicShape, cnode)) && (!HasNodeAttr(kAttrOutputIsDynamicShape, cnode))) {
auto ret = IsNodeDynamicShape(node);
MS_LOG(DEBUG) << "The Node:" << node->fullname_with_scope() << " is dynamic shape or not:" << ret;
return ret;
}
return GetBooleanAttr(node, kAttrInputIsDynamicShape) || GetBooleanAttr(node, kAttrOutputIsDynamicShape);
}

void AnfRuntimeAlgorithm::GetRealDynamicShape(const std::vector<size_t> &shape,
@@ -2128,26 +2157,6 @@ bool AnfRuntimeAlgorithm::IsNodeInputDynamicShape(const CNodePtr &anf_node_ptr)
return false;
}

bool AnfRuntimeAlgorithm::IsNodeDynamicShape(const AnfNodePtr &node) {
MS_EXCEPTION_IF_NULL(node);
if (!node->isa<CNode>()) {
MS_LOG(DEBUG) << "Node is not a cnode";
return false;
}
auto cnode = node->cast<CNodePtr>();
auto in_dynamic = IsNodeInputDynamicShape(cnode);
auto out_dynamic = AnfUtils::IsNodeOutputDynamicShape(cnode);
if (in_dynamic && !AnfAlgo::HasNodeAttr(kAttrInputIsDynamicShape, cnode)) {
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), cnode);
MS_LOG(INFO) << "Set Input Dynamic Shape Attr to Node:" << cnode->fullname_with_scope();
}
if (out_dynamic && !AnfAlgo::HasNodeAttr(kAttrOutputIsDynamicShape, cnode)) {
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), cnode);
MS_LOG(INFO) << "Set Output Dynamic Shape Attr to Node:" << cnode->fullname_with_scope();
}
return in_dynamic || out_dynamic;
}

std::vector<size_t> AnfRuntimeAlgorithm::GetInputRealDeviceShapeIfExist(const AnfNodePtr &anf_node, size_t index) {
auto device_shape = GetInputDeviceShape(anf_node, index);
// Initialize GPUKernel with max shape to fit 'InitDynamicOutputKernelRef()' for memory reuse.


+ 0
- 1
mindspore/ccsrc/backend/common/session/anf_runtime_algorithm.h View File

@@ -300,7 +300,6 @@ class AnfRuntimeAlgorithm {
static std::vector<int64_t> GetInputMinShape(const AnfNodePtr &anf_node, size_t index);
static std::vector<int64_t> GetOutputMaxShape(const AnfNodePtr &anf_node, size_t index);
static std::vector<int64_t> GetOutputMinShape(const AnfNodePtr &anf_node, size_t index);
static bool IsNodeDynamicShape(const AnfNodePtr &node);
static bool IsHostKernel(const CNodePtr &node);
static void InferShape(const CNodePtr &node, std::map<uint32_t, tensor::TensorPtr> *depend_tensors = nullptr);
// return true if use cnode_input's abstract, false if use real_input's abstract


+ 2
- 2
mindspore/ccsrc/common/graph_kernel/core/graph_kernel_utils.cc View File

@@ -104,8 +104,8 @@ bool GkUtils::IsKeepBasicNode(const AnfNodePtr &node) {
// dynamic shape nodes is not supported yet.
// the "skip" is used by inplace node.
// the kAttrIsInternalOutputNopNode is used by internal output of KernelGraph.
const std::vector<std::string> exclude_bool_attrs = {kAttrInputIsDynamicShape, kAttrOutputIsDynamicShape,
kAttrIsDynamicShape, "skip", kAttrIsInternalOutputNopNode};
const std::vector<std::string> exclude_bool_attrs = {kAttrInputIsDynamicShape, kAttrOutputIsDynamicShape, "skip",
kAttrIsInternalOutputNopNode};
if (std::any_of(exclude_bool_attrs.cbegin(), exclude_bool_attrs.cend(), [&prim](const std::string &attr_name) {
return prim->HasAttr(attr_name) && GetValue<bool>(prim->GetAttr(attr_name));
})) {


+ 1
- 1
mindspore/ccsrc/pipeline/jit/action.cc View File

@@ -88,7 +88,7 @@ bool IsDynamicShapeGraph(FuncGraphPtr func_graph) {
MS_EXCEPTION_IF_NULL(func_graph);
std::vector<AnfNodePtr> node_list = TopoSort(func_graph->get_return());
return std::any_of(node_list.begin(), node_list.end(),
[](const AnfNodePtr &node) { return AnfAlgo::IsNodeDynamicShape(node); });
[](const AnfNodePtr &node) { return AnfAlgo::IsDynamicShape(node); });
}

// Disable mindRT in the heterogeneous scenario + dynamic_shape scenario.


+ 9
- 0
mindspore/ccsrc/plugin/device/ascend/hal/device/kernel_build_ascend.cc View File

@@ -262,6 +262,9 @@ void InsertFusionAtomicOp(const CNodePtr &first_clear_node, const std::vector<An
auto clear_zero = NewAtomicOp(first_clear_node, fusion_clear_inputs);
AnfAlgo::SetNodeAttr(kAttrAtomicAddMemSize, MakeValue(clean_size_list), clear_zero);
AnfAlgo::SetStreamDistinctionLabel(AnfAlgo::GetStreamDistinctionLabel(first_clear_node.get()), clear_zero.get());
MS_LOG(DEBUG) << "The AtomicClean currently does not support dynamic shape.";
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(false), clear_zero);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(false), clear_zero);
(*clean_ops)[first_clear_node].emplace_back(clear_zero);
}

@@ -272,6 +275,9 @@ void InsertAtomicOpForNormalOp(const mindspore::CNodePtr &pre_node, CleanOpsMap
auto clean_size = GetClearSize(pre_node);
AnfAlgo::SetNodeAttr(kAttrAtomicAddMemSize, MakeValue(clean_size), clear_zero);
AnfAlgo::SetStreamDistinctionLabel(AnfAlgo::GetStreamDistinctionLabel(pre_node.get()), clear_zero.get());
MS_LOG(DEBUG) << "The AtomicClean currently does not support dynamic shape.";
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(false), clear_zero);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(false), clear_zero);
(*clean_ops)[pre_node].emplace_back(clear_zero);
}

@@ -299,6 +305,9 @@ void SpecialAkgOps(const std::string &op_name, const CNodePtr &node, CleanOpsMap
SelectKernelInfo(clear_zero);
// set the distinction label of clear same with anf
AnfAlgo::SetStreamDistinctionLabel(AnfAlgo::GetStreamDistinctionLabel(node.get()), clear_zero.get());
MS_LOG(DEBUG) << "The AtomicClean currently does not support dynamic shape.";
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(false), clear_zero);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(false), clear_zero);
(*clean_ops)[node].emplace_back(clear_zero);
}
}


+ 1
- 1
mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_adapter.h View File

@@ -119,7 +119,7 @@ class TbeAdapter {
template <typename T>
static bool DynamicInputAdjusted(const std::shared_ptr<AnfNode> &anf_node, std::vector<T> const &inputs_list,
std::vector<T> *inputs_json) {
if (!AnfAlgo::IsNodeDynamicShape(anf_node) && !AnfAlgo::IsDynamicShape(anf_node)) {
if (!AnfAlgo::IsDynamicShape(anf_node)) {
return false;
}
auto op_name = AnfAlgo::GetCNodeName(anf_node);


+ 1
- 11
mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_dynaminc_shape_util.cc View File

@@ -57,12 +57,6 @@ bool TbeDynamicShapeUtil::IsDynamicShapeNode(const AnfNodePtr &anf_node) {
return false;
}

void TbeDynamicShapeUtil::SetDynamicShapeAttr(const CNodePtr &cnode) {
MS_EXCEPTION_IF_NULL(cnode);
auto is_dyanmic_shape = IsDynamicShapeNode(cnode);
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(is_dyanmic_shape), cnode);
}

bool TbeDynamicShapeUtil::GetDynamicShapeAttr(const AnfNodePtr &anf_node) {
MS_EXCEPTION_IF_NULL(anf_node);
if (anf_node->isa<CNode>()) {
@@ -75,11 +69,7 @@ bool TbeDynamicShapeUtil::GetDynamicShapeAttr(const AnfNodePtr &anf_node) {

bool TbeDynamicShapeUtil::GetDynamicShapeAttr(const CNodePtr &cnode) {
MS_EXCEPTION_IF_NULL(cnode);
auto is_dynamic_shape = AnfAlgo::HasNodeAttr(kAttrIsDynamicShape, cnode);
if (!is_dynamic_shape) {
return false;
}
is_dynamic_shape = AnfAlgo::GetNodeAttr<bool>(cnode, kAttrIsDynamicShape);
auto is_dynamic_shape = AnfAlgo::IsDynamicShape(cnode);
return is_dynamic_shape;
}



+ 0
- 1
mindspore/ccsrc/plugin/device/ascend/kernel/tbe/tbe_dynaminc_shape_util.h View File

@@ -34,7 +34,6 @@ class TbeDynamicShapeUtil {
~TbeDynamicShapeUtil() = default;
static bool IsDynamicShapeNode(const CNodePtr &cnode);
static bool IsDynamicShapeNode(const AnfNodePtr &anf_node);
static void SetDynamicShapeAttr(const CNodePtr &cnode);
static bool GetDynamicShapeAttr(const CNodePtr &cnode);
static bool GetDynamicShapeAttr(const AnfNodePtr &anf_node);
static std::shared_ptr<OpInfo> FindOp(const std::string &op_name, const AnfNodePtr &anf_node);


+ 0
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/ascend_helper.cc View File

@@ -330,7 +330,6 @@ CNodePtr NewTransOpNode(const FuncGraphPtr &func_graph, const AnfNodePtr &input,
AnfAlgo::SetNodeAttr(kAttrPerm, MakeValue(perm), trans_node);
}
if (is_dynamic_shape) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), trans_node);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), trans_node);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), trans_node);
}
@@ -373,7 +372,6 @@ CNodePtr AddCastOpNodeToGraph(const FuncGraphPtr &func_graph, const AnfNodePtr &
cast->set_kernel_info(kernel_info);
}
if (origin_shape->IsDynamic()) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), cast);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), cast);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), cast);
}


+ 2
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/enhancer/insert_tensor_move_for_cascade.cc View File

@@ -82,8 +82,8 @@ AnfNodePtr InsertTensorMoveForCascade::InsertTensorMove(const FuncGraphPtr &grap
if (tensor_move == nullptr) {
MS_LOG(EXCEPTION) << "Create tensor_move op failed." << trace::DumpSourceLines(hccl_node);
}
if (AnfAlgo::IsNodeDynamicShape(input)) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), tensor_move);
if (AnfAlgo::IsDynamicShape(input)) {
MS_LOG(DEBUG) << "The tenser move op has dynamic shape attr.";
}
auto kernel_info = std::make_shared<device::KernelInfo>();
tensor_move->set_kernel_info(kernel_info);


+ 2
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/enhancer/insert_tensor_move_for_getnext.cc View File

@@ -43,8 +43,8 @@ AnfNodePtr InsertTensorMoveForGetNextOutputs(const FuncGraphPtr &func_graph, con
if (new_node == nullptr) {
MS_LOG(EXCEPTION) << "Create tensor move op failed!";
}
if (AnfAlgo::IsNodeDynamicShape(tuple_get_item)) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), new_node);
if (AnfAlgo::IsDynamicShape(tuple_get_item)) {
MS_LOG(DEBUG) << "The tenser move op has dynamic shape attr.";
}
AnfAlgo::SetNodeAttr(kAttrLabelForInsertStreamActive, MakeValue(true), new_node);
make_tuple_inputs.push_back(new_node);


+ 2
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/enhancer/insert_tensor_move_for_hccl_op.cc View File

@@ -123,8 +123,8 @@ void InsertTensorMoveForHcclOp::InsertTensorMove(const FuncGraphPtr &graph, cons
if (tensor_move == nullptr) {
MS_LOG(EXCEPTION) << "Create tensor_move op failed.";
}
if (input->isa<CNode>() && AnfAlgo::IsNodeDynamicShape(input)) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), tensor_move);
if (input->isa<CNode>() && AnfAlgo::IsDynamicShape(input)) {
MS_LOG(DEBUG) << "The tenser move op has dynamic shape attr.";
}
new_inputs.push_back(tensor_move);
need_tensor_move_async = true;


+ 0
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_grad_split.cc View File

@@ -49,7 +49,6 @@ void BnGradSplit::CreateOutputsOfUpdateGrad(const FuncGraphPtr &graph, const CNo
AnfAlgo::CopyNodeAttr(kAttrEpsilon, bn_grad_node, bn_update_grad);
AnfAlgo::CopyNodeAttr(kAttrFormat, bn_grad_node, bn_update_grad);
if (is_dynamic) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), bn_update_grad);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), bn_update_grad);
}
CreateMultipleOutputsOfAnfNode(graph, bn_update_grad, kBNTrainingUpdateGradOutputNum, bn_update_grad_outputs);
@@ -87,7 +86,6 @@ void BnGradSplit::CreateOutputsOfReduceGrad(const FuncGraphPtr &graph, const CNo
AnfAlgo::CopyNodeAttr(kAttrEpsilon, bn_grad_node, bn_reduce_grad);
AnfAlgo::CopyNodeAttr(kAttrFormat, bn_grad_node, bn_reduce_grad);
if (is_dynamic) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), bn_reduce_grad);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), bn_reduce_grad);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), bn_reduce_grad);
}


+ 0
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/bn_split.cc View File

@@ -58,7 +58,6 @@ bool BnSplit::CreateOutputsOfBNTrainingReduce(const FuncGraphPtr &graph, const C
AnfAlgo::SetOutputTypeAndDetailShape(types, shapes, bn_training_reduce.get());
bn_training_reduce->set_scope(bn_cnode->scope());
if (is_dynamic) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), bn_training_reduce);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), bn_training_reduce);
}
AnfAlgo::CopyNodeAttrs(bn_cnode, bn_training_reduce);
@@ -96,7 +95,6 @@ AnfNodePtr BnSplit::CreateOutputsOfBNTrainingUpdate(const FuncGraphPtr &graph, c
auto factor = AnfAlgo::GetNodeAttr<float>(bn_cnode, kAttrMomentum);
AnfAlgo::SetNodeAttr(kAttrFactor, MakeValue<float>(factor), bn_training_update);
if (is_dynamic) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), bn_training_update);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), bn_training_update);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), bn_training_update);
}


+ 0
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/gather_v2_ds_fission.cc View File

@@ -105,7 +105,6 @@ CNodePtr GatherV2DsFission::CreatePad(const FuncGraphPtr &graph, const CNodePtr
elements.push_back(last_padding_value);
ValueTuplePtr paddings = std::make_shared<ValueTuple>(elements);
AnfAlgo::SetNodeAttr(kAttrPaddings, paddings, pad);
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), pad);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), pad);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), pad);
return pad;
@@ -130,7 +129,6 @@ CNodePtr GatherV2DsFission::CreateGatherV2Ds(const FuncGraphPtr &graph, const CN
auto shape = AnfAlgo::GetOutputInferShape(origin_node, 0);
shape[shape.size() - 1] = pad_dim_size;
AnfAlgo::SetOutputInferTypeAndShape({AnfAlgo::GetOutputInferDataType(origin_node, 0)}, {shape}, gather_v2.get());
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), gather_v2);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), gather_v2);
auto input_names = AnfAlgo::GetNodeAttr<std::vector<std::string>>(origin_node, kAttrInputNames);
AnfAlgo::SetNodeAttr(kAttrInputNames, MakeValue(input_names), gather_v2);


+ 0
- 2
mindspore/ccsrc/plugin/device/ascend/optimizer/ir_fission/layer_norm_grad_split.cc View File

@@ -50,7 +50,6 @@ void LayerNormGradSplit::CreateOutputsOfLayerNormXBackpropV2(const FuncGraphPtr
auto shapes = {AnfAlgo::GetOutputDetailShape(layer_norm_grad, 0),
AnfAlgo::GetPrevNodeOutputDetailShape(layer_norm_grad, 1)};
if (is_dynamic) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), layer_norm_x_backprop);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), layer_norm_x_backprop);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), layer_norm_x_backprop);
}
@@ -74,7 +73,6 @@ void LayerNormGradSplit::CreateOutputsOfLayerNormBetaGammaBackpropV2(
layer_norm_beta_gamma_backprop->set_kernel_info(kernel_info);
layer_norm_beta_gamma_backprop->set_scope(layer_norm_grad->scope());
if (is_dynamic) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), layer_norm_beta_gamma_backprop);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), layer_norm_beta_gamma_backprop);
}
auto types = {AnfAlgo::GetOutputInferDataType(layer_norm_grad, kLayerNormGradOutputGammaIndex),


+ 1
- 1
mindspore/ccsrc/plugin/device/ascend/optimizer/mindir/update_input_names_strided_slice_grad.cc View File

@@ -37,7 +37,7 @@ const AnfNodePtr StridedSliceGradUpdateInputNames::Process(const FuncGraphPtr &g
MS_EXCEPTION_IF_NULL(strided_slice_grad);

const size_t shapex_index = 1;
if (AnfAlgo::IsNodeDynamicShape(strided_slice_grad)) {
if (AnfAlgo::IsDynamicShape(strided_slice_grad)) {
auto primitive = AnfAlgo::GetCNodePrimitive(strided_slice_grad);
MS_EXCEPTION_IF_NULL(primitive);
auto input_names_ptr = primitive->GetAttr(kAttrInputNames);


+ 0
- 1
mindspore/ccsrc/plugin/device/cpu/optimizer/insert_cast_cpu.cc View File

@@ -54,7 +54,6 @@ AnfNodePtr AddCastOpNodeToGraph(const FuncGraphPtr &func_graph, const AnfNodePtr
cast->set_kernel_info(kernel_info);
}
if (origin_shape->IsDynamic()) {
AnfAlgo::SetNodeAttr(kAttrIsDynamicShape, MakeValue(true), cast);
AnfAlgo::SetNodeAttr(kAttrInputIsDynamicShape, MakeValue(true), cast);
AnfAlgo::SetNodeAttr(kAttrOutputIsDynamicShape, MakeValue(true), cast);
}


Loading…
Cancel
Save