Browse Source

!15052 fix review boot

From: @zhangbuxue
Reviewed-by: @zh_qh,@ginfung
Signed-off-by: @zh_qh
pull/15052/MERGE
mindspore-ci-bot Gitee 4 years ago
parent
commit
4011fd7411
4 changed files with 28 additions and 24 deletions
  1. +0
    -1
      mindspore/ccsrc/frontend/optimizer/irpass/gradient_eliminate.h
  2. +26
    -22
      mindspore/ccsrc/pipeline/jit/static_analysis/program_specialize.cc
  3. +1
    -0
      mindspore/ccsrc/pipeline/jit/static_analysis/program_specialize.h
  4. +1
    -1
      mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc

+ 0
- 1
mindspore/ccsrc/frontend/optimizer/irpass/gradient_eliminate.h View File

@@ -31,7 +31,6 @@
namespace mindspore { namespace mindspore {
namespace opt { namespace opt {
namespace irpass { namespace irpass {

// {prim::kPrimJ, C} // {prim::kPrimJ, C}
class ExpandJPrim { class ExpandJPrim {
public: public:


+ 26
- 22
mindspore/ccsrc/pipeline/jit/static_analysis/program_specialize.cc View File

@@ -129,28 +129,7 @@ AnfNodePtr FuncGraphSpecializer::ReplicateDisconnectedNode(const AnfNodePtr &nod
if (!new_node->isa<CNode>()) { if (!new_node->isa<CNode>()) {
MS_LOG(EXCEPTION) << "new_node must be a CNode, but is " << new_node->DebugString() << "."; MS_LOG(EXCEPTION) << "new_node must be a CNode, but is " << new_node->DebugString() << ".";
} }
auto c_node = node->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_node);
auto inputs = c_node->inputs();
std::vector<AnfNodePtr> new_inputs;
(void)std::transform(
inputs.begin(), inputs.end(), std::back_inserter(new_inputs), [this](const AnfNodePtr &inp) -> AnfNodePtr {
auto new_inp = ReplicateDisconnectedNode(inp);
// Refer the comments in BuildReplacedNode.
if (inp->isa<CNode>()) {
auto c_inp = inp->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_inp);
auto c_new_inp = new_inp->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_new_inp);
MS_LOG(DEBUG) << "Replace in order, inp node: " << inp->DebugString() << " -> " << new_inp->DebugString();
c_new_inp->func_graph()->ReplaceInOrder(c_inp, c_new_inp);
}
return new_inp;
});

auto c_new_node = new_node->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_new_node);
c_new_node->set_inputs(new_inputs);
UpdateNewCNodeInputs(node, new_node);
} }


iter = specializer->repl_node_->find(node); iter = specializer->repl_node_->find(node);
@@ -164,6 +143,31 @@ AnfNodePtr FuncGraphSpecializer::ReplicateDisconnectedNode(const AnfNodePtr &nod
return new_node; return new_node;
} }


void FuncGraphSpecializer::UpdateNewCNodeInputs(const AnfNodePtr &node, const AnfNodePtr &new_node) {
auto c_node = node->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_node);
auto inputs = c_node->inputs();
std::vector<AnfNodePtr> new_inputs;
(void)std::transform(
inputs.begin(), inputs.end(), std::back_inserter(new_inputs), [this](const AnfNodePtr &inp) -> AnfNodePtr {
auto new_inp = ReplicateDisconnectedNode(inp);
// Refer the comments in BuildReplacedNode.
if (inp->isa<CNode>()) {
auto c_inp = inp->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_inp);
auto c_new_inp = new_inp->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_new_inp);
MS_LOG(DEBUG) << "Replace in order, inp node: " << inp->DebugString() << " -> " << new_inp->DebugString();
c_new_inp->func_graph()->ReplaceInOrder(c_inp, c_new_inp);
}
return new_inp;
});

auto c_new_node = new_node->cast<CNodePtr>();
MS_EXCEPTION_IF_NULL(c_new_node);
c_new_node->set_inputs(new_inputs);
}

AnfNodePtr FuncGraphSpecializer::GetReplicatedNode(const AnfNodePtr &node) { AnfNodePtr FuncGraphSpecializer::GetReplicatedNode(const AnfNodePtr &node) {
MS_EXCEPTION_IF_NULL(node); MS_EXCEPTION_IF_NULL(node);
FuncGraphPtr fg = node->func_graph(); FuncGraphPtr fg = node->func_graph();


+ 1
- 0
mindspore/ccsrc/pipeline/jit/static_analysis/program_specialize.h View File

@@ -130,6 +130,7 @@ class FuncGraphSpecializer : public std::enable_shared_from_this<FuncGraphSpecia
const EvaluatorCacheMapPtr &GetEvalCache(const EvaluatorPtr &eval); const EvaluatorCacheMapPtr &GetEvalCache(const EvaluatorPtr &eval);
// Try to build unique argvals from the broaded arg vals if it is unique. // Try to build unique argvals from the broaded arg vals if it is unique.
std::pair<AbstractBasePtrList, AbstractBasePtr> BuildFromBroadedArgsVal(const EvaluatorPtr &eval); std::pair<AbstractBasePtrList, AbstractBasePtr> BuildFromBroadedArgsVal(const EvaluatorPtr &eval);
void UpdateNewCNodeInputs(const AnfNodePtr &node, const AnfNodePtr &new_node);
}; };
} // namespace abstract } // namespace abstract
} // namespace mindspore } // namespace mindspore


+ 1
- 1
mindspore/ccsrc/runtime/device/ascend/ascend_device_address.cc View File

@@ -667,7 +667,7 @@ bool AscendDeviceAddress::DumpMemToFile(const std::string &filepath, const std::
std::string file_extension = ".bin"; std::string file_extension = ".bin";
if (trans_flag) { if (trans_flag) {
std::string path = std::string path =
filepath + '_' + shape + '_' + TypeIdToType(type_id_)->ToString() + '_' + host_fmt + file_extension;
filepath + '_' + shape + '_' + TypeIdToType(host_type)->ToString() + '_' + host_fmt + file_extension;
MS_LOG(INFO) << "E2E Dump path is " << path; MS_LOG(INFO) << "E2E Dump path is " << path;
mindspore::tensor::TensorPtr out_tensor = std::make_shared<tensor::Tensor>(host_type, host_shape); mindspore::tensor::TensorPtr out_tensor = std::make_shared<tensor::Tensor>(host_type, host_shape);
size_t host_size = out_tensor->data().nbytes(); size_t host_size = out_tensor->data().nbytes();


Loading…
Cancel
Save