update clang format rule

pull/552/head
zhoufeng 5 years ago
parent 31a12009dd
commit c2b3360d69

@ -94,7 +94,7 @@ PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Left
PointerAlignment: Right
RawStringFormats:
- Language: Cpp
Delimiters:

@ -23,7 +23,7 @@ namespace common {
const int CACHED_STR_NUM = 1 << 8;
const int CACHED_STR_MASK = CACHED_STR_NUM - 1;
std::vector<std::string> STR_HOLDER(CACHED_STR_NUM);
const char* SafeCStr(const std::string&& str) {
const char *SafeCStr(const std::string &&str) {
static std::atomic<uint32_t> index{0};
uint32_t cur_index = index++;
cur_index = cur_index & CACHED_STR_MASK;

@ -21,16 +21,16 @@
#include <string>
#define DISABLE_COPY_AND_ASSIGN(ClassType) \
ClassType(const ClassType&) = delete; \
ClassType& operator=(const ClassType&) = delete;
ClassType(const ClassType &) = delete; \
ClassType &operator=(const ClassType &) = delete;
namespace mindspore {
namespace common {
inline const char* SafeCStr(const std::string& str) { return str.c_str(); }
const char* SafeCStr(const std::string&& str);
inline const char *SafeCStr(const std::string &str) { return str.c_str(); }
const char *SafeCStr(const std::string &&str);
static inline std::string GetEnv(const std::string& envvar) {
const char* value = ::getenv(envvar.c_str());
static inline std::string GetEnv(const std::string &envvar) {
const char *value = ::getenv(envvar.c_str());
if (value == nullptr) {
return std::string();

@ -34,11 +34,11 @@ class DecodeOp : public TensorOp {
~DecodeOp() = default;
Status Compute(const std::shared_ptr<Tensor>& input, std::shared_ptr<Tensor>* output) override;
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
void Print(std::ostream& out) const override { out << "DecodeOp"; }
Status OutputShape(const std::vector<TensorShape>& inputs, std::vector<TensorShape>& outputs) override;
Status OutputType(const std::vector<DataType>& inputs, std::vector<DataType>& outputs) override;
void Print(std::ostream &out) const override { out << "DecodeOp"; }
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override;
private:
bool is_rgb_format_ = true;

@ -37,8 +37,8 @@ DistortBoundingBoxCropOp::DistortBoundingBoxCropOp(float aspect_ratio, float int
rnd_.seed(seed_);
}
Status DistortBoundingBoxCropOp::Compute(const std::vector<std::shared_ptr<Tensor>>& input,
std::vector<std::shared_ptr<Tensor>>* output) {
Status DistortBoundingBoxCropOp::Compute(const std::vector<std::shared_ptr<Tensor>> &input,
std::vector<std::shared_ptr<Tensor>> *output) {
IO_CHECK_VECTOR(input, output);
if (input.size() != NumInput())
return Status(StatusCode::kUnexpectedError, __LINE__, __FILE__, "Number of inputs is not 5");
@ -98,8 +98,8 @@ Status DistortBoundingBoxCropOp::Compute(const std::vector<std::shared_ptr<Tenso
return Status::OK();
}
Status DistortBoundingBoxCropOp::OutputShape(const std::vector<TensorShape>& inputs,
std::vector<TensorShape>& outputs) {
Status DistortBoundingBoxCropOp::OutputShape(const std::vector<TensorShape> &inputs,
std::vector<TensorShape> &outputs) {
RETURN_IF_NOT_OK(TensorOp::OutputShape(inputs, outputs));
outputs.clear();
TensorShape out = TensorShape{-1, -1};
@ -108,7 +108,7 @@ Status DistortBoundingBoxCropOp::OutputShape(const std::vector<TensorShape>& inp
if (!outputs.empty()) return Status::OK();
return Status(StatusCode::kUnexpectedError, "Input has a wrong shape");
}
Status DistortBoundingBoxCropOp::OutputType(const std::vector<DataType>& inputs, std::vector<DataType>& outputs) {
Status DistortBoundingBoxCropOp::OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) {
RETURN_IF_NOT_OK(TensorOp::OutputType(inputs, outputs));
outputs[0] = inputs[0];
return Status::OK();

@ -45,16 +45,16 @@ class DistortBoundingBoxCropOp : public TensorOp {
~DistortBoundingBoxCropOp() override = default;
void Print(std::ostream& out) const override {
void Print(std::ostream &out) const override {
out << "DistortBoundingBoxCropOp: " << max_attempts_ << " " << intersect_ratio_;
}
Status Compute(const std::vector<std::shared_ptr<Tensor>>& input,
std::vector<std::shared_ptr<Tensor>>* output) override;
Status Compute(const std::vector<std::shared_ptr<Tensor>> &input,
std::vector<std::shared_ptr<Tensor>> *output) override;
uint32_t NumInput() override { return 5; }
Status OutputShape(const std::vector<TensorShape>& inputs, std::vector<TensorShape>& outputs) override;
Status OutputType(const std::vector<DataType>& inputs, std::vector<DataType>& outputs) override;
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override;
private:
int32_t max_attempts_;

@ -41,7 +41,7 @@ RandomCropAndResizeOp::RandomCropAndResizeOp(int32_t target_height, int32_t targ
rnd_.seed(GetSeed());
}
Status RandomCropAndResizeOp::Compute(const std::shared_ptr<Tensor>& input, std::shared_ptr<Tensor>* output) {
Status RandomCropAndResizeOp::Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) {
IO_CHECK(input, output);
CHECK_FAIL_RETURN_UNEXPECTED(input->shape().Size() >= 2, "The shape of input is abnormal");
@ -54,7 +54,7 @@ Status RandomCropAndResizeOp::Compute(const std::shared_ptr<Tensor>& input, std:
(void)GetCropBox(h_in, w_in, &x, &y, &crop_height, &crop_width);
return CropAndResize(input, output, x, y, crop_height, crop_width, target_height_, target_width_, interpolation_);
}
Status RandomCropAndResizeOp::OutputShape(const std::vector<TensorShape>& inputs, std::vector<TensorShape>& outputs) {
Status RandomCropAndResizeOp::OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) {
RETURN_IF_NOT_OK(TensorOp::OutputShape(inputs, outputs));
outputs.clear();
TensorShape out = TensorShape{target_height_, target_width_};
@ -63,7 +63,7 @@ Status RandomCropAndResizeOp::OutputShape(const std::vector<TensorShape>& inputs
if (!outputs.empty()) return Status::OK();
return Status(StatusCode::kUnexpectedError, "Input has a wrong shape");
}
Status RandomCropAndResizeOp::GetCropBox(int h_in, int w_in, int* x, int* y, int* crop_height, int* crop_width) {
Status RandomCropAndResizeOp::GetCropBox(int h_in, int w_in, int *x, int *y, int *crop_height, int *crop_width) {
double scale, aspect;
*crop_width = w_in;
*crop_height = h_in;

@ -22,7 +22,7 @@
namespace mindspore {
constexpr char PARALLEL_STRATEGY[] = "strategy";
void DumpIR(const std::string& filename, const FuncGraphPtr& func_graph, bool dump_full_name = false);
void DumpIR(const std::string &filename, const FuncGraphPtr &func_graph, bool dump_full_name = false);
} // namespace mindspore

File diff suppressed because it is too large Load Diff

@ -39,7 +39,7 @@
namespace mindspore {
struct ParamPtrEqual {
bool operator()(AnfNodePtr const& t1, AnfNodePtr const& t2) const {
bool operator()(AnfNodePtr const &t1, AnfNodePtr const &t2) const {
const ParameterPtr param1 = dyn_cast<Parameter>(t1);
const ParameterPtr param2 = dyn_cast<Parameter>(t2);
@ -52,7 +52,7 @@ struct ParamPtrEqual {
};
struct ParamPtrHasher {
std::size_t operator()(AnfNodePtr const& param) const {
std::size_t operator()(AnfNodePtr const &param) const {
const ParameterPtr parameter = dyn_cast<Parameter>(param);
if (parameter == nullptr) {
return 0;
@ -64,39 +64,39 @@ struct ParamPtrHasher {
class AnfExporter {
public:
explicit AnfExporter(const std::string& id, bool export_used = true, bool check_integrity = false)
explicit AnfExporter(const std::string &id, bool export_used = true, bool check_integrity = false)
: param_index(-1), id_(id), export_used_(export_used), check_integrity_(check_integrity) {
func_graph_set.clear();
exported.clear();
}
virtual ~AnfExporter() {}
void ExportFuncGraph(const std::string& filename, const FuncGraphPtr& func_graph);
void ExportFuncGraph(const std::string& filename, const std::vector<TaggedGraph>& graphs);
void ExportFuncGraph(const std::string &filename, const FuncGraphPtr &func_graph);
void ExportFuncGraph(const std::string &filename, const std::vector<TaggedGraph> &graphs);
protected:
virtual std::string GetNodeType(const AnfNodePtr& nd);
int GetParamIndex(const FuncGraphPtr& func_graph, const AnfNodePtr& param, bool throw_excp = true);
int GetParamIndexFromExported(const AnfNodePtr& param);
std::string DumpObject(const py::object& obj, const std::string& category) const;
std::string GetValueNodeText(const FuncGraphPtr& func_graph, const ValueNodePtr& node);
std::string GetMultitypeFuncGraphText(const prim::MultitypeFuncGraphPtr& mt_func_graph);
std::string GetSymbolicKeyInstanceText(const FuncGraphPtr& func_graph, const SymbolicKeyInstancePtr& sym_inst);
std::string GetSequenceText(const FuncGraphPtr& func_graph, const ValuePtr& value);
std::string GetValueText(const FuncGraphPtr& func_graph, const ValuePtr& value);
std::string GetOtherValueText(const FuncGraphPtr& func_graph, const ValuePtr& value);
std::string GetPrimitiveText(const PrimitivePtr& prim);
std::string GetDictText(const FuncGraphPtr& func_graph, const ValuePtr& value);
std::string GetNameSpaceText(const parse::NameSpacePtr& ns);
std::string GetMetaFuncGraphText(const MetaFuncGraphPtr& meta_func_graph);
std::string GetAnfNodeText(const FuncGraphPtr& func_graph, const AnfNodePtr& node,
const std::map<AnfNodePtr, int>& apply_map);
void ExportOneFuncGraph(std::ofstream& ofs, const FuncGraphPtr& func_graph);
void OutputParameters(std::ofstream& ofs, const std::vector<AnfNodePtr>& parameters,
OrderedMap<AnfNodePtr, int, ParamPtrHasher, ParamPtrEqual>* param_map);
void OutputStatementComment(std::ofstream& ofs, const CNodePtr& node);
void OutputCNodes(std::ofstream& ofs, const std::vector<AnfNodePtr>& nodes, const FuncGraphPtr& func_graph);
virtual std::string GetNodeType(const AnfNodePtr &nd);
int GetParamIndex(const FuncGraphPtr &func_graph, const AnfNodePtr &param, bool throw_excp = true);
int GetParamIndexFromExported(const AnfNodePtr &param);
std::string DumpObject(const py::object &obj, const std::string &category) const;
std::string GetValueNodeText(const FuncGraphPtr &func_graph, const ValueNodePtr &node);
std::string GetMultitypeFuncGraphText(const prim::MultitypeFuncGraphPtr &mt_func_graph);
std::string GetSymbolicKeyInstanceText(const FuncGraphPtr &func_graph, const SymbolicKeyInstancePtr &sym_inst);
std::string GetSequenceText(const FuncGraphPtr &func_graph, const ValuePtr &value);
std::string GetValueText(const FuncGraphPtr &func_graph, const ValuePtr &value);
std::string GetOtherValueText(const FuncGraphPtr &func_graph, const ValuePtr &value);
std::string GetPrimitiveText(const PrimitivePtr &prim);
std::string GetDictText(const FuncGraphPtr &func_graph, const ValuePtr &value);
std::string GetNameSpaceText(const parse::NameSpacePtr &ns);
std::string GetMetaFuncGraphText(const MetaFuncGraphPtr &meta_func_graph);
std::string GetAnfNodeText(const FuncGraphPtr &func_graph, const AnfNodePtr &node,
const std::map<AnfNodePtr, int> &apply_map);
void ExportOneFuncGraph(std::ofstream &ofs, const FuncGraphPtr &func_graph);
void OutputParameters(std::ofstream &ofs, const std::vector<AnfNodePtr> &parameters,
OrderedMap<AnfNodePtr, int, ParamPtrHasher, ParamPtrEqual> *param_map);
void OutputStatementComment(std::ofstream &ofs, const CNodePtr &node);
void OutputCNodes(std::ofstream &ofs, const std::vector<AnfNodePtr> &nodes, const FuncGraphPtr &func_graph);
int param_index;
OrderedSet<FuncGraphPtr> func_graph_set{};
@ -108,16 +108,16 @@ class AnfExporter {
abstract::AnfNodeConfigPtr node_cfg_ = nullptr;
};
void ExportIR(const std::string& filename, const std::string& id, const FuncGraphPtr& func_graph);
void ExportIR(const std::string& filename, const std::vector<TaggedGraph>& graphs);
void ExportIR(const std::string &filename, const std::string &id, const FuncGraphPtr &func_graph);
void ExportIR(const std::string &filename, const std::vector<TaggedGraph> &graphs);
std::vector<FuncGraphPtr> ImportIR(const std::string& filename);
std::vector<FuncGraphPtr> ImportIR(const std::string &filename);
std::string GetFuncGraphProtoString(const FuncGraphPtr& func_graph);
std::string GetFuncGraphProtoString(const FuncGraphPtr &func_graph);
void DumpIRProto(const FuncGraphPtr& func_graph, const std::string& suffix);
void DumpIRProto(const FuncGraphPtr &func_graph, const std::string &suffix);
std::string GetOnnxProtoString(const FuncGraphPtr& func_graph);
std::string GetOnnxProtoString(const FuncGraphPtr &func_graph);
} // namespace mindspore
#endif // MINDSPORE_CCSRC_DEBUG_ANF_IR_UTILS_H_

@ -34,7 +34,7 @@ namespace draw {
namespace {
// Only for ValueNode
std::string ValueType(const ValueNodePtr& node) {
std::string ValueType(const ValueNodePtr &node) {
if (node == nullptr) {
return "";
}
@ -43,7 +43,7 @@ std::string ValueType(const ValueNodePtr& node) {
return v->type_name();
}
std::string ReplaceSpecialChar(const std::string& str) {
std::string ReplaceSpecialChar(const std::string &str) {
std::ostringstream oss;
for (size_t i = 0; i < str.size(); i++) {
if (str[i] == '<') {
@ -59,12 +59,12 @@ std::string ReplaceSpecialChar(const std::string& str) {
} // namespace
// API of debug utils
void DrawNodes(const std::vector<AnfNodePtr>& nodes, OrderedMap<FuncGraphPtr, std::shared_ptr<BaseDigraph>>* sub_graphs,
void DrawNodes(const std::vector<AnfNodePtr> &nodes, OrderedMap<FuncGraphPtr, std::shared_ptr<BaseDigraph>> *sub_graphs,
bool is_user) {
if (sub_graphs == nullptr) {
return;
}
for (auto& nd : nodes) {
for (auto &nd : nodes) {
MS_EXCEPTION_IF_NULL(nd);
auto sub_graph = nd->func_graph();
if (sub_graph != nullptr) {
@ -84,16 +84,16 @@ void DrawNodes(const std::vector<AnfNodePtr>& nodes, OrderedMap<FuncGraphPtr, st
}
}
void DrawValueNodes(const std::vector<AnfNodePtr>& nodes,
OrderedMap<FuncGraphPtr, std::shared_ptr<BaseDigraph>>* sub_graphs) {
void DrawValueNodes(const std::vector<AnfNodePtr> &nodes,
OrderedMap<FuncGraphPtr, std::shared_ptr<BaseDigraph>> *sub_graphs) {
if (sub_graphs == nullptr) {
return;
}
int dup_idx = 0;
for (auto& nd : nodes) {
for (auto& t : SuccIncoming(nd)) {
for (auto &nd : nodes) {
for (auto &t : SuccIncoming(nd)) {
MS_EXCEPTION_IF_NULL(t);
MS_EXCEPTION_IF_NULL(nd);
if (t->isa<ValueNode>() && (*sub_graphs).find(nd->func_graph()) != (*sub_graphs).end()) {
@ -107,7 +107,7 @@ void DrawValueNodes(const std::vector<AnfNodePtr>& nodes,
}
}
void DrawEdges(const std::vector<AnfNodePtr>& nodes, const std::shared_ptr<BaseDigraph>& digraph, bool is_user) {
void DrawEdges(const std::vector<AnfNodePtr> &nodes, const std::shared_ptr<BaseDigraph> &digraph, bool is_user) {
if (digraph == nullptr) {
return;
}
@ -120,11 +120,11 @@ void DrawEdges(const std::vector<AnfNodePtr>& nodes, const std::shared_ptr<BaseD
}
// Draw edge
for (auto& nd : nodes) {
for (auto &nd : nodes) {
auto succs = SuccIncoming(nd);
auto num = succs.size();
for (size_t i = 0; i < num; i++) {
auto& t = succs.at(i);
auto &t = succs.at(i);
MS_EXCEPTION_IF_NULL(t);
if (t->isa<ValueNode>() || t->isa<Parameter>()) {
if ((!is_user) || (i != 0)) {
@ -143,7 +143,7 @@ void DrawEdges(const std::vector<AnfNodePtr>& nodes, const std::shared_ptr<BaseD
}
}
void DrawByOpt(std::string filename, const FuncGraphPtr& func_graph, bool is_user) {
void DrawByOpt(std::string filename, const FuncGraphPtr &func_graph, bool is_user) {
if (func_graph == nullptr) {
return;
}
@ -169,7 +169,7 @@ void DrawByOpt(std::string filename, const FuncGraphPtr& func_graph, bool is_use
DrawValueNodes(nodes, &sub_graphs);
// Draw subgraph
for (const auto& gsub : sub_graphs) {
for (const auto &gsub : sub_graphs) {
digraph->SubGraph(gsub.first, gsub.second);
}
@ -182,18 +182,18 @@ void DrawByOpt(std::string filename, const FuncGraphPtr& func_graph, bool is_use
}
#ifdef ENABLE_DUMP_IR
void Draw(const std::string& filename, const FuncGraphPtr& func_graph) {
void Draw(const std::string &filename, const FuncGraphPtr &func_graph) {
const std::string dot_suffix = ".dot";
std::string filename_with_suffix =
(filename.rfind(dot_suffix) != (filename.size() - dot_suffix.size())) ? (filename + dot_suffix) : filename;
DrawByOpt(filename_with_suffix, func_graph, false);
}
void DrawUserFuncGraph(const std::string& filename, const FuncGraphPtr& func_graph) {
void DrawUserFuncGraph(const std::string &filename, const FuncGraphPtr &func_graph) {
DrawByOpt(filename, func_graph, true);
}
#else
void Draw(const std::string&, const FuncGraphPtr&) {
void Draw(const std::string &, const FuncGraphPtr &) {
static bool already_printed = false;
if (already_printed) {
return;
@ -203,7 +203,7 @@ void Draw(const std::string&, const FuncGraphPtr&) {
<< "please recompile source to enable it. See help of building script.";
}
void DrawUserFuncGraph(const std::string&, const FuncGraphPtr&) {
void DrawUserFuncGraph(const std::string &, const FuncGraphPtr &) {
static bool already_printed = false;
if (already_printed) {
return;
@ -234,7 +234,7 @@ std::string Graphviz::Shape(AnfNodePtr node) {
return "plaintext";
}
std::string Graphviz::Color(const AnfNodePtr& node) {
std::string Graphviz::Color(const AnfNodePtr &node) {
if (node == nullptr) {
return "";
}
@ -259,7 +259,7 @@ void BaseDigraph::Start() {
buffer_ << "compound=true" << std::endl;
}
void BaseDigraph::Head(const AnfNodePtr& node, int id) {
void BaseDigraph::Head(const AnfNodePtr &node, int id) {
if (node == nullptr) {
return;
}
@ -270,7 +270,7 @@ void BaseDigraph::Head(const AnfNodePtr& node, int id) {
}
}
void BaseDigraph::Tail(const AnfNodePtr& node, int idx, int id) {
void BaseDigraph::Tail(const AnfNodePtr &node, int idx, int id) {
if (node == nullptr) {
return;
}
@ -279,7 +279,7 @@ void BaseDigraph::Tail(const AnfNodePtr& node, int idx, int id) {
buffer_ << ":" << idx;
}
void BaseDigraph::Tail(const FuncGraphPtr& func_graph) {
void BaseDigraph::Tail(const FuncGraphPtr &func_graph) {
if (func_graph == nullptr) {
return;
}
@ -304,12 +304,12 @@ void BaseDigraph::End() {
}
}
void BaseDigraph::FuncGraphParameters(const FuncGraphPtr& key) {
void BaseDigraph::FuncGraphParameters(const FuncGraphPtr &key) {
buffer_ << "parameters_" << key << "[shape=plaintext ";
buffer_ << "label=<<table bgcolor='paleturquoise' cellspacing='0' cellborder='1' border='0'>";
buffer_ << "<tr><td>parameters</td></tr>";
int count = 0;
for (auto& parameter : key->parameters()) {
for (auto &parameter : key->parameters()) {
buffer_ << "<tr><td>";
buffer_ << parameter->ToString();
auto py_p = dyn_cast<Parameter>(parameter)->default_param();
@ -331,7 +331,7 @@ void BaseDigraph::FuncGraphParameters(const FuncGraphPtr& key) {
buffer_ << "</table>>,];";
}
void BaseDigraph::SubGraph(const FuncGraphPtr& key, const std::shared_ptr<BaseDigraph>& gsub) {
void BaseDigraph::SubGraph(const FuncGraphPtr &key, const std::shared_ptr<BaseDigraph> &gsub) {
if (key == nullptr || gsub == nullptr) {
return;
}
@ -361,12 +361,12 @@ Digraph::~Digraph() {
if (fout_.is_open()) {
fout_.close();
}
} catch (const std::exception& e) {
} catch (const std::exception &e) {
MS_LOG(ERROR) << "Exception when closing file " << filename_;
}
}
static std::string ReplaceAll(std::string str, const std::string& from, const std::string& to) {
static std::string ReplaceAll(std::string str, const std::string &from, const std::string &to) {
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) {
(void)str.replace(start_pos, from.length(), to);
@ -375,7 +375,7 @@ static std::string ReplaceAll(std::string str, const std::string& from, const st
return str;
}
static void DrawValueNode(Graphviz* const graph_obj, const ValueNodePtr& node) {
static void DrawValueNode(Graphviz *const graph_obj, const ValueNodePtr &node) {
MS_EXCEPTION_IF_NULL(graph_obj);
graph_obj->buffer() << "label=<<table port='core' cellborder='0' cellspacing='2' bgcolor='" << graph_obj->Color(node)
<< "'>";
@ -410,7 +410,7 @@ static void DrawValueNode(Graphviz* const graph_obj, const ValueNodePtr& node) {
graph_obj->buffer() << "</td></tr>";
graph_obj->buffer() << "<tr><td align='left'>";
int i = 0;
for (const auto& attr : attrs) {
for (const auto &attr : attrs) {
if (i != 0) {
graph_obj->buffer() << "<br/>";
}
@ -425,7 +425,7 @@ static void DrawValueNode(Graphviz* const graph_obj, const ValueNodePtr& node) {
graph_obj->buffer() << "</table>>,";
}
static void DrawParallelInfo(Graphviz* const graph_obj, const CNodePtr& node) {
static void DrawParallelInfo(Graphviz *const graph_obj, const CNodePtr &node) {
if (graph_obj == nullptr || node == nullptr) {
return;
}
@ -444,7 +444,7 @@ static void DrawParallelInfo(Graphviz* const graph_obj, const CNodePtr& node) {
}
}
static void DrawCNode(Graphviz* const graph_obj, const CNodePtr& node) {
static void DrawCNode(Graphviz *const graph_obj, const CNodePtr &node) {
if (graph_obj == nullptr || node == nullptr || node->size() == 0) {
return;
}
@ -484,7 +484,7 @@ static void DrawCNode(Graphviz* const graph_obj, const CNodePtr& node) {
}
graph_obj->buffer() << ">";
int i = 0;
for (auto& attr : attrs) {
for (auto &attr : attrs) {
if (i != 0) {
graph_obj->buffer() << "<br/>";
}
@ -567,7 +567,7 @@ ModelDigraph::~ModelDigraph() {
if (fout_.is_open()) {
fout_.close();
}
} catch (const std::exception& e) {
} catch (const std::exception &e) {
MS_LOG(ERROR) << "exception when closing file " << filename_;
}
}

@ -31,9 +31,9 @@ namespace parse = mindspore::parse;
class Graphviz {
public:
Graphviz(const std::string& name, const std::string& filename) : name_(name), filename_(filename), fout_(filename_) {}
Graphviz(const std::string &name, const std::string &filename) : name_(name), filename_(filename), fout_(filename_) {}
explicit Graphviz(const std::string& name) : name_(name) {}
explicit Graphviz(const std::string &name) : name_(name) {}
virtual ~Graphviz() {}
@ -41,8 +41,8 @@ class Graphviz {
virtual void End() {}
virtual std::string Shape(AnfNodePtr node);
std::string Color(const AnfNodePtr& node);
std::ostringstream& buffer() { return buffer_; }
std::string Color(const AnfNodePtr &node);
std::ostringstream &buffer() { return buffer_; }
std::ostringstream buffer_;
protected:
@ -53,8 +53,8 @@ class Graphviz {
class BaseDigraph : public Graphviz {
public:
BaseDigraph(const std::string& name, const std::string& filename) : Graphviz(name, filename) {}
explicit BaseDigraph(const std::string& name) : Graphviz(name) {}
BaseDigraph(const std::string &name, const std::string &filename) : Graphviz(name, filename) {}
explicit BaseDigraph(const std::string &name) : Graphviz(name) {}
~BaseDigraph() override = default;
virtual void Node(AnfNodePtr node, int id = 0) = 0;
@ -63,21 +63,21 @@ class BaseDigraph : public Graphviz {
void Start() override;
void End() override;
virtual void Edge(AnfNodePtr start, FuncGraphPtr end, int id_start);
void FuncGraphParameters(const FuncGraphPtr& key);
void SubGraph(const FuncGraphPtr& key, const std::shared_ptr<BaseDigraph>& gsub);
void FuncGraphParameters(const FuncGraphPtr &key);
void SubGraph(const FuncGraphPtr &key, const std::shared_ptr<BaseDigraph> &gsub);
const std::string& name() const { return name_; }
const std::string &name() const { return name_; }
protected:
void Head(const AnfNodePtr& node, int id = 0);
void Tail(const AnfNodePtr& node, int idx, int id = 0);
void Tail(const FuncGraphPtr& func_graph);
void Head(const AnfNodePtr &node, int id = 0);
void Tail(const AnfNodePtr &node, int idx, int id = 0);
void Tail(const FuncGraphPtr &func_graph);
};
class Digraph : public BaseDigraph {
public:
Digraph(const std::string& name, const std::string& filename) : BaseDigraph(name, filename) {}
explicit Digraph(const std::string& name) : BaseDigraph(name) {}
Digraph(const std::string &name, const std::string &filename) : BaseDigraph(name, filename) {}
explicit Digraph(const std::string &name) : BaseDigraph(name) {}
~Digraph() override;
void Node(AnfNodePtr node, int id = 0) override;
@ -86,8 +86,8 @@ class Digraph : public BaseDigraph {
class ModelDigraph : public BaseDigraph {
public:
ModelDigraph(const std::string& name, const std::string& filename) : BaseDigraph(name, filename) {}
explicit ModelDigraph(const std::string& name) : BaseDigraph(name) {}
ModelDigraph(const std::string &name, const std::string &filename) : BaseDigraph(name, filename) {}
explicit ModelDigraph(const std::string &name) : BaseDigraph(name) {}
~ModelDigraph() override;
std::string Shape(AnfNodePtr node) override;
@ -96,8 +96,8 @@ class ModelDigraph : public BaseDigraph {
};
// API to draw
void Draw(const std::string& filename, const FuncGraphPtr& func_graph);
void DrawUserFuncGraph(const std::string& filename, const FuncGraphPtr& func_graph);
void Draw(const std::string &filename, const FuncGraphPtr &func_graph);
void DrawUserFuncGraph(const std::string &filename, const FuncGraphPtr &func_graph);
} // namespace draw
} // namespace mindspore

File diff suppressed because it is too large Load Diff

@ -36,7 +36,7 @@ Dump::Dump()
dump_iter_(0),
cur_iter_(0) {}
bool Dump::IsKernelNeedDump(const std::string& kernel_name) {
bool Dump::IsKernelNeedDump(const std::string &kernel_name) {
if (dump_mode_ == 0) {
// Dump All Kernels mode
return true;
@ -49,7 +49,7 @@ bool Dump::IsKernelNeedDump(const std::string& kernel_name) {
return false;
}
bool Dump::ParseDumpConfig(const std::string& dump_config_file) {
bool Dump::ParseDumpConfig(const std::string &dump_config_file) {
std::ifstream jsonFile(dump_config_file);
if (!jsonFile.is_open()) {
MS_LOG(ERROR) << dump_config_file << " open failed.";
@ -79,7 +79,7 @@ bool Dump::ParseDumpConfig(const std::string& dump_config_file) {
return true;
}
bool Dump::IsConfigExist(const nlohmann::json& dumpSettings) {
bool Dump::IsConfigExist(const nlohmann::json &dumpSettings) {
if (dumpSettings.find("trans_flag") == dumpSettings.end() || dumpSettings.find("enable") == dumpSettings.end() ||
dumpSettings.find("mode") == dumpSettings.end() || dumpSettings.find("path") == dumpSettings.end() ||
dumpSettings.find("net_name") == dumpSettings.end() || dumpSettings.find("iteration") == dumpSettings.end() ||
@ -91,7 +91,7 @@ bool Dump::IsConfigExist(const nlohmann::json& dumpSettings) {
return true;
}
bool Dump::IsConfigValid(const nlohmann::json& dumpSettings) {
bool Dump::IsConfigValid(const nlohmann::json &dumpSettings) {
auto trans_flag = dumpSettings.at("trans_flag");
auto enable = dumpSettings.at("enable");
auto mode = dumpSettings.at("mode");
@ -112,14 +112,14 @@ bool Dump::IsConfigValid(const nlohmann::json& dumpSettings) {
dump_path_ = path;
dump_net_name_ = net_name;
dump_iter_ = iteration;
for (const auto& kernel : kernels) {
for (const auto &kernel : kernels) {
dump_kernels_.push_back(kernel);
}
return true;
}
bool Dump::SetDumpConfFromJsonFile() {
const char* config_path_str = std::getenv("MINDSPORE_CONFIG_PATH");
const char *config_path_str = std::getenv("MINDSPORE_CONFIG_PATH");
if (config_path_str != nullptr) {
MS_LOG(INFO) << "Getenv MINDSPORE_CONFIG_PATH :" << config_path_str;
} else {
@ -148,7 +148,7 @@ bool Dump::SetDumpConfFromJsonFile() {
return ParseDumpConfig(dump_config_file);
}
bool Dump::DumpToFile(const std::string& filename, const void* data, size_t len) {
bool Dump::DumpToFile(const std::string &filename, const void *data, size_t len) {
if (filename.empty() || data == nullptr || len == 0) {
MS_LOG(ERROR) << "Incorrect parameter.";
return false;
@ -166,12 +166,12 @@ bool Dump::DumpToFile(const std::string& filename, const void* data, size_t len)
MS_LOG(ERROR) << "Open file " << realpath << " fail.";
return false;
}
(void)fd.write(reinterpret_cast<const char*>(data), SizeToLong(len));
(void)fd.write(reinterpret_cast<const char *>(data), SizeToLong(len));
fd.close();
return true;
}
bool Dump::GetRealPath(const std::string& inpath, std::string* outpath) {
bool Dump::GetRealPath(const std::string &inpath, std::string *outpath) {
MS_EXCEPTION_IF_NULL(outpath);
auto path_split_pos = inpath.find_last_of('/');
if (path_split_pos == std::string::npos) {
@ -213,7 +213,7 @@ bool Dump::GetRealPath(const std::string& inpath, std::string* outpath) {
return true;
}
bool Dump::CreateNotExistDirs(const std::string& path) {
bool Dump::CreateNotExistDirs(const std::string &path) {
std::shared_ptr<system::FileSystem> fs = system::Env::GetFileSystem();
MS_EXCEPTION_IF_NULL(fs);
char temp_path[PATH_MAX] = {0};

@ -43,11 +43,11 @@ class Dump {
uint32_t cur_iter() const { return cur_iter_; }
bool IsKernelNeedDump(const std::string& kernel_name);
bool IsKernelNeedDump(const std::string &kernel_name);
bool SetDumpConfFromJsonFile();
static bool DumpToFile(const std::string& filename, const void* data, size_t len);
static bool DumpToFile(const std::string &filename, const void *data, size_t len);
protected:
bool dump_enable_;
@ -59,14 +59,14 @@ class Dump {
uint32_t cur_iter_;
std::vector<std::string> dump_kernels_;
static bool GetRealPath(const std::string& inpath, std::string* outpath);
static bool GetRealPath(const std::string &inpath, std::string *outpath);
static bool CreateNotExistDirs(const std::string& path);
static bool CreateNotExistDirs(const std::string &path);
private:
bool ParseDumpConfig(const std::string& dump_config_file);
bool IsConfigExist(const nlohmann::json& dumpSettings);
bool IsConfigValid(const nlohmann::json& dumpSettings);
bool ParseDumpConfig(const std::string &dump_config_file);
bool IsConfigExist(const nlohmann::json &dumpSettings);
bool IsConfigValid(const nlohmann::json &dumpSettings);
};
using DumpConfPtr = std::shared_ptr<Dump>;

@ -23,7 +23,7 @@
#include "pipeline/parse/python_adapter.h"
namespace mindspore {
std::string HighLightLine(const std::string& line, int col_begin, int col_end, SourceLineTip tip) {
std::string HighLightLine(const std::string &line, int col_begin, int col_end, SourceLineTip tip) {
std::string temp_line = line;
if (col_begin < col_end && col_begin != -1 && col_end <= SizeToInt(temp_line.length()) &&
tip != kSourceLineTipDiscard) {
@ -101,14 +101,14 @@ DebugInfo::DebugInfo() {
name_ = "";
}
DebugInfo::DebugInfo(const std::string& name) {
DebugInfo::DebugInfo(const std::string &name) {
InitValueFromContext();
unique_id_ = gen_unique_id();
debug_id_ = -1;
name_ = name;
}
DebugInfo::DebugInfo(const LocationPtr& loc) {
DebugInfo::DebugInfo(const LocationPtr &loc) {
InitValueFromContext();
unique_id_ = gen_unique_id();
debug_id_ = -1;
@ -126,7 +126,7 @@ int64_t DebugInfo::debug_id() {
}
int64_t DebugInfo::unique_id_through_copy() const {
TraceInfoPtr trace_info = const_cast<DebugInfo*>(this)->trace_info();
TraceInfoPtr trace_info = const_cast<DebugInfo *>(this)->trace_info();
if (trace_info != nullptr) {
if (trace_info->isa<TraceCopy>() && trace_info->debug_info() != nullptr) {
return trace_info->debug_info()->unique_id_through_copy();
@ -172,7 +172,7 @@ LocationPtr GraphDebugInfo::location() {
}
return DebugInfo::location();
}
void GraphDebugInfo::set_deco_location(const LocationPtr& deco_list_loc) { deco_loc_ = deco_list_loc; }
void GraphDebugInfo::set_deco_location(const LocationPtr &deco_list_loc) { deco_loc_ = deco_list_loc; }
TraceContextPtr TraceManager::CurrentContextInfo() {
if (!TraceManager::trace_context_stack_.empty()) {
@ -181,18 +181,18 @@ TraceContextPtr TraceManager::CurrentContextInfo() {
return nullptr;
}
void TraceManager::DebugTrace(const std::string& func_name, const LocationPtr& location) {
void TraceManager::DebugTrace(const std::string &func_name, const LocationPtr &location) {
TraceContextPtr context = std::make_shared<TraceContext>(location);
context->set_func_name(func_name);
TraceManager::trace_context_stack_.push(context);
}
void TraceManager::DebugTrace(const LocationPtr& location) {
void TraceManager::DebugTrace(const LocationPtr &location) {
TraceContextPtr context = std::make_shared<TraceContext>(location);
TraceManager::trace_context_stack_.push(context);
}
void TraceManager::DebugTrace(const TraceInfoPtr& trace_info) {
void TraceManager::DebugTrace(const TraceInfoPtr &trace_info) {
if (trace_info == nullptr) {
MS_LOG(EXCEPTION) << "DebugTrace wrong traced info is null";
}
@ -203,7 +203,7 @@ void TraceManager::DebugTrace(const TraceInfoPtr& trace_info) {
TraceManager::trace_context_stack_.push(context);
}
void TraceManager::DebugTrace(const DebugInfoPtr& debug_info, const TraceInfoPtr& trace_info) {
void TraceManager::DebugTrace(const DebugInfoPtr &debug_info, const TraceInfoPtr &trace_info) {
if (trace_info == nullptr) {
MS_LOG(EXCEPTION) << "DebugTrace wrong traced info is null";
}

@ -37,9 +37,9 @@ enum SourceLineTip { kSourceLineTipDiscard = 0, kSourceLineTipNextLine = 1, kSou
// Location class record the location in source code.
class Location {
public:
Location(const std::string& file_name, int line, int column, int line_end, int column_end)
Location(const std::string &file_name, int line, int column, int line_end, int column_end)
: file_name_(file_name), line_(line), column_(column), line_end_(line_end), column_end_(column_end) {}
Location(const Location& loc)
Location(const Location &loc)
: file_name_(loc.file_name_),
line_(loc.line_),
column_(loc.column_),
@ -77,21 +77,21 @@ class TraceManager {
TraceManager() = default;
~TraceManager() = default;
static TraceContextPtr CurrentContextInfo();
static void DebugTrace(const std::string& func_name, const LocationPtr& location);
static void DebugTrace(const LocationPtr& location);
static void DebugTrace(const TraceInfoPtr& trace_info);
static void DebugTrace(const std::string &func_name, const LocationPtr &location);
static void DebugTrace(const LocationPtr &location);
static void DebugTrace(const TraceInfoPtr &trace_info);
// debug trace with a cloned trace info with debug_info
static void DebugTrace(const DebugInfoPtr& debug_info, const TraceInfoPtr& trace_info);
static void DebugTrace(const DebugInfoPtr &debug_info, const TraceInfoPtr &trace_info);
static void EndTrace();
static std::stack<TraceContextPtr> trace_context_stack_;
};
class TraceGuard {
public:
explicit TraceGuard(const std::string func_name, const LocationPtr& location) {
explicit TraceGuard(const std::string func_name, const LocationPtr &location) {
TraceManager::DebugTrace(func_name, location);
}
explicit TraceGuard(const LocationPtr& location) { TraceManager::DebugTrace(location); }
explicit TraceGuard(const LocationPtr &location) { TraceManager::DebugTrace(location); }
~TraceGuard() { TraceManager::EndTrace(); }
};
@ -106,23 +106,23 @@ class TraceContext {
public:
~TraceContext() = default;
explicit TraceContext(const LocationPtr& loc) {
explicit TraceContext(const LocationPtr &loc) {
ProcessAttributeFromContext();
location_ = loc;
}
explicit TraceContext(const std::string& func_name) {
explicit TraceContext(const std::string &func_name) {
ProcessAttributeFromContext();
func_name_ = func_name;
}
explicit TraceContext(const TraceInfoPtr& trace_info) {
explicit TraceContext(const TraceInfoPtr &trace_info) {
ProcessAttributeFromContext();
trace_info_ = trace_info;
}
void set_location(const LocationPtr& loc) { location_ = loc; }
void set_location(const LocationPtr &loc) { location_ = loc; }
LocationPtr location() { return location_; }
void set_trace_info(const TraceInfoPtr& trace_info) { trace_info_ = trace_info; }
void set_trace_info(const TraceInfoPtr &trace_info) { trace_info_ = trace_info; }
TraceInfoPtr trace_info() { return trace_info_; }
void set_func_name(const std::string& func_name) { func_name_ = func_name; }
void set_func_name(const std::string &func_name) { func_name_ = func_name; }
std::string func_name() { return func_name_; }
};
@ -130,9 +130,9 @@ class DebugInfo : public Base {
public:
DebugInfo();
explicit DebugInfo(const std::string& name);
explicit DebugInfo(const std::string &name);
explicit DebugInfo(const LocationPtr& loc);
explicit DebugInfo(const LocationPtr &loc);
virtual ~DebugInfo() = default;
MS_DECLARE_PARENT(DebugInfo, Base);
@ -141,12 +141,12 @@ class DebugInfo : public Base {
int64_t unique_id_through_copy() const;
std::string get_id() { return std::to_string(debug_id()); }
void set_trace_info(const TraceInfoPtr& trace_info) { trace_info_ = trace_info; }
void set_trace_info(const TraceInfoPtr &trace_info) { trace_info_ = trace_info; }
TraceInfoPtr trace_info() { return trace_info_; }
void set_location(const LocationPtr& loc) { location_ = loc; }
void set_location(const LocationPtr &loc) { location_ = loc; }
virtual LocationPtr location() { return location_; }
std::string name() { return name_; }
void set_name(const std::string& name) { name_ = name; }
void set_name(const std::string &name) { name_ = name; }
virtual std::string debug_name();
virtual std::string get_python_func_belonged() { return ""; }
@ -186,7 +186,7 @@ class NodeDebugInfo : public DebugInfo {
py_func_belonged_ = context_info->func_name();
}
}
explicit NodeDebugInfo(const std::string& name) : DebugInfo(name) {
explicit NodeDebugInfo(const std::string &name) : DebugInfo(name) {
if (TraceManager::CurrentContextInfo() != nullptr) {
auto context_info = TraceManager::CurrentContextInfo();
py_func_belonged_ = context_info->func_name();
@ -195,9 +195,9 @@ class NodeDebugInfo : public DebugInfo {
~NodeDebugInfo() override = default;
std::string debug_name() override;
void set_node(const std::shared_ptr<AnfNode>& node) { node_ = AnfNodeWeakPtr(node); }
void set_node(const std::shared_ptr<AnfNode> &node) { node_ = AnfNodeWeakPtr(node); }
std::shared_ptr<AnfNode> get_node() const { return node_.lock(); }
void set_py_func_belonged(const std::string& name) { py_func_belonged_ = name; }
void set_py_func_belonged(const std::string &name) { py_func_belonged_ = name; }
std::string get_python_func_belonged() override { return py_func_belonged_; }
AnfNodeWeakPtr node_;
std::string py_func_belonged_;
@ -214,7 +214,7 @@ class GraphDebugInfo : public DebugInfo {
}
}
explicit GraphDebugInfo(const std::string& name) : DebugInfo(name) {
explicit GraphDebugInfo(const std::string &name) : DebugInfo(name) {
if (TraceManager::CurrentContextInfo() != nullptr) {
auto context_info = TraceManager::CurrentContextInfo();
py_func_name_ = context_info->func_name();
@ -225,11 +225,11 @@ class GraphDebugInfo : public DebugInfo {
std::string debug_name() override;
LocationPtr location() override;
LocationPtr deco_location() { return deco_loc_; }
void set_graph(const FuncGraphPtr& func_graph) { func_graph_ = FuncGraphWeakPtr(func_graph); }
void set_graph(const FuncGraphPtr &func_graph) { func_graph_ = FuncGraphWeakPtr(func_graph); }
FuncGraphPtr get_graph() const { return func_graph_.lock(); }
void set_full_name(const std::string& name) { full_name_ = name; }
void set_full_name(const std::string &name) { full_name_ = name; }
std::string get_full_name() { return full_name_; }
void set_deco_location(const LocationPtr& deco_list_loc);
void set_deco_location(const LocationPtr &deco_list_loc);
std::string get_python_func_belonged() override { return py_func_name_; }
FuncGraphWeakPtr func_graph_;
LocationPtr deco_loc_;

@ -31,7 +31,7 @@ struct NameWithTrace {
std::string name;
std::vector<std::string> trace_labels;
};
static std::string GetTraceName(const TraceInfoPtr& trace_info, TraceLabelType trace_label) {
static std::string GetTraceName(const TraceInfoPtr &trace_info, TraceLabelType trace_label) {
switch (trace_label) {
case TraceLabelType::kShortSymbol:
return trace_info->symbol();
@ -42,7 +42,7 @@ static std::string GetTraceName(const TraceInfoPtr& trace_info, TraceLabelType t
}
}
NameWithTrace RootName(const DebugInfoPtr& debug_info, TraceLabelType trace_label) {
NameWithTrace RootName(const DebugInfoPtr &debug_info, TraceLabelType trace_label) {
NameWithTrace trace_name;
// find debug info after Resolve/ExpandJ/GenMetaFuncGraph, it is a new node
auto temp_info = debug_info;
@ -66,9 +66,9 @@ NameWithTrace RootName(const DebugInfoPtr& debug_info, TraceLabelType trace_labe
return trace_name;
}
std::string CombineTraceTypes(const std::string& root_name, const std::vector<std::string>& trace_labels) {
std::string CombineTraceTypes(const std::string &root_name, const std::vector<std::string> &trace_labels) {
std::string tags = "";
for (auto& itr : trace_labels) {
for (auto &itr : trace_labels) {
std::string symbol = itr;
tags = tags + symbol;
}
@ -76,12 +76,12 @@ std::string CombineTraceTypes(const std::string& root_name, const std::vector<st
}
// get the label name of the node debug info
std::string LabelString(const DebugInfoPtr& debug_info, TraceLabelType trace_label) {
std::string LabelString(const DebugInfoPtr &debug_info, TraceLabelType trace_label) {
NameWithTrace trace_name = RootName(debug_info, trace_label);
return CombineTraceTypes(trace_name.name, trace_name.trace_labels);
}
std::string CombineUniqueID(const DebugInfoPtr& debug_info) {
std::string CombineUniqueID(const DebugInfoPtr &debug_info) {
auto temp_info = debug_info;
std::string label = "";
while (temp_info != nullptr) {
@ -103,9 +103,9 @@ std::string CombineUniqueID(const DebugInfoPtr& debug_info) {
}
// get trace with unique id chain
std::string LabelStringUnique(const DebugInfoPtr& debug_info) { return CombineUniqueID(debug_info); }
std::string LabelStringUnique(const DebugInfoPtr &debug_info) { return CombineUniqueID(debug_info); }
std::string Label(const DebugInfoPtr& debug_info, TraceLabelType trace_label) {
std::string Label(const DebugInfoPtr &debug_info, TraceLabelType trace_label) {
if (GetGlobalTraceLabelType() == TraceLabelType::kWithUniqueId) {
return LabelStringUnique(debug_info);
}

@ -29,7 +29,7 @@ namespace label_manage {
enum class TraceLabelType { kShortSymbol, kFullName, kWithUniqueId };
TraceLabelType GetGlobalTraceLabelType();
void SetGlobalTraceLabelType(TraceLabelType label_type);
std::string Label(const DebugInfoPtr& debug_info, TraceLabelType trace_type = TraceLabelType::kShortSymbol);
std::string Label(const DebugInfoPtr &debug_info, TraceLabelType trace_type = TraceLabelType::kShortSymbol);
} // namespace label_manage
} // namespace mindspore

@ -37,7 +37,7 @@
namespace mindspore {
// namespace to support debug trace infomation
namespace trace {
std::string GetAbstractStr(const abstract::AbstractBasePtr& abs) {
std::string GetAbstractStr(const abstract::AbstractBasePtr &abs) {
if (abs == nullptr) {
return "Null Abstract";
}
@ -69,7 +69,7 @@ std::vector<DebugInfoPtr> GetSourceCodeDebugInfoVec(DebugInfoPtr debug_info) {
return debug_with_loc_vec;
}
DebugInfoPtr GetSourceCodeDebugInfo(const DebugInfoPtr& info) {
DebugInfoPtr GetSourceCodeDebugInfo(const DebugInfoPtr &info) {
auto debug_with_loc_vec = GetSourceCodeDebugInfoVec(info);
if (debug_with_loc_vec.size() > 0) {
return debug_with_loc_vec[0];
@ -78,7 +78,7 @@ DebugInfoPtr GetSourceCodeDebugInfo(const DebugInfoPtr& info) {
}
}
std::string GetDebugInfo(const DebugInfoPtr& info, SourceLineTip tip) {
std::string GetDebugInfo(const DebugInfoPtr &info, SourceLineTip tip) {
if (info == nullptr) {
return "";
}
@ -91,7 +91,7 @@ std::string GetDebugInfo(const DebugInfoPtr& info, SourceLineTip tip) {
// a trace info identifies a node transform, so we can trace the node transform through
// a link of trace info and debug info
std::string GetInfoWithAction(const std::vector<DebugInfoPtr>& info_vec, SourceLineTip tip) {
std::string GetInfoWithAction(const std::vector<DebugInfoPtr> &info_vec, SourceLineTip tip) {
if (info_vec.size() < 1) {
return "";
}
@ -109,7 +109,7 @@ std::string GetInfoWithAction(const std::vector<DebugInfoPtr>& info_vec, SourceL
return traced_info;
}
std::string GetTracedDebugInfo(const DebugInfoPtr& info, SourceLineTip tip) {
std::string GetTracedDebugInfo(const DebugInfoPtr &info, SourceLineTip tip) {
if (info == nullptr) {
return "";
}
@ -124,7 +124,7 @@ std::string GetTracedDebugInfo(const DebugInfoPtr& info, SourceLineTip tip) {
return "";
}
std::string GetDebugInfo(const DebugInfoPtr& info, const std::string& prefix, SourceLineTip tip) {
std::string GetDebugInfo(const DebugInfoPtr &info, const std::string &prefix, SourceLineTip tip) {
std::ostringstream oss;
if (info == nullptr) {
return "";
@ -139,7 +139,7 @@ std::string GetDebugInfo(const DebugInfoPtr& info, const std::string& prefix, So
return oss.str();
}
std::string GetGraphParamString(const FuncGraphPtr& graph, abstract::AbstractBasePtrList args_spec_list) {
std::string GetGraphParamString(const FuncGraphPtr &graph, abstract::AbstractBasePtrList args_spec_list) {
std::ostringstream oss;
oss << "graph:" << graph->ToString() << " with args[";
auto params = graph->parameters();
@ -151,8 +151,8 @@ std::string GetGraphParamString(const FuncGraphPtr& graph, abstract::AbstractBas
return oss.str();
}
void DumpInferStack(std::ostringstream& oss) {
auto& infer_stack = GetCurrenGraphInferStack();
void DumpInferStack(std::ostringstream &oss) {
auto &infer_stack = GetCurrenGraphInferStack();
if (infer_stack.empty()) {
return;
}
@ -164,7 +164,7 @@ void DumpInferStack(std::ostringstream& oss) {
}
std::reverse(infer_vec.begin(), infer_vec.end());
int index = 0;
for (auto& item : infer_vec) {
for (auto &item : infer_vec) {
auto graph_infer = std::dynamic_pointer_cast<abstract::BaseFuncGraphEvaluator>(item.first);
if (graph_infer == nullptr) {
MS_LOG(WARNING) << "DumpInferStack failed, got null graph evaluator";
@ -183,7 +183,7 @@ void DumpInferStack(std::ostringstream& oss) {
}
void TraceGraphInfer() {
auto& infer_stack = GetCurrenGraphInferStack();
auto &infer_stack = GetCurrenGraphInferStack();
std::ostringstream oss;
if (infer_stack.empty()) {
return;
@ -200,15 +200,15 @@ class AnalyzedFuncGraphExporter : public AnfExporter {
AnalyzedFuncGraphExporter() : AnfExporter("", true, false) {}
~AnalyzedFuncGraphExporter() override = default;
void ExportFuncGraph(const std::string& filename, const std::vector<abstract::AnfNodeConfigPtr>& node_cfgs);
void ExportFuncGraph(const std::string &filename, const std::vector<abstract::AnfNodeConfigPtr> &node_cfgs);
private:
std::string GetNodeType(const AnfNodePtr& nd) override;
std::string GetNodeType(const AnfNodePtr &nd) override;
};
std::unordered_map<FuncGraphPtr, TaggedNodeMap> CalcTaggedFuncGraphs() {
std::unordered_map<FuncGraphPtr, TaggedNodeMap> tagged_func_graphs;
auto& list = GetCNodeDebugStack();
auto &list = GetCNodeDebugStack();
for (size_t i = 0; i < list.size(); ++i) {
auto node_cfg = list[i];
auto fg = node_cfg->context()->func_graph();
@ -223,7 +223,7 @@ void OutputAnalyzedGraphWithType() {
exporter.ExportFuncGraph("analyze_fail.dat", GetCNodeDebugStack());
}
std::string AnalyzedFuncGraphExporter::GetNodeType(const AnfNodePtr& node) {
std::string AnalyzedFuncGraphExporter::GetNodeType(const AnfNodePtr &node) {
if (node_cfg_ == nullptr) {
return AnfExporter::GetNodeType(node);
}
@ -248,8 +248,8 @@ std::string AnalyzedFuncGraphExporter::GetNodeType(const AnfNodePtr& node) {
return oss.str();
}
void AnalyzedFuncGraphExporter::ExportFuncGraph(const std::string& filename,
const std::vector<abstract::AnfNodeConfigPtr>& node_cfgs) {
void AnalyzedFuncGraphExporter::ExportFuncGraph(const std::string &filename,
const std::vector<abstract::AnfNodeConfigPtr> &node_cfgs) {
if (node_cfgs.empty()) {
MS_LOG(DEBUG) << "Node configs is empty";
return;
@ -265,7 +265,7 @@ void AnalyzedFuncGraphExporter::ExportFuncGraph(const std::string& filename,
auto tagged_func_graphs = CalcTaggedFuncGraphs();
// first output graph on the analysis stack
for (const auto& node_cfg : node_cfgs) {
for (const auto &node_cfg : node_cfgs) {
auto fg = node_cfg->context()->func_graph();
// the graph is already output, skip it
if (exported.find(fg) != exported.end()) {
@ -296,7 +296,7 @@ void AnalyzedFuncGraphExporter::ExportFuncGraph(const std::string& filename,
ofs.close();
}
void GetInferStackInfo(std::ostringstream& oss) {
void GetInferStackInfo(std::ostringstream &oss) {
MS_LOG(INFO) << "Get graph analysis information begin";
auto stack = GetCNodeDebugStack();
if (stack.empty()) {
@ -336,7 +336,7 @@ void GetInferStackInfo(std::ostringstream& oss) {
static std::stack<std::pair<abstract::EvaluatorPtr, abstract::AnfNodeConfigPtr>> graph_infer_stack;
// trace the cnode infer debug info
static std::vector<abstract::AnfNodeConfigPtr> cnode_debug_stack{};
void TraceGraphInferEnter(const abstract::EvaluatorPtr& eval, const abstract::AnfNodeConfigPtr& node) {
void TraceGraphInferEnter(const abstract::EvaluatorPtr &eval, const abstract::AnfNodeConfigPtr &node) {
if (eval == nullptr) {
MS_LOG(EXCEPTION) << "GraphInferEnter got null eval";
}
@ -345,7 +345,7 @@ void TraceGraphInferEnter(const abstract::EvaluatorPtr& eval, const abstract::An
}
}
void TraceGraphInferLeave(const abstract::EvaluatorPtr& eval) {
void TraceGraphInferLeave(const abstract::EvaluatorPtr &eval) {
if (eval == nullptr) {
MS_LOG(EXCEPTION) << "GraphInferEnter got null eval";
}
@ -354,13 +354,13 @@ void TraceGraphInferLeave(const abstract::EvaluatorPtr& eval) {
}
}
void TraceInferCNodeEnter(const abstract::AnfNodeConfigPtr& node_cfg) { cnode_debug_stack.push_back(node_cfg); }
void TraceInferCNodeEnter(const abstract::AnfNodeConfigPtr &node_cfg) { cnode_debug_stack.push_back(node_cfg); }
void TraceInferCNodeLeave() { cnode_debug_stack.pop_back(); }
std::vector<abstract::AnfNodeConfigPtr>& GetCNodeDebugStack() { return cnode_debug_stack; }
std::vector<abstract::AnfNodeConfigPtr> &GetCNodeDebugStack() { return cnode_debug_stack; }
std::stack<std::pair<abstract::EvaluatorPtr, abstract::AnfNodeConfigPtr>>& GetCurrenGraphInferStack() {
std::stack<std::pair<abstract::EvaluatorPtr, abstract::AnfNodeConfigPtr>> &GetCurrenGraphInferStack() {
return graph_infer_stack;
}
void ClearTraceStack() {

@ -31,19 +31,19 @@
namespace mindspore {
namespace trace {
std::string GetDebugInfo(const DebugInfoPtr& info, SourceLineTip tip = kSourceLineTipNextLine);
std::string GetDebugInfo(const DebugInfoPtr& info, const std::string& prefix,
std::string GetDebugInfo(const DebugInfoPtr &info, SourceLineTip tip = kSourceLineTipNextLine);
std::string GetDebugInfo(const DebugInfoPtr &info, const std::string &prefix,
SourceLineTip tip = kSourceLineTipNextLine);
DebugInfoPtr GetSourceCodeDebugInfo(const DebugInfoPtr& info);
DebugInfoPtr GetSourceCodeDebugInfo(const DebugInfoPtr &info);
void TraceGraphInfer();
void GetInferStackInfo(std::ostringstream& oss);
void TraceGraphInferEnter(const abstract::EvaluatorPtr& eval, const abstract::AnfNodeConfigPtr& node);
void TraceGraphInferLeave(const abstract::EvaluatorPtr& eval);
void TraceInferCNodeEnter(const abstract::AnfNodeConfigPtr& node_cfg);
void GetInferStackInfo(std::ostringstream &oss);
void TraceGraphInferEnter(const abstract::EvaluatorPtr &eval, const abstract::AnfNodeConfigPtr &node);
void TraceGraphInferLeave(const abstract::EvaluatorPtr &eval);
void TraceInferCNodeEnter(const abstract::AnfNodeConfigPtr &node_cfg);
void TraceInferCNodeLeave();
std::vector<abstract::AnfNodeConfigPtr>& GetCNodeDebugStack();
std::stack<std::pair<abstract::EvaluatorPtr, abstract::AnfNodeConfigPtr>>& GetCurrenGraphInferStack();
std::string GetAbstractStr(const abstract::AbstractBasePtr& abs);
std::vector<abstract::AnfNodeConfigPtr> &GetCNodeDebugStack();
std::stack<std::pair<abstract::EvaluatorPtr, abstract::AnfNodeConfigPtr>> &GetCurrenGraphInferStack();
std::string GetAbstractStr(const abstract::AbstractBasePtr &abs);
void ClearTraceStack();
} // namespace trace
} // namespace mindspore

@ -23,7 +23,7 @@
#include "pipeline/parse/python_adapter.h"
namespace mindspore {
std::string TraceInfo::GetActionBetweenNode(const DebugInfoPtr& info) {
std::string TraceInfo::GetActionBetweenNode(const DebugInfoPtr &info) {
if (info == nullptr) {
return "";
}

File diff suppressed because it is too large Load Diff

@ -21,7 +21,7 @@
namespace mindspore {
namespace device {
namespace ascend {
size_t AscendMemoryPool::AllocDeviceMem(size_t size, DeviceMemPtr* addr) {
size_t AscendMemoryPool::AllocDeviceMem(size_t size, DeviceMemPtr *addr) {
if (has_malloc_) {
MS_LOG(EXCEPTION) << "Has alloc memory pool memory !";
}
@ -37,7 +37,7 @@ size_t AscendMemoryPool::AllocDeviceMem(size_t size, DeviceMemPtr* addr) {
return size;
}
bool AscendMemoryPool::FreeDeviceMem(const DeviceMemPtr& addr) {
bool AscendMemoryPool::FreeDeviceMem(const DeviceMemPtr &addr) {
MS_EXCEPTION_IF_NULL(addr);
has_malloc_ = false;
free_mem_size_ = total_mem_size_;
@ -53,7 +53,7 @@ size_t AscendMemoryPool::AlignMemorySize(size_t size) const {
size_t AscendMemoryPool::mem_alloc_unit_size() const { return free_mem_size_ - 512; }
void AscendMemoryPool::set_device_mem_pool_base(uint8_t* device_mem_pool_base) {
void AscendMemoryPool::set_device_mem_pool_base(uint8_t *device_mem_pool_base) {
MS_EXCEPTION_IF_NULL(device_mem_pool_base);
device_mem_pool_base_ = device_mem_pool_base;
}

@ -26,12 +26,12 @@ namespace ascend {
class AscendMemoryPool : public DynamicMemPoolBestFit {
public:
~AscendMemoryPool() override = default;
AscendMemoryPool(const AscendMemoryPool&) = delete;
AscendMemoryPool& operator=(const AscendMemoryPool&) = delete;
AscendMemoryPool(const AscendMemoryPool &) = delete;
AscendMemoryPool &operator=(const AscendMemoryPool &) = delete;
size_t AllocDeviceMem(size_t size, DeviceMemPtr* addr) override;
bool FreeDeviceMem(const DeviceMemPtr& addr) override;
void set_device_mem_pool_base(uint8_t* device_mem_pool_base);
size_t AllocDeviceMem(size_t size, DeviceMemPtr *addr) override;
bool FreeDeviceMem(const DeviceMemPtr &addr) override;
void set_device_mem_pool_base(uint8_t *device_mem_pool_base);
void set_device_mem_pool_size(uint64_t device_mem_pool_size) {
device_mem_pool_size_ = device_mem_pool_size;
free_mem_size_ = device_mem_pool_size_;
@ -40,7 +40,7 @@ class AscendMemoryPool : public DynamicMemPoolBestFit {
size_t free_mem_size() override;
size_t total_mem_size() override;
static AscendMemoryPool& GetInstance() {
static AscendMemoryPool &GetInstance() {
static AscendMemoryPool instance;
return instance;
}
@ -54,7 +54,7 @@ class AscendMemoryPool : public DynamicMemPoolBestFit {
private:
AscendMemoryPool() = default;
bool has_malloc_{false};
uint8_t* device_mem_pool_base_{nullptr};
uint8_t *device_mem_pool_base_{nullptr};
uint64_t device_mem_pool_size_{0};
size_t free_mem_size_{0};
size_t total_mem_size_{0};

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save