提交 92bebe65 编写于 作者: K kingxian 提交者: jinxiaoxian

cell init performance opt

上级 e06dc0a9
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import inspect import inspect
import time import time
import gc import gc
import os
from collections import OrderedDict from collections import OrderedDict
import numpy import numpy
from mindspore import log as logger from mindspore import log as logger
...@@ -73,8 +74,11 @@ class Cell: ...@@ -73,8 +74,11 @@ class Cell:
self._parameter_layout_dict = {} self._parameter_layout_dict = {}
self._create_time = int(time.time() * 1e9) self._create_time = int(time.time() * 1e9)
init_backend() init_backend()
# call gc to release GE session resources used by non-used cell objects # call gc to release GE session resources used by non-used cell objects
gc.collect() if os.getenv('GC_COLLECT_IN_CELL') == '1':
gc.collect()
self._construct_inputs_num = 0 self._construct_inputs_num = 0
self._construct_inputs_names = [] self._construct_inputs_names = []
self._auto_parallel_mode = False self._auto_parallel_mode = False
......
...@@ -35,10 +35,10 @@ class Net_Pool(nn.Cell): ...@@ -35,10 +35,10 @@ class Net_Pool(nn.Cell):
class Net_Pool2(nn.Cell): class Net_Pool2(nn.Cell):
def __init__(self): def __init__(self):
super(Net_Pool2, self).__init__() super(Net_Pool2, self).__init__()
self.maxpool_fun = nn.MaxPool2d(kernel_size=3, stride=2, pad_mode="SAME") self.maxpool_fun2 = nn.MaxPool2d(kernel_size=3, stride=2, pad_mode="SAME")
def construct(self, x): def construct(self, x):
return self.maxpool_fun(x) return self.maxpool_fun2(x)
@pytest.mark.level0 @pytest.mark.level0
......
...@@ -29,6 +29,7 @@ cd ${BUILD_PATH}/mindspore/tests/ut/cpp ...@@ -29,6 +29,7 @@ cd ${BUILD_PATH}/mindspore/tests/ut/cpp
export LD_LIBRARY_PATH=${BUILD_PATH}/mindspore/googletest/googlemock/gtest:${PROJECT_PATH}/mindspore:${PROJECT_PATH}/mindspore/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=${BUILD_PATH}/mindspore/googletest/googlemock/gtest:${PROJECT_PATH}/mindspore:${PROJECT_PATH}/mindspore/lib:$LD_LIBRARY_PATH
export PYTHONPATH=${PROJECT_PATH}/tests/ut/cpp/python_input:$PYTHONPATH:${PROJECT_PATH} export PYTHONPATH=${PROJECT_PATH}/tests/ut/cpp/python_input:$PYTHONPATH:${PROJECT_PATH}
export GLOG_v=2 export GLOG_v=2
export GC_COLLECT_IN_CELL=1
## prepare data for dataset & mindrecord ## prepare data for dataset & mindrecord
cp -fr $PROJECT_PATH/tests/ut/data ${PROJECT_PATH}/build/mindspore/tests/ut/cpp/ cp -fr $PROJECT_PATH/tests/ut/data ${PROJECT_PATH}/build/mindspore/tests/ut/cpp/
......
...@@ -27,6 +27,7 @@ fi ...@@ -27,6 +27,7 @@ fi
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${BUILD_PATH}/third_party/gtest/lib export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${BUILD_PATH}/third_party/gtest/lib
export PYTHONPATH=$PYTHONPATH:${PROJECT_PATH}:${PROJECT_PATH}/tests/ut/cpp/python_input:${PROJECT_PATH}/tests/ut/python export PYTHONPATH=$PYTHONPATH:${PROJECT_PATH}:${PROJECT_PATH}/tests/ut/cpp/python_input:${PROJECT_PATH}/tests/ut/python
echo "export PYTHONPATH=$PYTHONPATH" echo "export PYTHONPATH=$PYTHONPATH"
export GC_COLLECT_IN_CELL=1
if [ $# -eq 1 ] && ([ "$1" == "stage1" ] || [ "$1" == "stage2" ] || [ "$1" == "stage3" ]); then if [ $# -eq 1 ] && ([ "$1" == "stage1" ] || [ "$1" == "stage2" ] || [ "$1" == "stage3" ]); then
if [ $1 == "stage1" ]; then if [ $1 == "stage1" ]; then
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册