forked from huawei/mindspore2022
!30920 Call Draw function directly
Merge pull request !30920 from huanghui/fix-draw
This commit is contained in:
commit
059ac45ae8
|
|
@ -656,13 +656,5 @@ void ModelDigraph::Edge(const AnfNodePtr &start, const AnfNodePtr &end, int idx,
|
|||
buffer_ << "[arrowhead=vee,";
|
||||
buffer_ << "]" << std::endl;
|
||||
}
|
||||
|
||||
struct DrawerRegister {
|
||||
DrawerRegister() {
|
||||
FuncGraph::set_drawer(
|
||||
[](const std::string &filename, const FuncGraphPtr &func_graph) { Draw(filename, func_graph); });
|
||||
}
|
||||
~DrawerRegister() = default;
|
||||
} drawer_regsiter;
|
||||
} // namespace draw
|
||||
} // namespace mindspore
|
||||
|
|
|
|||
|
|
@ -308,7 +308,7 @@ bool SubstitutionList::ApplySubstitutionsToIR(const OptimizerPtr &optimizer, con
|
|||
DumpIR(fg_name + ".ir", func_graph);
|
||||
if (MsContext::GetInstance()->get_param<int>(MS_CTX_EXECUTION_MODE) != kPynativeMode) {
|
||||
ExportIR(fg_name + ".dat", func_graph);
|
||||
func_graph->DumpFuncGraph(fg_name);
|
||||
draw::Draw(fg_name + ".dot", func_graph);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ class Optimizer : public std::enable_shared_from_this<Optimizer> {
|
|||
DumpIR(fg_name + ".ir", func_graph);
|
||||
if (MsContext::GetInstance()->get_param<int>(MS_CTX_EXECUTION_MODE) != kPynativeMode) {
|
||||
ExportIR(fg_name + ".dat", func_graph);
|
||||
func_graph->DumpFuncGraph(fg_name);
|
||||
draw::Draw(fg_name + ".dot", func_graph);
|
||||
}
|
||||
MS_LOG(DEBUG) << "Dump " << pass_names_[i] << " func graph.";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include "base/core_ops.h"
|
||||
#include "mindspore/core/utils/ms_context.h"
|
||||
#include "include/common/utils/anfalgo.h"
|
||||
#include "debug/draw.h"
|
||||
|
||||
namespace mindspore {
|
||||
namespace parallel {
|
||||
|
|
@ -220,7 +221,7 @@ void GraphSplitter::DumpDistributedGraph(const InterProcessOpEdgesInfo &comm_edg
|
|||
func_graph_->manager()->SetEdge(user_node, user_node_index, recv_node);
|
||||
}
|
||||
MS_LOG(INFO) << "Cut graph without eliminating nodes.";
|
||||
func_graph_->DumpFuncGraph("./single_node_graph.dot");
|
||||
draw::Draw("single_node_graph.dot", func_graph_);
|
||||
}
|
||||
|
||||
OperatorLabel GraphSplitter::GetSplitLabel(const AnfNodePtr &node) {
|
||||
|
|
|
|||
|
|
@ -621,7 +621,7 @@ bool OptimizeAction(const ResourcePtr &res, const std::vector<PassItem> &passes)
|
|||
MS_EXCEPTION_IF_NULL(func_graph);
|
||||
DumpIR(fg_name + ".ir", func_graph);
|
||||
ExportIR(fg_name + ".dat", func_graph);
|
||||
func_graph->DumpFuncGraph(fg_name);
|
||||
draw::Draw(fg_name + ".dot", func_graph);
|
||||
MS_LOG(DEBUG) << "Dump " << fg_name << " func graph.";
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@
|
|||
#include "include/common/utils/context/graph_kernel_flags.h"
|
||||
#include "debug/anf_ir_dump.h"
|
||||
#include "debug/dump_proto.h"
|
||||
#include "debug/draw.h"
|
||||
#ifdef ENABLE_DUMP_IR
|
||||
#include "debug/rdr/running_data_recorder.h"
|
||||
#endif
|
||||
|
|
@ -491,7 +492,7 @@ void AscendBackendOptimization(const std::shared_ptr<session::KernelGraph> &kern
|
|||
std::string file_name = "hwopt_d_end_graph_" + std::to_string(kernel_graph->graph_id()) + ".ir";
|
||||
DumpIR(file_name, kernel_graph, true, kWholeStack);
|
||||
DumpIRProto(kernel_graph, "after_hwopt_" + std::to_string(kernel_graph->graph_id()));
|
||||
kernel_graph->DumpFuncGraph("hwopt_d_end");
|
||||
draw::Draw("hwopt_d_end.dot", kernel_graph);
|
||||
}
|
||||
#endif
|
||||
PROF_END(ascend_backend_optimization);
|
||||
|
|
|
|||
|
|
@ -804,6 +804,4 @@ api::FuncGraphPtr api::FuncGraph::GetFuncGraphFromAnfNode(const AnfNodePtr &inpu
|
|||
auto fg = GetValueNode<mindspore::FuncGraphPtr>(input);
|
||||
return fg;
|
||||
}
|
||||
|
||||
FuncGraph::Drawer FuncGraph::drawer_ = nullptr;
|
||||
} // namespace mindspore
|
||||
|
|
|
|||
|
|
@ -289,8 +289,6 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
|||
|
||||
std::size_t hash() const override { return std::hash<const FuncGraph *>{}(this); }
|
||||
|
||||
void DumpFuncGraph(const std::string &path = "./func_graph.dot");
|
||||
|
||||
bool operator==(const Value &other) const override {
|
||||
if (other.isa<FuncGraph>()) {
|
||||
return &other == this;
|
||||
|
|
@ -342,7 +340,6 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
|||
|
||||
bool stub() const { return stub_; }
|
||||
void set_stub(bool stub) { stub_ = stub; }
|
||||
static void set_drawer(const Drawer &drawer) { drawer_ = drawer; }
|
||||
std::shared_ptr<bool> switch_input() const { return switch_input_; }
|
||||
void set_switch_input(const std::shared_ptr<bool> &switch_input) { switch_input_ = switch_input; }
|
||||
std::shared_ptr<bool> switch_layer_input() const { return switch_layer_input_; }
|
||||
|
|
@ -437,7 +434,6 @@ class MS_CORE_API FuncGraph : public deprecated::api::FuncGraph, public FuncGrap
|
|||
// CNode order which relates to origin code order.
|
||||
OrderedSet<CNodePtr> order_;
|
||||
bool stub_;
|
||||
static Drawer drawer_;
|
||||
// Design switch_input and switch_layer_input as a ptr to
|
||||
// share between derived backpropagator and cloned graphs.
|
||||
std::shared_ptr<bool> switch_input_;
|
||||
|
|
|
|||
|
|
@ -73,12 +73,6 @@ void FuncGraph::set_output(const AnfNodePtr &value, bool force_new_ret) {
|
|||
input0->set_abstract(f);
|
||||
}
|
||||
|
||||
void FuncGraph::DumpFuncGraph(const std::string &path) {
|
||||
if (drawer_) {
|
||||
drawer_(path + ".dot", shared_from_base<FuncGraph>());
|
||||
}
|
||||
}
|
||||
|
||||
void FuncGraph::GenerateVarParams(const FuncGraphPtr &specialized_graph, int variable_args_count,
|
||||
int pos_args_input_count, std::vector<AnfNodePtr> *specialized_parameter_list,
|
||||
mindspore::HashMap<AnfNodePtr, AnfNodePtr> *repl_nodes) const {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
# Copyright 2022 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Watchpoints test script for dump analyze_fail.dat when infer failed.
|
||||
"""
|
||||
# pylint: disable=too-many-function-args
|
||||
import os
|
||||
import pytest
|
||||
import mindspore
|
||||
from mindspore import ops, Tensor, nn
|
||||
from tests.security_utils import security_off_wrap
|
||||
|
||||
|
||||
@security_off_wrap
|
||||
def test_infer_fail_generate_analyze_fail_dat():
|
||||
"""
|
||||
Feature: test dump analyze_fail.dat.
|
||||
Description: test dump analyze_fail.dat if infer failed.
|
||||
Expectation: success.
|
||||
"""
|
||||
|
||||
class Net(nn.Cell):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.add = ops.Add()
|
||||
self.sub = ops.Sub()
|
||||
self.mul = ops.Mul()
|
||||
self.div = ops.Div()
|
||||
|
||||
def func(self, x, y):
|
||||
return self.div(x, y)
|
||||
|
||||
def construct(self, x, y):
|
||||
a = self.sub(x, 1)
|
||||
b = self.add(a, y)
|
||||
c = self.mul(b, self.func(a, a, b))
|
||||
return c
|
||||
|
||||
input1 = Tensor(3, mindspore.float32)
|
||||
input2 = Tensor(2, mindspore.float32)
|
||||
net = Net()
|
||||
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
net(input1, input2)
|
||||
assert "rank_0/om/analyze_fail.dat" in str(excinfo.value)
|
||||
assert os.path.exists("./rank_0/om/analyze_fail.dat") is True
|
||||
Loading…
Reference in New Issue