diff --git a/paddleslim/core/__init__.pyc b/paddleslim/core/__init__.pyc deleted file mode 100644 index e532c8d43acacca16231998b9717c3d81d7b94d8..0000000000000000000000000000000000000000 Binary files a/paddleslim/core/__init__.pyc and /dev/null differ diff --git a/paddleslim/core/graph_wrapper.pyc b/paddleslim/core/graph_wrapper.pyc deleted file mode 100644 index 591351096db4cc217efe7320165cd2f13ca1ddb2..0000000000000000000000000000000000000000 Binary files a/paddleslim/core/graph_wrapper.pyc and /dev/null differ diff --git a/paddleslim/nas/searchspacebase.py b/paddleslim/nas/search_space_base.py similarity index 100% rename from paddleslim/nas/searchspacebase.py rename to paddleslim/nas/search_space_base.py diff --git a/paddleslim/nas/searchspacefactory.py b/paddleslim/nas/search_space_factory.py similarity index 100% rename from paddleslim/nas/searchspacefactory.py rename to paddleslim/nas/search_space_factory.py diff --git a/paddleslim/nas/searchspace/base_layer.py b/paddleslim/nas/searchspace/layer.py similarity index 100% rename from paddleslim/nas/searchspace/base_layer.py rename to paddleslim/nas/searchspace/layer.py diff --git a/paddleslim/nas/searchspace/mobilenetv2_space.py b/paddleslim/nas/searchspace/mobilenetv2_space.py index e09e00a6d8d685dff6e0e373ad97629b48dafd2a..bf224d6f6fb56b29fbee5e297f7a95650bd20dbd 100644 --- a/paddleslim/nas/searchspace/mobilenetv2_space.py +++ b/paddleslim/nas/searchspace/mobilenetv2_space.py @@ -16,13 +16,11 @@ from __future__ import absolute_import from __future__ import division from __future__ import print_function -import sys -sys.path.append('..') import numpy as np import paddle.fluid as fluid from paddle.fluid.param_attr import ParamAttr -from searchspacebase import SearchSpaceBase -from .base_layer import conv_bn_layer +from ..search_space_base import SearchSpaceBase +from .layer import conv_bn_layer from .registry import SEARCHSPACE @SEARCHSPACE.register_module diff --git a/paddleslim/nas/searchspace/registry.py b/paddleslim/nas/searchspace/registry.py index 33fb7212e99c886e4ad720f21db145e6f0e2443f..69fd9edf6cc97b1b71935f8b82d3056544fced42 100644 --- a/paddleslim/nas/searchspace/registry.py +++ b/paddleslim/nas/searchspace/registry.py @@ -1,5 +1,3 @@ -import sys -sys.path.append('..') -from utils.registry import Registry +from ..utils.registry import Registry SEARCHSPACE = Registry('searchspace') diff --git a/paddleslim/nas/test_searchspace.py b/paddleslim/nas/test_searchspace.py deleted file mode 100644 index 4761bf36e2722dfed83acfd69621a4e586a2ed93..0000000000000000000000000000000000000000 --- a/paddleslim/nas/test_searchspace.py +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2019 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. - -import paddle.fluid as fluid -from searchspacefactory import SearchSpaceFactory -if __name__ == '__main__': - # if output_size is 1, the model will add fc layer in the end. - config = {'input_size': 224, 'output_size': 7, 'block_num': 5} - space = SearchSpaceFactory() - - my_space = space.get_search_space('MobileNetV2Space', config) - model_arch = my_space.token2arch() - - train_prog = fluid.Program() - startup_prog = fluid.Program() - with fluid.program_guard(train_prog, startup_prog): - input_size= config['input_size'] - model_input = fluid.layers.data(name='model_in', shape=[1, 3, input_size, input_size], dtype='float32', append_batch_size=False) - print('input shape', model_input.shape) - predict = model_arch(model_input) - print('output shape', predict.shape) - - - #for op in train_prog.global_block().ops: - # print(op.type) diff --git a/paddleslim/prune/pruner.py b/paddleslim/prune/pruner.py index aa7f0f5987b02cb9b3631a9084b3e2e79c1c3627..30341f63407aa1b0cc52ec5b43eadead27aec2ab 100644 --- a/paddleslim/prune/pruner.py +++ b/paddleslim/prune/pruner.py @@ -14,7 +14,7 @@ import numpy as np import paddle.fluid as fluid -from ..core import VarWrapper, OpWrapper, GraphWrapper +from core import VarWrapper, OpWrapper, GraphWrapper __all__ = ["prune"] diff --git a/tests/layers.py b/paddleslim/tests/layers.py similarity index 100% rename from tests/layers.py rename to paddleslim/tests/layers.py diff --git a/paddleslim/tests/test_nas_search_space.py b/paddleslim/tests/test_nas_search_space.py new file mode 100644 index 0000000000000000000000000000000000000000..c2f2af5b8b9fac38a6d8f1273e853aefc6983bff --- /dev/null +++ b/paddleslim/tests/test_nas_search_space.py @@ -0,0 +1,43 @@ +# Copyright (c) 2019 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. + +import sys +sys.path.append('..') +import unittest +import paddle.fluid as fluid +from nas.search_space_factory import SearchSpaceFactory + +class TestSearchSpace(unittest.TestCase): + def test_searchspace(self): + # if output_size is 1, the model will add fc layer in the end. + config = {'input_size': 224, 'output_size': 7, 'block_num': 5} + space = SearchSpaceFactory() + + my_space = space.get_search_space('MobileNetV2Space', config) + model_arch = my_space.token2arch() + + train_prog = fluid.Program() + startup_prog = fluid.Program() + with fluid.program_guard(train_prog, startup_prog): + input_size= config['input_size'] + model_input = fluid.layers.data(name='model_in', shape=[1, 3, input_size, input_size], dtype='float32', append_batch_size=False) + predict = model_arch(model_input) + self.assertTrue(predict.shape[2] == config['output_size']) + + + #for op in train_prog.global_block().ops: + # print(op.type) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/test_prune.py b/paddleslim/tests/test_prune.py similarity index 98% rename from tests/test_prune.py rename to paddleslim/tests/test_prune.py index 3fdaa867e350af876648871f83fe70cc83b548b6..93609367351618ce375f164a1dca284e85369e4c 100644 --- a/tests/test_prune.py +++ b/paddleslim/tests/test_prune.py @@ -15,7 +15,7 @@ import sys sys.path.append("../") import unittest import paddle.fluid as fluid -from paddleslim.prune import Pruner +from prune import Pruner from layers import conv_bn_layer