diff --git a/src/common/log.cpp b/src/common/log.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3eb4d051c12005ea479de1c522f6291592bfae73 --- /dev/null +++ b/src/common/log.cpp @@ -0,0 +1,5 @@ +#include "log.h" + +namespace paddle_mobile { + +} diff --git a/src/common/log.h b/src/common/log.h index e62461c52f25c9797353c16a160c07f04a7eee71..eed5c821b874439f0e075d3ac300527216207fc9 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -1,32 +1,16 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #pragma once +#include #ifdef PADDLE_MOBILE_DEBUG - #include #include #include -#include +#endif namespace paddle_mobile { +#ifdef PADDLE_MOBILE_DEBUG + enum LogLevel { kNO_LOG, kLOG_ERROR, @@ -111,7 +95,6 @@ struct ToLog { << (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) \ << "] [line: " << __LINE__ << "] ") \ .str()) -} // namespace paddle_mobile #define LOGF(level, format, ...) \ if (level > paddle_mobile::log_level) { \ @@ -125,8 +108,6 @@ struct ToLog { #else -namespace paddle_mobile { - enum LogLevel { kNO_LOG, kLOG_ERROR, @@ -170,6 +151,17 @@ struct ToLog { #define LOGF(level, format, ...) #define DLOGF(format, ...) -} // namespace paddle_mobile #endif + +template +Print &operator<<(Print &printer, const std::vector &v) { + printer << "[ "; + for (const auto &value : v) { + printer << value << " "; + } + printer << " ]"; + return printer; +} + +} // namespace paddle_mobile \ No newline at end of file diff --git a/src/common/type_define.h b/src/common/type_define.h index 43eb6b2066712c59067c1a8fd580e7d1f75c5099..47d6c7090aa2188f730e0f47ba40485203b0b486 100644 --- a/src/common/type_define.h +++ b/src/common/type_define.h @@ -1,20 +1,3 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ #pragma once; #include diff --git a/src/common/types.h b/src/common/types.h index 61807be8701d4a86b9661a2563b469ba37d99612..058dc7feccf9c010978bfec525092c75d492cb92 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -1,21 +1,3 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #pragma once; namespace paddle_mobile { diff --git a/src/common/variant.cpp b/src/common/variant.cpp index e05a9d0df3445569908444aa83892e54f9c06acf..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -1,17 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ diff --git a/src/common/variant.h b/src/common/variant.h index b1b924059d83bad6b6ba969dcaa157e2e00619bc..051b8d09a3b959adabe291fe635e2ce28f5db4a0 100644 --- a/src/common/variant.h +++ b/src/common/variant.h @@ -1,23 +1,7 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #include +#include "common/log.h" + #pragma once namespace paddle_mobile { diff --git a/src/framework/attribute.cpp b/src/framework/attribute.cpp index a3b9cf6a4ffeb8e684d6b0eeafa93ff34142cef0..362775baaf269acb9cb33140f8f014aeba8afb68 100644 --- a/src/framework/attribute.cpp +++ b/src/framework/attribute.cpp @@ -1,21 +1,34 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ +#include "attribute.h" namespace paddle_mobile { -namespace framework {} +namespace framework { + + + +/* + * Variant, std::vector, + std::vector, bool, std::vector, BlockDesc *, + int64_t> + * */ + +struct PrintVistor: Vistor{ + PrintVistor(Print &printer):printer_(printer){ + } + template + Print &operator()(const T &value){ + printer_ << value; + return printer_; + } + private: + Print &printer_; +}; + +Print &operator<<(Print &printer, const Attribute &attr) { + Attribute::ApplyVistor(PrintVistor(printer), attr); +// std::vector v = {"1", "2"}; +// printer << (v); + return printer; +} + +} } // namespace paddle_mobile diff --git a/src/framework/attribute.h b/src/framework/attribute.h index c6cbb80442fadc8e9cf6cde97ff97bb7de91038b..f86cba41809a1339cf56c9464c891044e53ca43b 100644 --- a/src/framework/attribute.h +++ b/src/framework/attribute.h @@ -1,25 +1,8 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #pragma once +#include "common/log.h" #include "common/variant.h" -#include "framework.pb.h" +#include "framework/framework.pb.h" namespace paddle_mobile { namespace framework { @@ -104,6 +87,31 @@ class Attribute { return variant_.Get(); } + template + static typename Vistor::type_t ApplyVistor(Vistor vistor, Attribute attr) { + if (attr.variant_.TypeId() == typeid(int).hash_code()) { + return vistor(attr.variant_.Get()); + } else if (attr.variant_.TypeId() == typeid(float).hash_code()) { + return vistor(attr.variant_.Get()); + } else if (attr.variant_.TypeId() == typeid(std::string).hash_code()) { + return vistor(attr.variant_.Get()); + } else if (attr.variant_.TypeId() == typeid(std::vector).hash_code()) { + return vistor(attr.variant_.Get>()); + } else if (attr.variant_.TypeId() == typeid(std::vector).hash_code()) { + return vistor(attr.variant_.Get>()); + } else if (attr.variant_.TypeId() == typeid(std::vector).hash_code()) { + return vistor(attr.variant_.Get>()); + } else if (attr.variant_.TypeId() == typeid(bool).hash_code()) { + return vistor(attr.variant_.Get()); + } else if (attr.variant_.TypeId() == typeid(std::vector).hash_code()) { + return vistor(attr.variant_.Get>()); + } else if (attr.variant_.TypeId() == typeid(int64_t).hash_code()) { + return vistor(attr.variant_.Get()); + } else { + throw std::bad_exception(); + } + } + private: Variant, std::vector, std::vector, bool, std::vector, BlockDesc *, @@ -130,5 +138,10 @@ class AttrReader { const AttributeMap &attrs_; }; + + + +Print &operator<<(Print &printer, const Attribute &op_desc); + } // namespace framework } // namespace paddle_mobile diff --git a/src/framework/block_desc.cpp b/src/framework/block_desc.cpp deleted file mode 100644 index 5f7c1295f1103c711a1d7e551013635000039fad..0000000000000000000000000000000000000000 --- a/src/framework/block_desc.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#include "block_desc.h" - -namespace paddle_mobile { -namespace framework { - -std::vector> BlockDesc::Vars() const { - std::vector> res; - for (const auto &p : vars_) { - res.push_back(p.second); - } - return res; -} - -std::vector> BlockDesc::Ops() const { - std::vector> res; - for (const auto &op : ops_) { - res.push_back(op); - } - return res; -} - -BlockDesc::BlockDesc(const proto::BlockDesc &desc) : desc_(desc) { - for (const proto::VarDesc &var_desc : desc_.vars()) { - vars_[var_desc.name()].reset(new VarDesc(var_desc)); - } - for (const proto::OpDesc &op_desc : desc_.ops()) { - ops_.emplace_back(new framework::OpDesc(op_desc)); - } -} - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/block_desc.h b/src/framework/block_desc.h deleted file mode 100644 index 02ff14e52e1ca59dbb28f61193ec2b6352672416..0000000000000000000000000000000000000000 --- a/src/framework/block_desc.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#pragma once - -#include "framework.pb.h" -#include "op_desc.h" -#include "paddle_mobile_object.h" -#include "var_desc.h" - -namespace paddle_mobile { -namespace framework { - -class BlockDesc : PaddleMobileObject { - public: - BlockDesc(const proto::BlockDesc &desc); - - const int &ID() const { return desc_.idx(); } - - const int &Parent() const { return desc_.parent_idx(); } - - bool operator==(const paddle_mobile::framework::BlockDesc &in_block) const { - return this->ID() == in_block.ID() && this->Parent() == in_block.Parent(); - } - - bool operator<(const paddle_mobile::framework::BlockDesc &in_block) const { - return this->ID() < in_block.ID() && this->Parent() < in_block.Parent(); - } - - std::vector> Vars() const; - std::vector> Ops() const; - - private: - proto::BlockDesc desc_; - std::vector> ops_; - std::unordered_map> vars_; -}; - -} // namespace framework -} // namespace paddle_mobile - -namespace std { - -template <> -struct hash { - typedef paddle_mobile::framework::BlockDesc argument_type; - typedef std::size_t result_type; - result_type operator()(argument_type const &s) const noexcept { - result_type const h1(std::hash{}(s.ID())); - result_type const h2(std::hash{}(s.ID())); - return h1 ^ (h2 << 1); - } -}; - -} // namespace std diff --git a/src/framework/data_layout.h b/src/framework/data_layout.h index d669486fbceea08c10f9dcf2151b90e1e3ab19cc..99c011055bfb007657bad57ff88228e5462e553f 100644 --- a/src/framework/data_layout.h +++ b/src/framework/data_layout.h @@ -1,17 +1,3 @@ -/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - #pragma once #include diff --git a/src/framework/ddim.cc b/src/framework/ddim.cc index 8ea1946dd66b99fe6cb1c781efbb7581445ba7a0..db6f2cd6aba92fec6a42839c0e3198ac749807b0 100644 --- a/src/framework/ddim.cc +++ b/src/framework/ddim.cc @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "ddim.h" +#include namespace paddle_mobile { namespace framework { diff --git a/src/framework/executor.h b/src/framework/executor.h index 82a1430f05647b8dd5b0fa270dc44bae6dd0bb59..aaf87fb101bdb33913b8682faffd5e6ceca643f8 100644 --- a/src/framework/executor.h +++ b/src/framework/executor.h @@ -18,11 +18,11 @@ limitations under the License. */ #include #include -#include "block_desc.h" +#include "framework/program/block_desc.h" #include "framework.pb.h" #include "operator.h" -#include "program.h" -#include "program_desc.h" +#include "framework/program/program.h" +#include "framework/program/program_desc.h" #include "scope.h" #include "tensor.h" #include "variable.h" diff --git a/src/framework/framework.pb.h b/src/framework/framework.pb.h index fa75a92e57ddee571a611146e91fa93e8b943b60..c595963cb5c5a935cea839d7c98b84797550c6c4 100644 --- a/src/framework/framework.pb.h +++ b/src/framework/framework.pb.h @@ -124,7 +124,7 @@ void AddDescriptors(); void InitDefaults(); } // namespace protobuf_framework_2eproto -enum VarType_Type { +enum VarType_Type { VarType_Type_BOOL = 0, VarType_Type_INT16 = 1, VarType_Type_INT32 = 2, diff --git a/src/framework/op_desc.h b/src/framework/op_desc.h deleted file mode 100644 index e2465989bb0c65398de80128085b7eb546318eb3..0000000000000000000000000000000000000000 --- a/src/framework/op_desc.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#pragma once - -#include "common/type_define.h" -#include "framework.pb.h" -#include "paddle_mobile_object.h" - -namespace paddle_mobile { -namespace framework { - -class OpDesc : PaddleMobileObject { - public: - OpDesc(const proto::OpDesc &desc); - const std::vector &Input(const std::string &name) const; - const std::vector &Output(const std::string &name) const; - Attribute GetAttr(const std::string &name) const; - - const VariableNameMap &GetInputs() { return inputs_; } - - const VariableNameMap &GetOutputs() { return outputs_; } - - const AttributeMap &GetAttrMap() const; - - const std::string &Type() { return desc_.type(); }; - - private: - proto::OpDesc desc_; - VariableNameMap inputs_; - VariableNameMap outputs_; - AttributeMap attrs_; -}; - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/operator.h b/src/framework/operator.h index 4ec757582005c8da1c7c810c4dfebd50b85e8b64..527fb61aa7867fe4f433828f19655d58e9142432 100644 --- a/src/framework/operator.h +++ b/src/framework/operator.h @@ -18,17 +18,19 @@ limitations under the License. */ #include #include #include + #include "common/type_define.h" #include "common/types.h" #include "common/variant.h" -#include "framework/attribute.h" -#include "framework/block_desc.h" -#include "framework/op_info.h" -#include "framework/op_kernel_type.h" -#include "framework/paddle_mobile_object.h" #include "framework/scope.h" #include "framework/tensor.h" +#include "framework/op_info.h" #include "framework/variable.h" +#include "framework/attribute.h" +#include "framework/op_kernel_type.h" +#include "framework/program/block_desc.h" +#include "framework/paddle_mobile_object.h" +#include "framework/program/program-optimize/node.h" namespace paddle_mobile { namespace framework { @@ -102,5 +104,30 @@ class OpKernelBase : PaddleMobileObject { std::shared_ptr<::paddle_mobile::framework::Scope> scope) \ : parent_cls(type, inputs, outputs, attrs, scope) {} +class FusionOpMatcher: PaddleMobileObject{ + public: + FusionOpMatcher() {} + + virtual std::string Type() = 0; + + virtual void FolderNodes(Node &node) { + node.Folder(node_.Depth(), Type(), {}); + + } + + virtual Node &BeginNode() { + return node_; + } + + std::string BeginType() { + return node_.BeginType(); + } + + protected: + Node node_; + std::string type_; + std::shared_ptr new_opdesc_; +}; + } // namespace framework } // namespace paddle_mobile diff --git a/src/framework/paddle_mobile_object.cpp b/src/framework/paddle_mobile_object.cpp index eeaabe6ea423010f568e99a74b1db8d98c9e830a..8040ec7bb81572e7c9cdf1f042ba0a26b96359f6 100644 --- a/src/framework/paddle_mobile_object.cpp +++ b/src/framework/paddle_mobile_object.cpp @@ -1,19 +1 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #include "paddle_mobile_object.h" diff --git a/src/framework/paddle_mobile_object.h b/src/framework/paddle_mobile_object.h index 062bac75b26354cd5872cf6c2bf600a6847d3d46..1d426a8c390cdc324a8c2b08317ef7470d687b64 100644 --- a/src/framework/paddle_mobile_object.h +++ b/src/framework/paddle_mobile_object.h @@ -1,21 +1,3 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #pragma once #include diff --git a/src/framework/program-optimize/node.cpp b/src/framework/program-optimize/node.cpp deleted file mode 100644 index a6cc775e4ceb7161614a571fcd392b0090924791..0000000000000000000000000000000000000000 --- a/src/framework/program-optimize/node.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#include - -#include "node.h" - -namespace paddle_mobile { - -namespace framework { - -Node &Node::operator>(std::shared_ptr node) { - outputs_.push_back(node); - std::shared_ptr this_node; - node->inputs_.push_back(this); - return *node; -} - -bool Node::operator==(const Node &in) { - if (in.type_ == this->type_) { - if (this->outputs_.size() == in.outputs_.size()) { - for (int i = 0; i < outputs_.size(); ++i) { - if (!(*outputs_[i] == *in.outputs_[i])) { - return false; - } - } - } else { - return false; - } - } else { - return false; - } - return true; -} - -std::string Node::ToString(std::string blank, const Node *node) const { - std::stringstream ss; - ss << type_ << "-> \n"; - - if (inputs_.size() > 1 && node != inputs_.back()) { - return ss.str(); - } else if (inputs_.size() > 1 && node == inputs_.back()) { - ss << "\n" << blank << type_ << "\n"; - } - - for (int i = 0; i < outputs_.size(); ++i) { - ss << blank << outputs_[i]->ToString(blank + " ", this) << ""; - } - return ss.str(); -} - -std::string Node::ToString() const { return this->ToString(" ", this); } - -Node &Node::To(int index) { - if (index == 0) { - this->outputs_.clear(); - } - - for (int j = 0; j < this->outputs_.size(); ++j) { - outputs_[j]->To(index - 1); - } - return *this; -} - -uint Node::depth(uint begin) { - uint depth = 0; - begin++; - for (int i = 0; i < outputs_.size(); ++i) { - uint output_depth = outputs_[i]->depth(begin); - depth = output_depth > depth ? output_depth : depth; - } - return begin > depth ? begin : depth; -} - -Print &operator<<(Print &printer, const Node &node) { - printer << node.ToString(); - return printer; -} - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/program-optimize/node.h b/src/framework/program-optimize/node.h deleted file mode 100644 index 0a6cb0a524cc25eb48bc2c0511cdb25c4ca7cbd5..0000000000000000000000000000000000000000 --- a/src/framework/program-optimize/node.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#pragma once - -#include -#include - -#include "common/log.h" -#include "framework/op_desc.h" -#include "framework/paddle_mobile_object.h" - -namespace paddle_mobile { -namespace framework { - -class Node : PaddleMobileObject { - public: - Node(const std::string &type) : type_(type) {} - Node(std::shared_ptr op_desc) - : op_desc_(op_desc), type_(op_desc->Type()){}; - Node &operator>(std::shared_ptr node); - bool operator==(const Node &in); - std::string ToString() const; - Node &To(int index); - uint depth(uint begin = 0); - - private: - std::shared_ptr op_desc_; - std::string ToString(std::string blank, const Node *node) const; - std::vector> outputs_; - std::vector inputs_; - std::string type_; -}; - -Print &operator<<(Print &printer, const Node &node); -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/program-optimize/program_optimize.cpp b/src/framework/program-optimize/program_optimize.cpp deleted file mode 100644 index ea923790a9fecec31952b5b19eb86310c226df6f..0000000000000000000000000000000000000000 --- a/src/framework/program-optimize/program_optimize.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#include "program_optimize.h" - -namespace paddle_mobile { - -namespace framework { - -std::shared_ptr ProgramOptimize::Optimize() {} - -std::shared_ptr ProgramOptimize::FushionOptimize( - std::shared_ptr ori_des) { - for (int i = 0; i < ori_des->Blocks().size(); ++i) { - std::unordered_map> output_nodes; - std::shared_ptr begin_node; - auto block = ori_des->Block(i); - // DLOG << " ops size: " << block->Ops().size(); - for (int j = 0; j < block->Ops().size(); ++j) { - auto op = block->Ops()[j]; - auto op_type = op->Type(); - // DLOG << "op type: " << op_type << " index: " << j; - if (op_input_output_key.find(op->Type()) == op_input_output_key.end()) { - return NULL; - } - - std::shared_ptr node = std::make_shared(op); - if (j == 0) { - begin_node = node; - } - - auto input_keys = op_input_output_key.at(op->Type()).first; - for (auto input_key : input_keys) { - auto op_inputs = op->Input(input_key); - for (int l = 0; l < op_inputs.size(); ++l) { - std::string input_key = op_inputs[l]; - if (output_nodes.find(input_key) != output_nodes.end()) { - auto input_node = output_nodes[input_key]; - *input_node > node; - } - } - } - - auto output_keys = op_input_output_key.at(op_type).second; - for (auto output_key : output_keys) { - auto op_outputs = op->Output(output_key); - for (int k = 0; k < op_outputs.size(); ++k) { - output_nodes[op_outputs[k]] = node; - } - } - } - - DLOG << "node: \n" << *begin_node; - } - return ori_des; -} -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/program-optimize/program_optimize.h b/src/framework/program-optimize/program_optimize.h deleted file mode 100644 index bb32493bf2cf238d0ed81d2c71dccd93fce58666..0000000000000000000000000000000000000000 --- a/src/framework/program-optimize/program_optimize.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#pragma once - -#include "framework/operator.h" -#include "framework/program_desc.h" -#include "node.h" - -namespace paddle_mobile { - -namespace framework { -class ProgramOptimize { - public: - ProgramOptimize() {} - std::shared_ptr Optimize(); - std::shared_ptr FushionOptimize( - std::shared_ptr ori_des); - - private: - // std::shared_ptr ori_desc_; - std::vector>> - outputs_nodes_; -}; -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/program.cpp b/src/framework/program.cpp deleted file mode 100644 index a3b9cf6a4ffeb8e684d6b0eeafa93ff34142cef0..0000000000000000000000000000000000000000 --- a/src/framework/program.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -namespace paddle_mobile { -namespace framework {} -} // namespace paddle_mobile diff --git a/src/framework/program.h b/src/framework/program.h deleted file mode 100644 index 07f175bf37ddbe20de6532424a7e47b59ff0c69e..0000000000000000000000000000000000000000 --- a/src/framework/program.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#pragma once - -#include "common/types.h" -#include "paddle_mobile_object.h" -#include "program_desc.h" -#include "scope.h" - -namespace paddle_mobile { -namespace framework { - -template -class Program : PaddleMobileObject { - public: - std::shared_ptr originProgram; - std::shared_ptr optimizeProgram; - std::shared_ptr scope; - - private: -}; - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/program/block_desc.cpp b/src/framework/program/block_desc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..73295744060699d2b1e40d11c74d793ca1dee5f1 --- /dev/null +++ b/src/framework/program/block_desc.cpp @@ -0,0 +1,33 @@ +#include "block_desc.h" + +namespace paddle_mobile { +namespace framework { + +std::vector> BlockDesc::Vars() const { + std::vector> res; + for (const auto &p : vars_) { + res.push_back(p.second); + } + return res; +} + +std::vector> BlockDesc::Ops() const { + std::vector> res; + for (const auto &op : ops_) { + res.push_back(op); + } + return res; +} + +BlockDesc::BlockDesc(const proto::BlockDesc &desc): + index_(desc.idx()), parent_index_(desc.parent_idx()) { + for (const proto::VarDesc &var_desc : desc.vars()) { + vars_[var_desc.name()].reset(new VarDesc(var_desc)); + } + for (const proto::OpDesc &op_desc : desc.ops()) { + ops_.emplace_back(new framework::OpDesc(op_desc)); + } +} + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/block_desc.h b/src/framework/program/block_desc.h new file mode 100644 index 0000000000000000000000000000000000000000..810418a5161939fd09043cbe77c9fcbc12542334 --- /dev/null +++ b/src/framework/program/block_desc.h @@ -0,0 +1,71 @@ +#pragma once + +#include "framework/framework.pb.h" +#include "framework/program/op_desc.h" +#include "framework/program/var_desc.h" +#include "framework/paddle_mobile_object.h" + + +namespace paddle_mobile { +namespace framework { + +class BlockDesc : PaddleMobileObject { + public: + friend class Node; + friend class ProgramOptimize; + BlockDesc(const proto::BlockDesc &desc); + + BlockDesc(const BlockDesc &block_desc): + index_(block_desc.index_), + parent_index_(block_desc.parent_index_) { + for (auto &op_desc : block_desc.ops_) { + std::shared_ptr copy_op_desc = std::make_shared(*op_desc); + ops_.push_back(copy_op_desc); + } + + for (auto &var_desc : block_desc.vars_) { + std::shared_ptr copy_var_desc = + std::make_shared(*var_desc.second); + vars_[var_desc.first] = copy_var_desc; + } + } + + const int &ID() const { return index_; } + + const int &Parent() const { return parent_index_; } + + bool operator==(const paddle_mobile::framework::BlockDesc &in_block) const { + return this->ID() == in_block.ID() && this->Parent() == in_block.Parent(); + } + + bool operator<(const paddle_mobile::framework::BlockDesc &in_block) const { + return this->ID() < in_block.ID() && this->Parent() < in_block.Parent(); + } + + std::vector> Vars() const; + std::vector> Ops() const; + + private: + int index_; + int parent_index_; + std::vector> ops_; + std::unordered_map> vars_; +}; + +} // namespace framework +} // namespace paddle_mobile + +namespace std { + +template <> +struct hash { + typedef paddle_mobile::framework::BlockDesc argument_type; + typedef std::size_t result_type; + result_type operator()(argument_type const &s) const noexcept { + result_type const h1(std::hash{}(s.ID())); + result_type const h2(std::hash{}(s.ID())); + return h1 ^ (h2 << 1); + } +}; + +} // namespace std diff --git a/src/framework/op_desc.cpp b/src/framework/program/op_desc.cpp similarity index 61% rename from src/framework/op_desc.cpp rename to src/framework/program/op_desc.cpp index 73037ecf3077d5ef746929487eea22efdd0b3194..8853e95c7ab896ea228691e94d2e5a44c70df556 100644 --- a/src/framework/op_desc.cpp +++ b/src/framework/program/op_desc.cpp @@ -12,19 +12,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -// -// Created by liuRuiLong on 2018/5/4. -// -#include "framework/op_desc.h" #include #include +#include "framework/program/op_desc.h" + namespace paddle_mobile { namespace framework { -OpDesc::OpDesc(const proto::OpDesc &desc) : desc_(desc) { - for (int i = 0; i < desc_.inputs_size(); ++i) { - const proto::OpDesc::Var &var = desc_.inputs(i); +OpDesc::OpDesc(const proto::OpDesc &desc):type_(desc.type()) { + for (int i = 0; i < desc.inputs_size(); ++i) { + const proto::OpDesc::Var &var = desc.inputs(i); std::vector &args = inputs_[var.parameter()]; int arg_size = var.arguments_size(); for (int j = 0; j < arg_size; ++j) { @@ -32,8 +30,8 @@ OpDesc::OpDesc(const proto::OpDesc &desc) : desc_(desc) { } } - for (int i = 0; i < desc_.outputs_size(); ++i) { - const proto::OpDesc::Var &var = desc_.outputs(i); + for (int i = 0; i < desc.outputs_size(); ++i) { + const proto::OpDesc::Var &var = desc.outputs(i); std::vector &args = outputs_[var.parameter()]; int arg_size = var.arguments_size(); for (int j = 0; j < arg_size; ++j) { @@ -41,7 +39,7 @@ OpDesc::OpDesc(const proto::OpDesc &desc) : desc_(desc) { } } - for (const proto::OpDesc::Attr &attr : desc_.attrs()) { + for (const proto::OpDesc::Attr &attr : desc.attrs()) { std::string attr_name = attr.name(); if (attr.type() != proto::AttrType::BLOCK) { attrs_[attr_name] = Attribute::GetAttrValue(attr); @@ -62,9 +60,28 @@ Attribute OpDesc::GetAttr(const std::string &name) const { return it->second; } -const std::unordered_map &OpDesc::GetAttrMap() const { +std::unordered_map &OpDesc::GetAttrMap() { return attrs_; } +Print &operator<<(Print &printer, const OpDesc &op_desc) { + OpDesc &no_const_op_desc = const_cast(op_desc); + printer << "inputs: \n"; + for (const auto &input : no_const_op_desc.GetInputs()) { + printer << input.first << " : " << input.second << "\n"; + } + + printer << "outputs: \n"; + for (const auto &output : no_const_op_desc.GetOutputs()) { + printer << output.first << " : " << output.second << "\n"; + } + + printer << "outputs: \n"; + for (const auto &attr : no_const_op_desc.GetAttrMap()) { + printer << attr.first << " : " << attr.second << "\n"; + } + return printer; +} + } // namespace framework } // namespace paddle_mobile diff --git a/src/framework/program/op_desc.h b/src/framework/program/op_desc.h new file mode 100644 index 0000000000000000000000000000000000000000..ec8da73bd582057c8c571ee682d27c1470f16fc2 --- /dev/null +++ b/src/framework/program/op_desc.h @@ -0,0 +1,63 @@ +#pragma once + +#include +#include + +#include "common/log.h" +#include "common/type_define.h" +#include "framework/framework.pb.h" +#include "framework/paddle_mobile_object.h" + +namespace paddle_mobile { +namespace framework { + +class OpDesc : PaddleMobileObject { + public: + friend class ProgramOptimize; + friend class FusionOpMatcher; + friend class Node; + explicit OpDesc(const proto::OpDesc &desc); + + OpDesc(const OpDesc &op_desc): type_(op_desc.type_) { + this->inputs_ = op_desc.inputs_; + this->outputs_ = op_desc.outputs_; + this->attrs_ = op_desc.attrs_; + } + + OpDesc() { + } + const std::vector &Input(const std::string &name) const; + const std::vector &Output(const std::string &name) const; + Attribute GetAttr(const std::string &name) const; + + VariableNameMap &GetInputs() { return inputs_; } + + VariableNameMap &GetOutputs() { return outputs_; } + + AttributeMap &GetAttrMap(); + + const std::string &Type() { return type_; } + + void SetInputs(VariableNameMap inputs){ + inputs_ = inputs; + } + + void SetOutputs(VariableNameMap outputs){ + outputs_ = outputs; + } + + void SetAttrMap(AttributeMap attrs){ + attrs_ = attrs; + } + + private: + std::string type_; + VariableNameMap inputs_; + VariableNameMap outputs_; + AttributeMap attrs_; +}; + +Print &operator<<(Print &printer, const OpDesc &op_desc); + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program-optimize/fusion_op_register.cpp b/src/framework/program/program-optimize/fusion_op_register.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e4cbca7ba733e623411c6c94be597961dcbee4c0 --- /dev/null +++ b/src/framework/program/program-optimize/fusion_op_register.cpp @@ -0,0 +1 @@ +#include "fusion_op_register.h" diff --git a/src/framework/program/program-optimize/fusion_op_register.h b/src/framework/program/program-optimize/fusion_op_register.h new file mode 100644 index 0000000000000000000000000000000000000000..37c5c01d0d39949d47658f17dcf77bdf582fd5d9 --- /dev/null +++ b/src/framework/program/program-optimize/fusion_op_register.h @@ -0,0 +1,44 @@ +#pragma once + +#include +#include + +#include "framework/operator.h" +#include "node.h" + +namespace paddle_mobile { +namespace framework { + +class FusionOpRegister { + public: + static FusionOpRegister *Instance() { + static FusionOpRegister *regist = nullptr; + if (regist == nullptr) { + regist = new FusionOpRegister(); + } + return regist; + } + + void regist(FusionOpMatcher* matcher) { + std::shared_ptr shared_matcher(matcher); + matchers_[matcher->Type()] = shared_matcher; + } + + const std::map> Matchers() { + return matchers_; + } + + private: + std::map> matchers_; + FusionOpRegister() {} +}; + +class FusionOpRegistrar{ + public: + explicit FusionOpRegistrar(FusionOpMatcher* matcher){ + FusionOpRegister::Instance()->regist(matcher); + } +}; + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program-optimize/node.cpp b/src/framework/program/program-optimize/node.cpp new file mode 100644 index 0000000000000000000000000000000000000000..e47e0f227a7c8552d7862fa97cbacb11b6bda31c --- /dev/null +++ b/src/framework/program/program-optimize/node.cpp @@ -0,0 +1,207 @@ +#include + +#include "framework/program/program-optimize/node.h" + +namespace paddle_mobile { + +namespace framework { + +Node &Node::operator>(std::shared_ptr node) { + outputs_.push_back(node); + std::shared_ptr this_node; + node->inputs_.push_back(this); + return *node; +} + +bool Node::operator==(const Node &in) { + if (in.type_ == this->type_) { + if (this->outputs_.size() == in.outputs_.size()) { + for (int i = 0; i < outputs_.size(); ++i) { + if (!(*outputs_[i] == *in.outputs_[i])) { + return false; + } + } + } else { + return false; + } + } else { + return false; + } + return true; +} + +// std::shared_ptr Node::MatchTheFirstNode(std::string type){ +// +// for (const auto &node : outputs_){ +// if (node->type_ == type){ +// return node; +// }else{ +// +// } +// } +//} + +std::vector> Node::OpDescs(uint size) { + std::vector> op_descs; + OpDescs(size - 1, &op_descs); + return op_descs; +} + +void Node::OpDescs(uint index, + std::vector> *op_desc) { + if (index == 0) { + return; + } + op_desc->push_back(this->op_desc_); + for (auto &output : outputs_) { + output->OpDescs(index, op_desc); + } +} + +void Node::OpDescs(std::vector> *op_desc, Node *node) { + auto iter = std::find(op_desc->begin(), op_desc->end(), this->op_desc_); + if (inputs_.size() > 1 && node != inputs_.back()) { + return; + } else if (inputs_.size() > 1 && node == inputs_.back()) { + op_desc->push_back(this->op_desc_); + } else { + op_desc->push_back(this->op_desc_); + } + + for (auto &output : outputs_) { + output->OpDescs(op_desc, this); + } +} + +std::vector> Node::OpDescs() { + std::vector> op_descs; + OpDescs(&op_descs, this); + return op_descs; +} + +std::string Node::ToString(std::string blank, const Node *node) const { + std::stringstream ss; + ss << type_ << "-> \n"; + + if (inputs_.size() > 1 && node != inputs_.back()) { + return ss.str(); + } else if (inputs_.size() > 1 && node == inputs_.back()) { + ss << "\n" << blank << type_ << "\n"; + } + + for (int i = 0; i < outputs_.size(); ++i) { + ss << blank << outputs_[i]->ToString(blank + " ", this) << ""; + } + return ss.str(); +} + +std::string Node::ToString() const { return this->ToString(" ", this); } + +std::shared_ptr Node::To(int size) { + std::shared_ptr node = std::make_shared(); + this->To(size - 1, node); + return node; +} + +// Node &Node::To(int size) { +// if (size == 1) { +// this->outputs_.clear(); +// } +// +// for (int j = 0; j < this->outputs_.size(); ++j) { +// outputs_[j]->To(size - 1); +// } +// return *this; +//} + +void Node::To(int index, std::shared_ptr node) { + node->type_ = this->type_; + if (index != 0) { + } else { + return; + } + + for (int j = 0; j < this->outputs_.size(); ++j) { + std::shared_ptr sub_node = std::make_shared(); + node->outputs_.push_back(sub_node); + outputs_[j]->To(index - 1, sub_node); + } +} + +uint Node::Depth(uint begin) { + uint depth = 0; + begin++; + for (int i = 0; i < outputs_.size(); ++i) { + uint output_depth = outputs_[i]->Depth(begin); + depth = output_depth > depth ? output_depth : depth; + } + return begin > depth ? begin : depth; +} + +Node &Node::Folder( + uint size, std::string type, + std::map> change) { + std::shared_ptr op_desc = + std::make_shared(); + op_desc->inputs_ = this->op_desc_->inputs_; + std::vector> outputs; + this->Folder(op_desc, &outputs, size - 1, &change, this); + this->outputs_ = outputs; + this->type_ = type; + this->op_desc_ = op_desc; + this->op_desc_->type_ = type; + return *this; +} + +void Node::Folder( + std::shared_ptr op_desc, + std::vector> *outputs, uint index, + std::map> *change, + Node *begin_node) { + if (change->find(this->type_) != change->end()) { + auto change_pair = (*change)[this->type_]; + op_desc->GetInputs()[change_pair.second] = + this->op_desc_->GetInputs()[change_pair.first]; + } + + for (auto &attr_pair : this->op_desc_->attrs_) { + op_desc->attrs_.emplace(attr_pair.first, attr_pair.second); + } + if (index > 0) { + --index; + for (auto output : outputs_) { + output->Folder(op_desc, outputs, index, change, begin_node); + } + } else { + for (auto &op_output : this->op_desc_->outputs_) { + op_desc->outputs_.emplace(op_output.first, op_output.second); + } + + for (auto &output : this->outputs_) { + auto iter = + std::find(output->inputs_.begin(), output->inputs_.end(), this); + + if (iter != output->inputs_.end()) { + output->inputs_.erase(iter); + } + output->inputs_.push_back(begin_node); + outputs->push_back(output); + } + } +} + +void Node::Description() { + if (op_desc_.get()) { + DLOG << *op_desc_; + } else { + DLOG << " null "; + } +} + +Print &operator<<(Print &printer, const Node &node) { + printer << node.ToString(); + return printer; +} + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program-optimize/node.h b/src/framework/program/program-optimize/node.h new file mode 100644 index 0000000000000000000000000000000000000000..77dc9624d86b0ae4860bef602a98fa8c7ccad58f --- /dev/null +++ b/src/framework/program/program-optimize/node.h @@ -0,0 +1,54 @@ +#pragma once + +#include +#include +#include +#include + +#include "common/log.h" +#include "framework/program/op_desc.h" +#include "framework/paddle_mobile_object.h" + +namespace paddle_mobile { +namespace framework { + +class Node : PaddleMobileObject { + public: + Node() {} + explicit Node(const std::string &type) : type_(type) {} + explicit Node(std::shared_ptr op_desc) + : op_desc_(op_desc), type_(op_desc->Type()) {} + Node &operator>(std::shared_ptr node); + bool operator==(const Node &in); + std::string ToString() const; + std::shared_ptr To(int size); + uint Depth(uint begin = 0); + Node &Folder( + uint size, std::string type, + std::map> change_map); + std::vector> OpDescs(uint size); + std::vector> OpDescs(); + void OpDescs(std::vector> *op_desc, Node *node); + std::shared_ptr OpDesc() { return op_desc_; } + std::string BeginType() { return type_; } + void Description(); + + private: + void OpDescs(uint size, + std::vector> *op_desc); + void To(int index, std::shared_ptr); + void Folder( + std::shared_ptr op_desc, + std::vector> *outputs, uint index, + std::map> *change, + Node *begin_node); + std::shared_ptr op_desc_; + std::string ToString(std::string blank, const Node *node) const; + std::vector> outputs_; + std::vector inputs_; + std::string type_; +}; + +Print &operator<<(Print &printer, const Node &node); +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program-optimize/program_optimize.cpp b/src/framework/program/program-optimize/program_optimize.cpp new file mode 100644 index 0000000000000000000000000000000000000000..606edce3e6e282d6031069683b09bf9e93fdb4ac --- /dev/null +++ b/src/framework/program/program-optimize/program_optimize.cpp @@ -0,0 +1,93 @@ +#include "framework/program/program-optimize/program_optimize.h" +#include "framework/program/program-optimize/fusion_op_register.h" + +namespace paddle_mobile { + +namespace framework { + +std::shared_ptr ProgramOptimize::Optimize() {} + +std::shared_ptr ProgramOptimize::FushionOptimize( + std::shared_ptr ori_des) { + + ProgramDesc *optimize_program = new ProgramDesc(*ori_des); + + for (int i = 0; i < optimize_program->Blocks().size(); ++i) { + std::unordered_map> output_nodes; + std::unordered_map>> + type_map; + + std::shared_ptr begin_node; + auto block = optimize_program->Block(i); + // DLOG << " ops size: " << block->Ops().size(); + for (int j = 0; j < block->Ops().size(); ++j) { + auto op = block->Ops()[j]; + auto op_type = op->Type(); + if (op_input_output_key.find(op->Type()) == op_input_output_key.end()) { + LOG(kLOG_ERROR) << "return null "; + return nullptr; + } + + std::shared_ptr node = std::make_shared(op); + + // + type_map[op->Type()].push_back(node); + + if (j == 0) { + begin_node = node; + } + + auto input_keys = op_input_output_key.at(op->Type()).first; + for (auto input_key : input_keys) { + auto op_inputs = op->Input(input_key); + for (int l = 0; l < op_inputs.size(); ++l) { + std::string input_key = op_inputs[l]; + if (output_nodes.find(input_key) != output_nodes.end()) { + auto input_node = output_nodes[input_key]; + *input_node > node; + } + } + } + + auto output_keys = op_input_output_key.at(op_type).second; + for (auto output_key : output_keys) { + auto op_outputs = op->Output(output_key); + for (int k = 0; k < op_outputs.size(); ++k) { + output_nodes[op_outputs[k]] = node; + } + } + } + + for (auto ®isted : FusionOpRegister::Instance()->Matchers()) { + std::string fusion_type = registed.first; + std::shared_ptr matcher = registed.second; + // DLOG << " registed node \n " << matcher->BeginNode(); + + auto match_vector = type_map[matcher->BeginType()]; + + for (auto &match_node : match_vector) { + auto depth = matcher->BeginNode().Depth(); + auto sub_node = match_node->To(depth); + // DLOG << " sub node: " << *sub_node; + if (*sub_node == matcher->BeginNode()) { + // DLOG << " match success " << " fusion node: \n" << + // matcher->BeginNode() << "\nsub node: \n" << *sub_node; + // DLOG << "match node\n"<< *match_node; + matcher->FolderNodes(*match_node); + // DLOG << " after match node\n"<< *match_node; + // match_node->Description(); + + // DLOG << "begin node: \n" << *begin_node; + } + } + } + +// DLOG << "node: \n" << *begin_node; + block->ops_ = begin_node->OpDescs(); + + } + std::shared_ptr shared_optimzie(optimize_program); + return shared_optimzie; +} +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program-optimize/program_optimize.h b/src/framework/program/program-optimize/program_optimize.h new file mode 100644 index 0000000000000000000000000000000000000000..e23d56139997b1923e04757626ae5c9d19f1d164 --- /dev/null +++ b/src/framework/program/program-optimize/program_optimize.h @@ -0,0 +1,25 @@ +#pragma once + +#include +#include + +#include "framework/operator.h" +#include "framework/program/program_desc.h" +#include "node.h" + +namespace paddle_mobile { + +namespace framework { +class ProgramOptimize { + public: + ProgramOptimize() {} + std::shared_ptr Optimize(); + std::shared_ptr FushionOptimize( + std::shared_ptr ori_des); + private: + // std::shared_ptr ori_desc_; + std::vector>> + outputs_nodes_; +}; +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program.cpp b/src/framework/program/program.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9ed874e1b9a39bd3beda545e9204fbad9321c2ac --- /dev/null +++ b/src/framework/program/program.cpp @@ -0,0 +1,3 @@ +namespace paddle_mobile { +namespace framework {} +} // namespace paddle_mobile diff --git a/src/framework/program/program.h b/src/framework/program/program.h new file mode 100644 index 0000000000000000000000000000000000000000..603da8274b4c9784da9da5fb7fad68d1ef740949 --- /dev/null +++ b/src/framework/program/program.h @@ -0,0 +1,22 @@ +#pragma once + +#include "common/types.h" +#include "framework/paddle_mobile_object.h" +#include "framework/program/program_desc.h" +#include "framework/scope.h" + +namespace paddle_mobile { +namespace framework { + +template +class Program : PaddleMobileObject { + public: + std::shared_ptr originProgram; + std::shared_ptr optimizeProgram; + std::shared_ptr scope; + + private: +}; + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program_desc.cpp b/src/framework/program/program_desc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f8e4397a63627d52fc9364a768c26eed34abf9cf --- /dev/null +++ b/src/framework/program/program_desc.cpp @@ -0,0 +1,53 @@ +#include +#include + +#include "program_desc.h" + +namespace paddle_mobile { +namespace framework { + +ProgramDesc::ProgramDesc(const proto::ProgramDesc &desc) { + for (auto &block_desc : desc.blocks()) { + // new framework::BlockDesc(block_desc) + blocks_.emplace_back(std::make_shared(block_desc)); + } +} + +void ProgramDesc::Description(std::string header) { +#ifdef PADDLE_MOBILE_DEBUG + if (header.size()){ + LOG(kLOG_INFO) << header; + } + for (const auto &block : this->blocks_) { + LOG(kLOG_DEBUG) << "block: " << block->ID(); + LOG(kLOG_INFO) << "block ops size: " << block->Ops().size(); + for (int j = 0; j < block->Ops().size(); ++j) { + const auto &op = block->Ops()[j]; + LOG(kLOG_DEBUG1) << "op: " << op->Type(); + for (auto &input : op->GetInputs()) { + LOG(kLOG_DEBUG2) << "input parameter: " << input.first; + for (auto &n : input.second) { + LOG(kLOG_DEBUG3) << "argument - " << n; + } + } + for (auto &output : op->GetOutputs()) { + LOG(kLOG_DEBUG2) << "output parameter: " << output.first; + for (auto &n : output.second) { + LOG(kLOG_DEBUG3) << "argument - " << n; + } + } + for (auto &attr : op->GetAttrMap()) { + LOG(kLOG_DEBUG2) << "attr name:: " << attr.first; + LOG(kLOG_DEBUG3) << "argument - " << attr.second; + } + } + } +#endif +} + +std::shared_ptr ProgramDesc::Block(size_t idx) { + return blocks_[idx]; +} + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/program_desc.h b/src/framework/program/program_desc.h new file mode 100644 index 0000000000000000000000000000000000000000..adf201aab6d485589504446639ae391bbae501d9 --- /dev/null +++ b/src/framework/program/program_desc.h @@ -0,0 +1,33 @@ +#pragma once + +#include + +#include "common/types.h" +#include "framework/program/block_desc.h" +#include "framework/paddle_mobile_object.h" + +namespace paddle_mobile { +namespace framework { + +class ProgramDesc : PaddleMobileObject { + public: + friend class Node; + friend class ProgramOptimize; + explicit ProgramDesc(const proto::ProgramDesc &desc); + std::shared_ptr Block(size_t idx); + const std::vector> &Blocks() { return blocks_; } + ProgramDesc(const ProgramDesc &program_desc) { + for (auto &block : program_desc.blocks_) { + std::shared_ptr copy_block = + std::make_shared(*block); + blocks_.push_back(copy_block); + } + } + + void Description(std::string header = ""); + private: + std::vector> blocks_; +}; + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/program/var_desc.cpp b/src/framework/program/var_desc.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d5dd6442862422c73b4f222da558c820605c2a39 --- /dev/null +++ b/src/framework/program/var_desc.cpp @@ -0,0 +1,10 @@ +#include "var_desc.h" + +namespace paddle_mobile { + +namespace framework { + +VarDesc::VarDesc(const proto::VarDesc &desc) : desc_(desc) {} + +} // namespace framework +} // namespace paddle_mobile diff --git a/src/framework/var_desc.h b/src/framework/program/var_desc.h similarity index 58% rename from src/framework/var_desc.h rename to src/framework/program/var_desc.h index 82d07a383e640efa77b9c06c7ba0136a64ec7e14..4a963e8d6d216c25a6a82d6bff4be41706c3e16f 100644 --- a/src/framework/var_desc.h +++ b/src/framework/program/var_desc.h @@ -1,25 +1,7 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #pragma once -#include "framework.pb.h" -#include "paddle_mobile_object.h" +#include "framework/framework.pb.h" +#include "framework/paddle_mobile_object.h" namespace paddle_mobile { namespace framework { @@ -28,6 +10,8 @@ class VarDesc { public: VarDesc(const proto::VarDesc &desc); + VarDesc(const VarDesc &var_desc):desc_(var_desc.desc_) {} + std::string Name() const { return desc_.name(); } proto::VarType::Type GetType() const { return desc_.type().type(); } diff --git a/src/framework/program_desc.cpp b/src/framework/program_desc.cpp deleted file mode 100644 index 5537dacdebccd5533b79b7331ad6bb77699d9b93..0000000000000000000000000000000000000000 --- a/src/framework/program_desc.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. */ - -// -// Created by liuRuiLong on 2018/5/4. -// - -#include "framework/program_desc.h" - -namespace paddle_mobile { -namespace framework { - -ProgramDesc::ProgramDesc(const proto::ProgramDesc &desc) : desc_(desc) { - for (auto &block_desc : *desc_.mutable_blocks()) { - // new framework::BlockDesc(block_desc) - blocks_.emplace_back(std::make_shared(block_desc)); - } -} - -std::shared_ptr ProgramDesc::Block(size_t idx) { - return blocks_[idx]; -} - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/program_desc.h b/src/framework/program_desc.h deleted file mode 100644 index 79adc70a6f7520942246af6f863be972ca4f1039..0000000000000000000000000000000000000000 --- a/src/framework/program_desc.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#pragma once - -#include - -#include "block_desc.h" -#include "common/types.h" -#include "paddle_mobile_object.h" - -namespace paddle_mobile { -namespace framework { - -class ProgramDesc : PaddleMobileObject { - public: - ProgramDesc(const proto::ProgramDesc &desc); - std::shared_ptr Block(size_t idx); - const std::vector> &Blocks() { return blocks_; }; - - private: - std::vector> blocks_; - proto::ProgramDesc desc_; -}; - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/scope.h b/src/framework/scope.h index 13e569e52bc89ad287fb76b471fc770f8bf1924c..907f7f241f54c0db9b51c1e9ff3f56bd46465a63 100644 --- a/src/framework/scope.h +++ b/src/framework/scope.h @@ -1,21 +1,3 @@ - -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ #pragma once #include //std::list diff --git a/src/framework/selected_rows.h b/src/framework/selected_rows.h index 3488450e234ad073b6e9eff25502a329b3c79d70..e295564009dbf23bf35fdc60d211eff87c13ca50 100644 --- a/src/framework/selected_rows.h +++ b/src/framework/selected_rows.h @@ -1,21 +1,3 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #pragma once #include diff --git a/src/framework/var_desc.cpp b/src/framework/var_desc.cpp deleted file mode 100644 index f0049e04897e00d36a9e0c2c0ec00e6249ca7b6d..0000000000000000000000000000000000000000 --- a/src/framework/var_desc.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - -#include "var_desc.h" - -namespace paddle_mobile { - -namespace framework { - -VarDesc::VarDesc(const proto::VarDesc &desc) : desc_(desc) {} - -} // namespace framework -} // namespace paddle_mobile diff --git a/src/framework/var_type.h b/src/framework/var_type.h index 8ead7901d526f3a0a8ddcef6888178254a3ebb73..a539a49d3f4333c499a4648291455d12927246ef 100644 --- a/src/framework/var_type.h +++ b/src/framework/var_type.h @@ -1,21 +1,3 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ - #pragma once #include "framework.pb.h" #include "lod_tensor.h" diff --git a/src/framework/variable.h b/src/framework/variable.h index 3a9cf3843ff4745f374c18f8a5dcbb05ad329149..78c402e34008c14c0f1b4b606d781c44c84fe598 100644 --- a/src/framework/variable.h +++ b/src/framework/variable.h @@ -1,21 +1,3 @@ - -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ #pragma once #include diff --git a/src/io.cpp b/src/io.cpp index 60fde1c08fe9309271d15834f552727a2650cfc8..f11764e72649c24aea34bc750f5e3bce9bf81926 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -14,14 +14,14 @@ limitations under the License. */ #include -#include "../src/io.h" +#include "io.h" #include "common/log.h" -#include "framework/framework.pb.h" -#include "framework/lod_tensor.h" -#include "framework/program_desc.h" #include "framework/scope.h" #include "framework/tensor.h" -#define PADDLE_MOBILE_DEBUG 1 +#include "framework/lod_tensor.h" +#include "framework/framework.pb.h" +#include "framework/program/program_desc.h" + namespace paddle_mobile { void ReadBinaryFile(const std::string &filename, std::string *contents) { @@ -152,7 +152,7 @@ const framework::Program Loader::Load( LoadVar(tensor, dirname + "/" + var_desc->Name()); } } else { - // TODO by someone + // TODO(codeWorm): some. } } } @@ -303,7 +303,7 @@ const framework::Program Loader::Load( is.read(static_cast(memory), memory_size * type_size); is.close(); } else { - // TODO + // TODO } } } diff --git a/src/io.h b/src/io.h index e177792ee0e4749df75b31c8e95595652ce390ec..7a8d5863ebae90861d0b6d999a185e5755b6b57f 100644 --- a/src/io.h +++ b/src/io.h @@ -19,7 +19,7 @@ limitations under the License. */ #include "common/types.h" #include "framework/lod_tensor.h" #include "framework/paddle_mobile_object.h" -#include "framework/program.h" +#include "framework/program/program.h" namespace paddle_mobile { diff --git a/src/operators/fusion_conv_add_relu_op.cpp b/src/operators/fusion_conv_add_relu_op.cpp new file mode 100644 index 0000000000000000000000000000000000000000..379092b469e43433ffd0d94b76da30d5ced0b756 --- /dev/null +++ b/src/operators/fusion_conv_add_relu_op.cpp @@ -0,0 +1 @@ +#include "fusion_conv_add_relu_op.h" diff --git a/src/operators/fusion_conv_add_relu_op.h b/src/operators/fusion_conv_add_relu_op.h new file mode 100644 index 0000000000000000000000000000000000000000..991f67396bd41fb115b4e36c75d195e3e489858a --- /dev/null +++ b/src/operators/fusion_conv_add_relu_op.h @@ -0,0 +1,34 @@ +#pragma once + +#include "framework/operator.h" +#include "framework/program/program-optimize/fusion_op_register.h" + +namespace paddle_mobile { +namespace operators { + +class FushionConvAddReluOpMatcher : public framework::FusionOpMatcher { + public: + FushionConvAddReluOpMatcher() { + node_ = framework::Node("conv2d"); + node_ > std::make_shared("elementwise_add") > std::make_shared("relu"); + } + + void FolderNodes(framework::Node &node) { + std::vector> origin_descs = node.OpDescs(node_.Depth()); + node.Folder(node_.Depth(), Type(), {{"elementwise_add" , {"Y", "Z"}}}); + } + + std::string Type() { + return "FusionConvAddRelu"; + } +}; + +class FusionFcOp { + public: + private: +}; + +static framework::FusionOpRegistrar fc_registrar(new FushionConvAddReluOpMatcher()); + +} +} diff --git a/src/operators/fusion_fc_op.cpp b/src/operators/fusion_fc_op.cpp new file mode 100644 index 0000000000000000000000000000000000000000..486b4799a70ea59f47b62bf457a12fe2290d4ecc --- /dev/null +++ b/src/operators/fusion_fc_op.cpp @@ -0,0 +1 @@ +#include "fusion_fc_op.h" \ No newline at end of file diff --git a/src/operators/fusion_fc_op.h b/src/operators/fusion_fc_op.h new file mode 100644 index 0000000000000000000000000000000000000000..eb03ced84f321c6bfd4b59867d59451f12f935e3 --- /dev/null +++ b/src/operators/fusion_fc_op.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +#include "framework/operator.h" +#include "framework/program/program-optimize/fusion_op_register.h" + +namespace paddle_mobile { +namespace operators { + +class FusionFcMatcher : public framework::FusionOpMatcher { + public: + FusionFcMatcher() { + node_ = framework::Node("mul"); + node_ > std::make_shared("elementwise_add"); + } + + void FolderNodes(framework::Node &node) { + std::vector> origin_descs = node.OpDescs(node_.Depth()); + node.Folder(node_.Depth(), Type(), {{"elementwise_add" , {"Y", "Z"}}}); + } + + std::string Type() { + return "fc"; + } +}; + +class FusionFcOp { + public: + private: +}; + +static framework::FusionOpRegistrar fc_registrar(new FusionFcMatcher()); + +} // namespace operators +} // namespace paddle_mobile diff --git a/src/platform/data_type.h b/src/platform/data_type.h index 401c7eb119e273ab04dd64b864618696865360e6..86e5c0ac7759252f2caec3c380ffec9e6f5d03b5 100644 --- a/src/platform/data_type.h +++ b/src/platform/data_type.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved. +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/test/common/test_log.cpp b/test/common/test_log.cpp index 777743b4fe4dcc1d9eca4dfcd8bc6c9fc0198142..6707d9ccd9e0a1b10ad6a4a61fac02363bc18b6d 100644 --- a/test/common/test_log.cpp +++ b/test/common/test_log.cpp @@ -1,3 +1,17 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + #include "common/log.h" int main() { diff --git a/test/framework/test_load.cpp b/test/framework/test_load.cpp index 153429bae6a910780e9a09cc4f76e249df8aa65d..d805070675e978ed2e413aacd3e23b8eb363ae32 100644 --- a/test/framework/test_load.cpp +++ b/test/framework/test_load.cpp @@ -1,20 +1,16 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ #include "io.h" diff --git a/test/framework/test_optimize.cpp b/test/framework/test_optimize.cpp index f11531f8adfb17b12ee9f6381f3110842e96685c..5a85c4edaf367fcdc741578b20adf3c0f02ca46d 100644 --- a/test/framework/test_optimize.cpp +++ b/test/framework/test_optimize.cpp @@ -1,23 +1,19 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. -#include "framework/program-optimize/node.h" -#include "framework/program-optimize/program_optimize.h" +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ + +#include "framework/program/program-optimize/node.h" +#include "framework/program/program-optimize/program_optimize.h" #include "io.h" using namespace paddle_mobile; @@ -28,13 +24,13 @@ int main() { Loader loader; // "../../../test/models/googlenet" auto program = loader.Load("../models/googlenet"); - ProgramOptimize optimize; - +// program.originProgram->Description("origin"); auto optimize_program = optimize.FushionOptimize(program.originProgram); - if (optimize_program) { - + if (optimize_program != nullptr) { +// optimize_program->Description("optimize"); } else { - DLOG << "optimize_program is null"; + LOG(kLOG_ERROR) << "optimize_program is null"; } + return 0; } diff --git a/test/operators/test_cov_op.cpp b/test/operators/test_cov_op.cpp index b460040d13da3cf3b79d00622670e1c8c76b598f..4e88b86ba542c2efe995d90d32c566f323c6793e 100644 --- a/test/operators/test_cov_op.cpp +++ b/test/operators/test_cov_op.cpp @@ -1,20 +1,16 @@ -/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==============================================================================*/ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. */ #include "../framework/executor_for_test.h" #include "../test_helper.h" @@ -22,6 +18,7 @@ SOFTWARE. int main() { paddle_mobile::Loader loader; + //../models/image_classification_resnet.inference.model auto program = loader.Load(std::string("../models/googlenet")); if (program.originProgram == nullptr) { DLOG << "program file read fail"; diff --git a/test/test_include.h b/test/test_include.h index 27ed715b2dbf80aba35a10699596601e94f001d6..092ebe7c3dc1003cc6f8a67f13a5d4ea775cde7a 100644 --- a/test/test_include.h +++ b/test/test_include.h @@ -12,17 +12,18 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#include "framework/block_desc.h" +#include +#include +#include + +#include "framework/program/block_desc.h" #include "framework/framework.pb.h" #include "framework/lod_tensor.h" #include "framework/operator.h" -#include "framework/program.h" -#include "framework/program_desc.h" +#include "framework/program/program.h" +#include "framework/program/program_desc.h" #include "framework/scope.h" #include "framework/tensor.h" #include "framework/variable.h" #include "io.h" #include "test_helper.h" -#include -#include -#include \ No newline at end of file