Merge pull request !4396 from Kang/opttags/v0.7.0-beta
| @@ -507,6 +507,5 @@ struct TraceProviderRegister { | |||||
| } | } | ||||
| ~TraceProviderRegister() = default; | ~TraceProviderRegister() = default; | ||||
| } trace_provider_regsiter; | } trace_provider_regsiter; | ||||
| } // namespace trace | } // namespace trace | ||||
| } // namespace mindspore | } // 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. | // 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 | // 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)}} | // 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; | std::map<SignatureEnumDType, std::vector<size_t>> type_indices; | ||||
| @@ -24,12 +24,10 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| /* namespace to support opt */ | /* namespace to support opt */ | ||||
| namespace opt { | namespace opt { | ||||
| bool GraphKernelReuse::CompareNode(const AnfNodePtr a, const AnfNodePtr b) { | bool GraphKernelReuse::CompareNode(const AnfNodePtr a, const AnfNodePtr b) { | ||||
| if (a->abstract() && b->abstract()) { | if (a->abstract() && b->abstract()) { | ||||
| auto a_type = a->abstract()->GetTypeTrack(); | auto a_type = a->abstract()->GetTypeTrack(); | ||||
| auto b_type = b->abstract()->GetTypeTrack(); | auto b_type = b->abstract()->GetTypeTrack(); | ||||
| if (a_type != b_type) { | if (a_type != b_type) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| @@ -132,7 +130,6 @@ bool GraphKernelReuse::DoReplace(const FuncGraphManagerPtr manager) { | |||||
| manager->Replace(iter.first->first, new_cnode); | manager->Replace(iter.first->first, new_cnode); | ||||
| changed = true; | changed = true; | ||||
| } | } | ||||
| } else { | } else { | ||||
| // Add current fg to map | // Add current fg to map | ||||
| graph_kernel_ops[key].push_back(fg); | graph_kernel_ops[key].push_back(fg); | ||||
| @@ -152,6 +149,5 @@ bool GraphKernelReuse::ReuseGraphKernel(const FuncGraphPtr root, const FuncGraph | |||||
| return DoReplace(manager); | return DoReplace(manager); | ||||
| } | } | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -25,7 +25,6 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace opt { | namespace opt { | ||||
| // Common subexpression elimination. | // Common subexpression elimination. | ||||
| class GraphKernelReuse { | class GraphKernelReuse { | ||||
| public: | public: | ||||
| @@ -46,7 +45,6 @@ class GraphKernelReuse { | |||||
| std::unordered_map<std::string, std::vector<FuncGraphPtr>> graph_kernel_ops; | std::unordered_map<std::string, std::vector<FuncGraphPtr>> graph_kernel_ops; | ||||
| int count; | int count; | ||||
| }; | }; | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CCSRC_FRONTEND_OPTIMIZER_GRAPH_KERNEL_OP_REUSE_H | #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 irpass | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -62,7 +62,6 @@ class ArithmeticSimplify2 : public OptimizerCaller { | |||||
| public: | public: | ||||
| AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override; | AnfNodePtr operator()(const OptimizerPtr &, const AnfNodePtr &node) override; | ||||
| }; | }; | ||||
| } // namespace irpass | } // namespace irpass | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -141,7 +141,6 @@ class ConvertSwitchReplacement : public OptimizerCaller { | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| }; | }; | ||||
| } // namespace irpass | } // namespace irpass | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -32,7 +32,6 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace opt { | namespace opt { | ||||
| namespace irpass { | namespace irpass { | ||||
| static int count = 0; | static int count = 0; | ||||
| std::string GetFusionNumber() { | std::string GetFusionNumber() { | ||||
| @@ -79,7 +78,6 @@ class MarkInterfaceFusion : public AnfVisitor { | |||||
| private: | private: | ||||
| AnfNodePtr y_{nullptr}; | AnfNodePtr y_{nullptr}; | ||||
| }; | }; | ||||
| } // namespace irpass | } // namespace irpass | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -203,7 +203,6 @@ class DependValueElim : public OptimizerCaller { | |||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| }; | }; | ||||
| } // namespace irpass | } // namespace irpass | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -33,7 +33,6 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace opt { | namespace opt { | ||||
| namespace irpass { | namespace irpass { | ||||
| const char PARSE_SUPER_NAME[] = "namespace"; | const char PARSE_SUPER_NAME[] = "namespace"; | ||||
| // {prim::kPrimResolve, Ns, Sym} | // {prim::kPrimResolve, Ns, Sym} | ||||
| @@ -108,7 +107,6 @@ class ResolveAttr : public OptimizerCaller { | |||||
| auto ns_ = GetValueNode<parse::NameSpacePtr>(ns_node.GetNode(node)); | auto ns_ = GetValueNode<parse::NameSpacePtr>(ns_node.GetNode(node)); | ||||
| auto sym_ = GetValueNode<parse::SymbolPtr>(sym_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) { | 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 | // deal with the case of getting attr from a class member | ||||
| // and avoid the case of getting attr from self (the result of ParseSuper) | // 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; | return nullptr; | ||||
| } | } | ||||
| } // namespace irpass | } // namespace irpass | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -30,7 +30,6 @@ | |||||
| namespace mindspore { | namespace mindspore { | ||||
| namespace opt { | namespace opt { | ||||
| namespace irpass { | namespace irpass { | ||||
| // {prim::kPrimSelect, {prim::kPrimGreater, X, 0}, Y, Z}} -> Y when X is always greater than 0 | // {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::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 | // {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; | return changed; | ||||
| } | } | ||||
| } // namespace python_pass | } // namespace python_pass | ||||
| } // namespace opt | } // namespace opt | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -49,6 +49,7 @@ using PatternNodeMap = std::unordered_map<PatternPtr, AnfNodePtr, PatternHasher, | |||||
| class Pattern : public Base { | class Pattern : public Base { | ||||
| public: | public: | ||||
| Pattern() : unique_name_(std::to_string(g_id_++)) {} | Pattern() : unique_name_(std::to_string(g_id_++)) {} | ||||
| ~Pattern() = default; | |||||
| virtual MatchResultPtr match(const AnfNodePtr &node) { return nullptr; } | virtual MatchResultPtr match(const AnfNodePtr &node) { return nullptr; } | ||||
| virtual bool operator==(const Pattern &other) const { return unique_name_ == other.unique_name_; } | virtual bool operator==(const Pattern &other) const { return unique_name_ == other.unique_name_; } | ||||
| string unique_name() const { return unique_name_; } | string unique_name() const { return unique_name_; } | ||||
| @@ -82,6 +83,7 @@ struct PatternHasher { | |||||
| class IsPrimTypeOf : public Pattern { | class IsPrimTypeOf : public Pattern { | ||||
| public: | public: | ||||
| IsPrimTypeOf() { unique_name_ = std::to_string(g_id_++); } | IsPrimTypeOf() { unique_name_ = std::to_string(g_id_++); } | ||||
| ~IsPrimTypeOf() = default; | |||||
| IsPrimTypeOf(vector<PrimitivePyPtr> prims, string name, bool should_replace) | IsPrimTypeOf(vector<PrimitivePyPtr> prims, string name, bool should_replace) | ||||
| : primitives_(prims), name_(name), matched_prim_(nullptr) { | : primitives_(prims), name_(name), matched_prim_(nullptr) { | ||||
| unique_name_ = std::to_string(g_id_++) + "_" + name; | unique_name_ = std::to_string(g_id_++) + "_" + name; | ||||
| @@ -120,6 +122,7 @@ class IsPrimTypeOf : public Pattern { | |||||
| class CallWith : public Pattern { | class CallWith : public Pattern { | ||||
| public: | public: | ||||
| CallWith() { unique_name_ = std::to_string(g_id_++); } | CallWith() { unique_name_ = std::to_string(g_id_++); } | ||||
| ~CallWith() = default; | |||||
| CallWith(PatternPtr prim_pattern, vector<PatternPtr> inputs, bool should_replace) { | 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 | // NOTE: should_replace is ignored in this case, since each sub-pattern has its own setting | ||||
| prim_pattern_ = prim_pattern; | prim_pattern_ = prim_pattern; | ||||
| @@ -154,6 +157,7 @@ class CallWith : public Pattern { | |||||
| class IsIn : public Pattern { | class IsIn : public Pattern { | ||||
| public: | public: | ||||
| IsIn() { unique_name_ = std::to_string(g_id_++); } | IsIn() { unique_name_ = std::to_string(g_id_++); } | ||||
| ~IsIn() = default; | |||||
| explicit IsIn(vector<PatternPtr> patterns) : patterns_(patterns) { | explicit IsIn(vector<PatternPtr> patterns) : patterns_(patterns) { | ||||
| unique_name_ = std::to_string(g_id_++); | unique_name_ = std::to_string(g_id_++); | ||||
| for (auto &iter : patterns) { | for (auto &iter : patterns) { | ||||
| @@ -170,6 +174,7 @@ class IsIn : public Pattern { | |||||
| class IsNot : public Pattern { | class IsNot : public Pattern { | ||||
| public: | public: | ||||
| IsNot() { unique_name_ = std::to_string(g_id_++); } | IsNot() { unique_name_ = std::to_string(g_id_++); } | ||||
| ~IsNot() = default; | |||||
| explicit IsNot(vector<PatternPtr> patterns) : patterns_(patterns) { | explicit IsNot(vector<PatternPtr> patterns) : patterns_(patterns) { | ||||
| unique_name_ = std::to_string(g_id_++); | unique_name_ = std::to_string(g_id_++); | ||||
| for (auto &iter : patterns) { | for (auto &iter : patterns) { | ||||
| @@ -186,6 +191,7 @@ class IsNot : public Pattern { | |||||
| class AnyPattern : public Pattern { | class AnyPattern : public Pattern { | ||||
| public: | public: | ||||
| AnyPattern() { unique_name_ = std::to_string(g_id_++) + "_AnyPattern"; } | AnyPattern() { unique_name_ = std::to_string(g_id_++) + "_AnyPattern"; } | ||||
| ~AnyPattern() = default; | |||||
| MS_DECLARE_PARENT(AnyPattern, Pattern); | MS_DECLARE_PARENT(AnyPattern, Pattern); | ||||
| MatchResultPtr match(const AnfNodePtr &node) override; | MatchResultPtr match(const AnfNodePtr &node) override; | ||||
| }; | }; | ||||
| @@ -193,6 +199,7 @@ class AnyPattern : public Pattern { | |||||
| class NewTensor : public Pattern { | class NewTensor : public Pattern { | ||||
| public: | public: | ||||
| NewTensor() { unique_name_ = std::to_string(g_id_++); } | NewTensor() { unique_name_ = std::to_string(g_id_++); } | ||||
| ~NewTensor() = default; | |||||
| explicit NewTensor(tensor::TensorPtr input_tensor) : input_tensor_(input_tensor) { should_replace_ = false; } | explicit NewTensor(tensor::TensorPtr input_tensor) : input_tensor_(input_tensor) { should_replace_ = false; } | ||||
| MS_DECLARE_PARENT(NewTensor, Pattern); | MS_DECLARE_PARENT(NewTensor, Pattern); | ||||
| MatchResultPtr match(const AnfNodePtr &node) override { | MatchResultPtr match(const AnfNodePtr &node) override { | ||||
| @@ -207,6 +214,7 @@ class NewTensor : public Pattern { | |||||
| class MatchResult { | class MatchResult { | ||||
| public: | public: | ||||
| MatchResult() {} | MatchResult() {} | ||||
| ~MatchResult() = default; | |||||
| void add_entry(PatternPtr pattern, AnfNodePtr node) { match_result_[pattern] = node; } | void add_entry(PatternPtr pattern, AnfNodePtr node) { match_result_[pattern] = node; } | ||||
| PatternNodeMap _result() { return match_result_; } | PatternNodeMap _result() { return match_result_; } | ||||
| AnfNodePtr get_node(const PatternPtr &pattern); | AnfNodePtr get_node(const PatternPtr &pattern); | ||||
| @@ -386,6 +386,5 @@ static inline uint64_t GetCurrentUSec() { | |||||
| do { \ | do { \ | ||||
| MS_LOG(INFO) << #stage << " called " << count_##stage << " times, costs " << total_##stage << " usec."; \ | MS_LOG(INFO) << #stage << " called " << count_##stage << " times, costs " << total_##stage << " usec."; \ | ||||
| } while (0) | } while (0) | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CCSRC_UTILS_UTILS_H_ | #endif // MINDSPORE_CCSRC_UTILS_UTILS_H_ | ||||
| @@ -146,6 +146,7 @@ void MsBackend::Link(GraphId graph_id) { | |||||
| Backend::Backend(const std::string &name) : name_(name) { | Backend::Backend(const std::string &name) : name_(name) { | ||||
| MS_LOG(DEBUG) << "select backend:" << name; | MS_LOG(DEBUG) << "select backend:" << name; | ||||
| convert_fn_ = backends[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) { | 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 { | 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) { | AnfNodePtrToAnfNodePtrMap *eqv_ptr) { | ||||
| MS_EXCEPTION_IF_NULL(fg); | MS_EXCEPTION_IF_NULL(fg); | ||||
| MS_EXCEPTION_IF_NULL(inputs_ptr); | MS_EXCEPTION_IF_NULL(inputs_ptr); | ||||
| @@ -215,7 +215,6 @@ AbstractBasePtr InferImplDictGetItem(const AnalysisEnginePtr &, const PrimitiveP | |||||
| std::vector<AbstractAttribute> dict_elems = dict->elements(); | std::vector<AbstractAttribute> dict_elems = dict->elements(); | ||||
| auto it = std::find_if(dict_elems.begin(), dict_elems.end(), | auto it = std::find_if(dict_elems.begin(), dict_elems.end(), | ||||
| [key_str](const AbstractAttribute &item) { return item.first == key_str; }); | [key_str](const AbstractAttribute &item) { return item.first == key_str; }); | ||||
| if (it == dict_elems.end()) { | if (it == dict_elems.end()) { | ||||
| MS_LOG(EXCEPTION) << "The key " << key_str << " does not exist in the dict:" << args_spec_list[0]->ToString(); | 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 { | class Conv2d : public PrimitiveC { | ||||
| public: | public: | ||||
| Conv2d(); | Conv2d(); | ||||
| ~Conv2d() = default; | |||||
| void Init(int out_channel, const std::vector<int> &kernel_size, int mode = 1, const std::string &pad_mode = "valid", | 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> &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); | const std::vector<int> &dilation = {1, 1, 1, 1}, int group = 1); | ||||
| @@ -27,6 +27,7 @@ namespace mindspore { | |||||
| class PrimitiveC : public Primitive { | class PrimitiveC : public Primitive { | ||||
| public: | public: | ||||
| explicit PrimitiveC(const std::string &name) : Primitive(name) {} | explicit PrimitiveC(const std::string &name) : Primitive(name) {} | ||||
| ~PrimitiveC() = default; | |||||
| AbstractBasePtr Infer(const AbstractBasePtrList &abstract_list); | AbstractBasePtr Infer(const AbstractBasePtrList &abstract_list); | ||||
| protected: | protected: | ||||
| @@ -23,10 +23,8 @@ | |||||
| #include "base/base.h" | #include "base/base.h" | ||||
| namespace mindspore { | namespace mindspore { | ||||
| struct TypeIdManager *TypeIdManager::Get() { | struct TypeIdManager *TypeIdManager::Get() { | ||||
| static TypeIdManager manager; | static TypeIdManager manager; | ||||
| return &manager; | return &manager; | ||||
| } | } | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -35,7 +35,6 @@ | |||||
| #include "utils/label.h" | #include "utils/label.h" | ||||
| namespace mindspore { | namespace mindspore { | ||||
| enum IncludeType { FOLLOW, NOFOLLOW, EXCLUDE }; | enum IncludeType { FOLLOW, NOFOLLOW, EXCLUDE }; | ||||
| using IncludeFunc = std::function<IncludeType(const AnfNodePtr &)>; | using IncludeFunc = std::function<IncludeType(const AnfNodePtr &)>; | ||||
| @@ -23,7 +23,6 @@ | |||||
| // namespace to support intermediate representation definition | // namespace to support intermediate representation definition | ||||
| namespace mindspore { | namespace mindspore { | ||||
| abstract::AbstractBasePtr MetaFuncGraph::ToAbstract() { | abstract::AbstractBasePtr MetaFuncGraph::ToAbstract() { | ||||
| return std::make_shared<abstract::MetaFuncGraphAbstractClosure>(shared_from_base<MetaFuncGraph>()); | return std::make_shared<abstract::MetaFuncGraphAbstractClosure>(shared_from_base<MetaFuncGraph>()); | ||||
| } | } | ||||
| @@ -579,7 +579,6 @@ class PConstant : public PBase<PConstant<T> > { | |||||
| if (!node->isa<ValueNode>()) { | if (!node->isa<ValueNode>()) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| auto value = node->cast<ValueNodePtr>()->value(); | auto value = node->cast<ValueNodePtr>()->value(); | ||||
| if (!value->isa<tensor::Tensor>()) { | if (!value->isa<tensor::Tensor>()) { | ||||
| @@ -622,7 +621,6 @@ class PConstant : public PBase<PConstant<T> > { | |||||
| } | } | ||||
| auto x_abstract = x->abstract()->cast<abstract::AbstractTensorPtr>(); | auto x_abstract = x->abstract()->cast<abstract::AbstractTensorPtr>(); | ||||
| std::vector<int> x_shape = x_abstract->shape()->shape(); | std::vector<int> x_shape = x_abstract->shape()->shape(); | ||||
| if (x_shape != tensor_shape) { | if (x_shape != tensor_shape) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -638,7 +636,6 @@ class PConstant : public PBase<PConstant<T> > { | |||||
| } | } | ||||
| auto x_tensor_ptr = dyn_cast<tensor::Tensor>(x_value); | auto x_tensor_ptr = dyn_cast<tensor::Tensor>(x_value); | ||||
| if ((x_tensor_ptr->DataSize() > 1) && (x_tensor_ptr->DataSize() != new_tensor_ptr->DataSize())) { | if ((x_tensor_ptr->DataSize() > 1) && (x_tensor_ptr->DataSize() != new_tensor_ptr->DataSize())) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -729,7 +726,6 @@ class PConstant : public PBase<PConstant<T> > { | |||||
| auto value_1 = GetValueNode(vnode_1); | auto value_1 = GetValueNode(vnode_1); | ||||
| auto value_2 = GetValueNode(vnode_2); | auto value_2 = GetValueNode(vnode_2); | ||||
| if (!value_1->isa<tensor::Tensor>() || !value_2->isa<tensor::Tensor>()) { | if (!value_1->isa<tensor::Tensor>() || !value_2->isa<tensor::Tensor>()) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| @@ -744,14 +740,12 @@ class PConstant : public PBase<PConstant<T> > { | |||||
| TypePtr tensor_1_type_ptr = tensor_1_abstract->element()->BuildType(); | TypePtr tensor_1_type_ptr = tensor_1_abstract->element()->BuildType(); | ||||
| TypePtr tensor_2_type_ptr = tensor_2_abstract->element()->BuildType(); | TypePtr tensor_2_type_ptr = tensor_2_abstract->element()->BuildType(); | ||||
| TypePtr tensor_3_type_ptr = tensor_3_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()) || | 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())) { | (tensor_2_type_ptr->type_id() != tensor_3_type_ptr->type_id())) { | ||||
| return nullptr; | return nullptr; | ||||
| } | } | ||||
| std::vector<int> tensor_out_shape = tensor_3_abstract->shape()->shape(); | 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>()); | 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)) { | 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; \ | return rep; \ | ||||
| } \ | } \ | ||||
| } | } | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CORE_IR_PATTERN_MATCHER_H_ | #endif // MINDSPORE_CORE_IR_PATTERN_MATCHER_H_ | ||||
| @@ -20,7 +20,6 @@ | |||||
| #include "abstract/abstract_function.h" | #include "abstract/abstract_function.h" | ||||
| namespace mindspore { | namespace mindspore { | ||||
| static std::string MakeId() { | static std::string MakeId() { | ||||
| // Use atomic to make id generator thread safe. | // Use atomic to make id generator thread safe. | ||||
| static std::atomic<uint64_t> last_id{1}; | static std::atomic<uint64_t> last_id{1}; | ||||
| @@ -44,6 +43,7 @@ Primitive::Primitive(const Primitive &prim) | |||||
| has_signature_(prim.has_signature_), | has_signature_(prim.has_signature_), | ||||
| prim_type_(prim.prim_type_), | prim_type_(prim.prim_type_), | ||||
| record_evaluate_add_attr_(false), | record_evaluate_add_attr_(false), | ||||
| is_const_value_(false), | |||||
| id_(prim.id_) {} | id_(prim.id_) {} | ||||
| abstract::AbstractBasePtr Primitive::ToAbstract() { | abstract::AbstractBasePtr Primitive::ToAbstract() { | ||||
| @@ -81,7 +81,7 @@ std::unique_ptr<T[]> NewData(Scalar scalar) { | |||||
| } | } | ||||
| template <typename T> | template <typename T> | ||||
| std::unique_ptr<T[]> CopyData(const std::vector<int> &shape, void *data, TypeId data_type) { | |||||
| std::unique_ptr<T[]> CopyData(const std::vector<int> &shape, void *const data, TypeId data_type) { | |||||
| const size_t size = SizeOf(shape); | const size_t size = SizeOf(shape); | ||||
| switch (data_type) { | switch (data_type) { | ||||
| case kNumberTypeBool: | case kNumberTypeBool: | ||||
| @@ -136,7 +136,7 @@ std::unique_ptr<T[]> CopyData(const std::vector<int> &shape, void *data, TypeId | |||||
| } | } | ||||
| template <typename T> | template <typename T> | ||||
| std::unique_ptr<T[]> CopyData(const std::vector<int> &shape, void *data, size_t data_len) { | |||||
| std::unique_ptr<T[]> CopyData(const std::vector<int> &shape, void *const data, size_t data_len) { | |||||
| size_t size = SizeOf(shape); | size_t size = SizeOf(shape); | ||||
| if (size * sizeof(T) != data_len) { | if (size * sizeof(T) != data_len) { | ||||
| MS_LOG(EXCEPTION) << "Incorrect tensor input data length " << data_len << ", expect " << size * sizeof(T) | MS_LOG(EXCEPTION) << "Incorrect tensor input data length " << data_len << ", expect " << size * sizeof(T) | ||||
| @@ -19,7 +19,6 @@ | |||||
| #include <memory> | #include <memory> | ||||
| namespace mindspore { | namespace mindspore { | ||||
| // only support (int, float, bool) as Literal | // only support (int, float, bool) as Literal | ||||
| bool AnyIsLiteral(const Any &any) { | bool AnyIsLiteral(const Any &any) { | ||||
| static const std::type_index typeid_int = std::type_index(typeid(int)); | static const std::type_index typeid_int = std::type_index(typeid(int)); | ||||
| @@ -53,5 +52,4 @@ Any &Any::operator=(Any &&other) { | |||||
| } | } | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -208,7 +208,6 @@ struct AnyLess { | |||||
| }; | }; | ||||
| bool AnyIsLiteral(const Any &any); | bool AnyIsLiteral(const Any &any); | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CORE_UTILS_ANY_H_ | #endif // MINDSPORE_CORE_UTILS_ANY_H_ | ||||
| @@ -20,7 +20,6 @@ | |||||
| #include "utils/ordered_map.h" | #include "utils/ordered_map.h" | ||||
| namespace mindspore { | namespace mindspore { | ||||
| template <typename T, class Hash = std::hash<T>, class Equal = std::equal_to<T>> | template <typename T, class Hash = std::hash<T>, class Equal = std::equal_to<T>> | ||||
| class Counter { | class Counter { | ||||
| using counter_type = Counter<T, Hash, Equal>; | using counter_type = Counter<T, Hash, Equal>; | ||||
| @@ -395,7 +395,6 @@ class LogConfigParser { | |||||
| bool flag_error = false; | bool flag_error = false; | ||||
| std::string text; | std::string text; | ||||
| auto tok = lexer.GetNext(&text); | auto tok = lexer.GetNext(&text); | ||||
| // empty string | // empty string | ||||
| if (tok == LogConfigToken::EOS) { | if (tok == LogConfigToken::EOS) { | ||||
| return log_levels; | return log_levels; | ||||
| @@ -33,6 +33,5 @@ extern const int RET_BREAK; | |||||
| // demangle the name to make it human reablable. | // demangle the name to make it human reablable. | ||||
| extern std::string demangle(const char *name); | extern std::string demangle(const char *name); | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CORE_UTILS_MISC_H_ | #endif // MINDSPORE_CORE_UTILS_MISC_H_ | ||||
| @@ -30,7 +30,6 @@ | |||||
| #include "utils/log_adapter.h" | #include "utils/log_adapter.h" | ||||
| namespace mindspore { | namespace mindspore { | ||||
| // Implementation of OrderedSet that keeps insertion order | // Implementation of OrderedSet that keeps insertion order | ||||
| // using map as set, and use list as a sequential container to record elements to keep insertion order | // using map as set, and use list as a sequential container to record elements to keep insertion order | ||||
| template <class T, class Hash = std::hash<T>, class KeyEqual = std::equal_to<T>> | template <class T, class Hash = std::hash<T>, class KeyEqual = std::equal_to<T>> | ||||
| @@ -277,7 +276,6 @@ class OrderedSet { | |||||
| map_type mapped_data_; | map_type mapped_data_; | ||||
| sequential_type ordered_data_; | sequential_type ordered_data_; | ||||
| }; | }; | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CORE_UTILS_ORDERED_SET_H_ | #endif // MINDSPORE_CORE_UTILS_ORDERED_SET_H_ | ||||
| @@ -361,5 +361,4 @@ void MsProfile::Print() { | |||||
| (void)printf("\nTime group info:\n%s", text.c_str()); | (void)printf("\nTime group info:\n%s", text.c_str()); | ||||
| (void)fflush(stdout); | (void)fflush(stdout); | ||||
| } | } | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -221,7 +221,6 @@ class MsProfile { | |||||
| std::map<std::string, TimeStat> time_stat_; // record time and count info from some activity | std::map<std::string, TimeStat> time_stat_; // record time and count info from some activity | ||||
| ProfileBase *profile_ = nullptr; // record hierarchical profile info | ProfileBase *profile_ = nullptr; // record hierarchical profile info | ||||
| }; | }; | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #ifdef ENABLE_PROFILE | #ifdef ENABLE_PROFILE | ||||
| @@ -21,7 +21,6 @@ | |||||
| #include <memory> | #include <memory> | ||||
| namespace mindspore { | namespace mindspore { | ||||
| std::ostream &operator<<(std::ostream &out, const std::shared_ptr<EnvInstance> &objPtr) { | std::ostream &operator<<(std::ostream &out, const std::shared_ptr<EnvInstance> &objPtr) { | ||||
| out << "("; | out << "("; | ||||
| MS_EXCEPTION_IF_NULL(objPtr); | MS_EXCEPTION_IF_NULL(objPtr); | ||||
| @@ -50,5 +49,4 @@ bool EnvInstance::operator==(const Value &other) const { | |||||
| return false; | return false; | ||||
| } | } | ||||
| std::shared_ptr<EnvInstance> newenv = std::make_shared<EnvInstance>(); | std::shared_ptr<EnvInstance> newenv = std::make_shared<EnvInstance>(); | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| @@ -29,7 +29,6 @@ | |||||
| #include "abstract/abstract_value.h" | #include "abstract/abstract_value.h" | ||||
| namespace mindspore { | namespace mindspore { | ||||
| class SymbolicKeyInstance : public Value { | class SymbolicKeyInstance : public Value { | ||||
| public: | public: | ||||
| SymbolicKeyInstance(const AnfNodePtr &node, const abstract::AbstractBasePtr &abstract) | SymbolicKeyInstance(const AnfNodePtr &node, const abstract::AbstractBasePtr &abstract) | ||||
| @@ -168,7 +167,6 @@ class EnvInstance : public Value { | |||||
| using EnvInstancePtr = std::shared_ptr<EnvInstance>; | using EnvInstancePtr = std::shared_ptr<EnvInstance>; | ||||
| extern std::shared_ptr<EnvInstance> newenv; | extern std::shared_ptr<EnvInstance> newenv; | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CORE_UTILS_SYMBOLIC_H_ | #endif // MINDSPORE_CORE_UTILS_SYMBOLIC_H_ | ||||
| @@ -38,7 +38,6 @@ namespace mindspore { | |||||
| #define MS_EXPORT __attribute__((visibility("default"))) | #define MS_EXPORT __attribute__((visibility("default"))) | ||||
| #define MS_LOCAL __attribute__((visibility("hidden"))) | #define MS_LOCAL __attribute__((visibility("hidden"))) | ||||
| #endif | #endif | ||||
| } // namespace mindspore | } // namespace mindspore | ||||
| #endif // MINDSPORE_CORE_UTILS_VISIBLE_H_ | #endif // MINDSPORE_CORE_UTILS_VISIBLE_H_ | ||||