fix static check problems

pull/4396/head
wuyongkang 5 years ago
parent eb4749642d
commit 78611b5d5b

@ -507,6 +507,5 @@ struct TraceProviderRegister {
}
~TraceProviderRegister() = default;
} trace_provider_regsiter;
} // namespace trace
} // namespace mindspore

@ -162,9 +162,9 @@ TypeId GetMaxTypeId(const abstract::AbstractBasePtrList &args_spec_list, std::ve
}
// Get the largest type of index in the same SignatureEnumDType of arguments.
std::map<SignatureEnumDType, TypeId> GetMaxDtype(const std::vector<SignatureEnumDType> &dtypes,
const abstract::AbstractBasePtrList &args_spec_list,
const std::set<size_t> &write_indices) {
using MaxTypeMap = std::map<SignatureEnumDType, TypeId>;
MaxTypeMap GetMaxDtype(const std::vector<SignatureEnumDType> &dtypes,
const abstract::AbstractBasePtrList &args_spec_list, const std::set<size_t> &write_indices) {
// record index for signature.dtypes of the same type
// eg. [T, T1, T, T2, T, T1, T3] -> {{T:(0,2,4)}, {T1:(1,5)}, {T2:(3)}, {T3:(6)}}
std::map<SignatureEnumDType, std::vector<size_t>> type_indices;

@ -24,12 +24,10 @@
namespace mindspore {
/* namespace to support opt */
namespace opt {
bool GraphKernelReuse::CompareNode(const AnfNodePtr a, const AnfNodePtr b) {
if (a->abstract() && b->abstract()) {
auto a_type = a->abstract()->GetTypeTrack();
auto b_type = b->abstract()->GetTypeTrack();
if (a_type != b_type) {
return false;
}
@ -132,7 +130,6 @@ bool GraphKernelReuse::DoReplace(const FuncGraphManagerPtr manager) {
manager->Replace(iter.first->first, new_cnode);
changed = true;
}
} else {
// Add current fg to map
graph_kernel_ops[key].push_back(fg);
@ -152,6 +149,5 @@ bool GraphKernelReuse::ReuseGraphKernel(const FuncGraphPtr root, const FuncGraph
return DoReplace(manager);
}
} // namespace opt
} // namespace mindspore

@ -25,7 +25,6 @@
namespace mindspore {
namespace opt {
// Common subexpression elimination.
class GraphKernelReuse {
public:
@ -46,7 +45,6 @@ class GraphKernelReuse {
std::unordered_map<std::string, std::vector<FuncGraphPtr>> graph_kernel_ops;
int count;
};
} // namespace opt
} // namespace mindspore
#endif // MINDSPORE_CCSRC_FRONTEND_OPTIMIZER_GRAPH_KERNEL_OP_REUSE_H

@ -147,7 +147,6 @@ void AdjustAllReduceMulAdd::ProcessDependEdge(const FuncGraphPtr &fg, const AnfN
}
}
}
} // namespace irpass
} // namespace opt
} // namespace mindspore

@ -62,7 +62,6 @@ class ArithmeticSimplify2 : public OptimizerCaller {
public:
AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override;
};
} // namespace irpass
} // namespace opt
} // namespace mindspore

@ -141,7 +141,6 @@ class ConvertSwitchReplacement : public OptimizerCaller {
return nullptr;
}
};
} // namespace irpass
} // namespace opt
} // namespace mindspore

@ -32,7 +32,6 @@
namespace mindspore {
namespace opt {
namespace irpass {
static int count = 0;
std::string GetFusionNumber() {
@ -79,7 +78,6 @@ class MarkInterfaceFusion : public AnfVisitor {
private:
AnfNodePtr y_{nullptr};
};
} // namespace irpass
} // namespace opt
} // namespace mindspore

@ -203,7 +203,6 @@ class DependValueElim : public OptimizerCaller {
return nullptr;
}
};
} // namespace irpass
} // namespace opt
} // namespace mindspore

@ -33,7 +33,6 @@
namespace mindspore {
namespace opt {
namespace irpass {
const char PARSE_SUPER_NAME[] = "namespace";
// {prim::kPrimResolve, Ns, Sym}
@ -108,7 +107,6 @@ class ResolveAttr : public OptimizerCaller {
auto ns_ = GetValueNode<parse::NameSpacePtr>(ns_node.GetNode(node));
auto sym_ = GetValueNode<parse::SymbolPtr>(sym_node.GetNode(node));
if (ns_->module() == parse::RESOLVE_NAMESPACE_NAME_CLASS_MEMBER && sym_->symbol() != PARSE_SUPER_NAME) {
// deal with the case of getting attr from a class member
// and avoid the case of getting attr from self (the result of ParseSuper)

@ -122,7 +122,6 @@ AnfNodePtr ValueBasedEliminate::operator()(const OptimizerPtr &, const AnfNodePt
return nullptr;
}
} // namespace irpass
} // namespace opt
} // namespace mindspore

@ -30,7 +30,6 @@
namespace mindspore {
namespace opt {
namespace irpass {
// {prim::kPrimSelect, {prim::kPrimGreater, X, 0}, Y, Z}} -> Y when X is always greater than 0
// {prim::kPrimMaximum, X, Y} -> X when Y is smaller than LOWER_FLT_LIMIT
// {prim::kPrimMinimum, X, Y} -> X when Y is greater than UPPER_FLT_LIMIT

@ -63,7 +63,6 @@ bool PassGroup::Run(const FuncGraphPtr &func_graph) const {
}
return changed;
}
} // namespace python_pass
} // namespace opt
} // namespace mindspore

@ -49,6 +49,7 @@ using PatternNodeMap = std::unordered_map<PatternPtr, AnfNodePtr, PatternHasher,
class Pattern : public Base {
public:
Pattern() : unique_name_(std::to_string(g_id_++)) {}
~Pattern() = default;
virtual MatchResultPtr match(const AnfNodePtr &node) { return nullptr; }
virtual bool operator==(const Pattern &other) const { return unique_name_ == other.unique_name_; }
string unique_name() const { return unique_name_; }
@ -82,6 +83,7 @@ struct PatternHasher {
class IsPrimTypeOf : public Pattern {
public:
IsPrimTypeOf() { unique_name_ = std::to_string(g_id_++); }
~IsPrimTypeOf() = default;
IsPrimTypeOf(vector<PrimitivePyPtr> prims, string name, bool should_replace)
: primitives_(prims), name_(name), matched_prim_(nullptr) {
unique_name_ = std::to_string(g_id_++) + "_" + name;
@ -120,6 +122,7 @@ class IsPrimTypeOf : public Pattern {
class CallWith : public Pattern {
public:
CallWith() { unique_name_ = std::to_string(g_id_++); }
~CallWith() = default;
CallWith(PatternPtr prim_pattern, vector<PatternPtr> inputs, bool should_replace) {
// NOTE: should_replace is ignored in this case, since each sub-pattern has its own setting
prim_pattern_ = prim_pattern;
@ -154,6 +157,7 @@ class CallWith : public Pattern {
class IsIn : public Pattern {
public:
IsIn() { unique_name_ = std::to_string(g_id_++); }
~IsIn() = default;
explicit IsIn(vector<PatternPtr> patterns) : patterns_(patterns) {
unique_name_ = std::to_string(g_id_++);
for (auto &iter : patterns) {
@ -170,6 +174,7 @@ class IsIn : public Pattern {
class IsNot : public Pattern {
public:
IsNot() { unique_name_ = std::to_string(g_id_++); }
~IsNot() = default;
explicit IsNot(vector<PatternPtr> patterns) : patterns_(patterns) {
unique_name_ = std::to_string(g_id_++);
for (auto &iter : patterns) {
@ -186,6 +191,7 @@ class IsNot : public Pattern {
class AnyPattern : public Pattern {
public:
AnyPattern() { unique_name_ = std::to_string(g_id_++) + "_AnyPattern"; }
~AnyPattern() = default;
MS_DECLARE_PARENT(AnyPattern, Pattern);
MatchResultPtr match(const AnfNodePtr &node) override;
};
@ -193,6 +199,7 @@ class AnyPattern : public Pattern {
class NewTensor : public Pattern {
public:
NewTensor() { unique_name_ = std::to_string(g_id_++); }
~NewTensor() = default;
explicit NewTensor(tensor::TensorPtr input_tensor) : input_tensor_(input_tensor) { should_replace_ = false; }
MS_DECLARE_PARENT(NewTensor, Pattern);
MatchResultPtr match(const AnfNodePtr &node) override {
@ -207,6 +214,7 @@ class NewTensor : public Pattern {
class MatchResult {
public:
MatchResult() {}
~MatchResult() = default;
void add_entry(PatternPtr pattern, AnfNodePtr node) { match_result_[pattern] = node; }
PatternNodeMap _result() { return match_result_; }
AnfNodePtr get_node(const PatternPtr &pattern);

@ -386,6 +386,5 @@ static inline uint64_t GetCurrentUSec() {
do { \
MS_LOG(INFO) << #stage << " called " << count_##stage << " times, costs " << total_##stage << " usec."; \
} while (0)
} // namespace mindspore
#endif // MINDSPORE_CCSRC_UTILS_UTILS_H_

@ -146,6 +146,7 @@ void MsBackend::Link(GraphId graph_id) {
Backend::Backend(const std::string &name) : name_(name) {
MS_LOG(DEBUG) << "select backend:" << name;
convert_fn_ = backends[name_];
is_multi_graph_sink_ = false;
}
MsBackend::MsBackend(const std::string &name, const std::string &target, uint32_t device_id) : Backend(name) {

@ -80,7 +80,7 @@ AnfNodePtrList GetOutput(const AnfNodePtrList &lst, const NodeUsersMap &users, c
}
namespace {
AnfNodePtr RefSubGraphNode(const FuncGraphPtr &fg, const AnfNodePtr &node, AnfNodePtrList *inputs_ptr,
AnfNodePtr RefSubGraphNode(const FuncGraphPtr &fg, const AnfNodePtr &node, AnfNodePtrList *const inputs_ptr,
AnfNodePtrToAnfNodePtrMap *eqv_ptr) {
MS_EXCEPTION_IF_NULL(fg);
MS_EXCEPTION_IF_NULL(inputs_ptr);

@ -215,7 +215,6 @@ AbstractBasePtr InferImplDictGetItem(const AnalysisEnginePtr &, const PrimitiveP
std::vector<AbstractAttribute> dict_elems = dict->elements();
auto it = std::find_if(dict_elems.begin(), dict_elems.end(),
[key_str](const AbstractAttribute &item) { return item.first == key_str; });
if (it == dict_elems.end()) {
MS_LOG(EXCEPTION) << "The key " << key_str << " does not exist in the dict:" << args_spec_list[0]->ToString();
}

@ -30,6 +30,7 @@ namespace mindspore {
class Conv2d : public PrimitiveC {
public:
Conv2d();
~Conv2d() = default;
void Init(int out_channel, const std::vector<int> &kernel_size, int mode = 1, const std::string &pad_mode = "valid",
const std::vector<int> &pad = {0, 0, 0, 0}, const std::vector<int> &stride = {1, 1, 1, 1},
const std::vector<int> &dilation = {1, 1, 1, 1}, int group = 1);

@ -27,6 +27,7 @@ namespace mindspore {
class PrimitiveC : public Primitive {
public:
explicit PrimitiveC(const std::string &name) : Primitive(name) {}
~PrimitiveC() = default;
AbstractBasePtr Infer(const AbstractBasePtrList &abstract_list);
protected:

@ -23,10 +23,8 @@
#include "base/base.h"
namespace mindspore {
struct TypeIdManager *TypeIdManager::Get() {
static TypeIdManager manager;
return &manager;
}
} // namespace mindspore

@ -35,7 +35,6 @@
#include "utils/label.h"
namespace mindspore {
enum IncludeType { FOLLOW, NOFOLLOW, EXCLUDE };
using IncludeFunc = std::function<IncludeType(const AnfNodePtr &)>;

@ -23,7 +23,6 @@
// namespace to support intermediate representation definition
namespace mindspore {
abstract::AbstractBasePtr MetaFuncGraph::ToAbstract() {
return std::make_shared<abstract::MetaFuncGraphAbstractClosure>(shared_from_base<MetaFuncGraph>());
}

@ -579,7 +579,6 @@ class PConstant : public PBase<PConstant<T> > {
if (!node->isa<ValueNode>()) {
return nullptr;
}
auto value = node->cast<ValueNodePtr>()->value();
if (!value->isa<tensor::Tensor>()) {
@ -622,7 +621,6 @@ class PConstant : public PBase<PConstant<T> > {
}
auto x_abstract = x->abstract()->cast<abstract::AbstractTensorPtr>();
std::vector<int> x_shape = x_abstract->shape()->shape();
if (x_shape != tensor_shape) {
return nullptr;
}
@ -638,7 +636,6 @@ class PConstant : public PBase<PConstant<T> > {
}
auto x_tensor_ptr = dyn_cast<tensor::Tensor>(x_value);
if ((x_tensor_ptr->DataSize() > 1) && (x_tensor_ptr->DataSize() != new_tensor_ptr->DataSize())) {
return nullptr;
}
@ -729,7 +726,6 @@ class PConstant : public PBase<PConstant<T> > {
auto value_1 = GetValueNode(vnode_1);
auto value_2 = GetValueNode(vnode_2);
if (!value_1->isa<tensor::Tensor>() || !value_2->isa<tensor::Tensor>()) {
return nullptr;
}
@ -744,14 +740,12 @@ class PConstant : public PBase<PConstant<T> > {
TypePtr tensor_1_type_ptr = tensor_1_abstract->element()->BuildType();
TypePtr tensor_2_type_ptr = tensor_2_abstract->element()->BuildType();
TypePtr tensor_3_type_ptr = tensor_3_abstract->element()->BuildType();
if ((tensor_1_type_ptr->type_id() != tensor_3_type_ptr->type_id()) ||
(tensor_2_type_ptr->type_id() != tensor_3_type_ptr->type_id())) {
return nullptr;
}
std::vector<int> tensor_out_shape = tensor_3_abstract->shape()->shape();
int data_out_size = std::accumulate(tensor_out_shape.begin(), tensor_out_shape.end(), 1, std::multiplies<int>());
if ((tensor_ptr_1->DataSize() > 1) && (tensor_ptr_1->DataSize() != data_out_size)) {
@ -872,7 +866,6 @@ BIN_OPERATION_PATTERN(operator*, prim::kPrimMul, true);
return rep; \
} \
}
} // namespace mindspore
#endif // MINDSPORE_CORE_IR_PATTERN_MATCHER_H_

@ -20,7 +20,6 @@
#include "abstract/abstract_function.h"
namespace mindspore {
static std::string MakeId() {
// Use atomic to make id generator thread safe.
static std::atomic<uint64_t> last_id{1};
@ -44,6 +43,7 @@ Primitive::Primitive(const Primitive &prim)
has_signature_(prim.has_signature_),
prim_type_(prim.prim_type_),
record_evaluate_add_attr_(false),
is_const_value_(false),
id_(prim.id_) {}
abstract::AbstractBasePtr Primitive::ToAbstract() {

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

Loading…
Cancel
Save