GitOrigin-RevId: d8d106b927
tags/v0.3.2
@@ -114,7 +114,7 @@ def max_pool2d( | |||||
:param stride: The stride of the window. If not provided, its value is set to ``kernel_size``. | :param stride: The stride of the window. If not provided, its value is set to ``kernel_size``. | ||||
Default: None | Default: None | ||||
:param padding: Implicit zero padding to be added on both sides. Default: 0 | :param padding: Implicit zero padding to be added on both sides. Default: 0 | ||||
Refer to :class:`~.MaxPool2d` for more information. | Refer to :class:`~.MaxPool2d` for more information. | ||||
""" | """ | ||||
@@ -615,7 +615,7 @@ def interpolate( | |||||
:param mode: interpolation methods, acceptable values are: | :param mode: interpolation methods, acceptable values are: | ||||
'bilinear'(default), 'linear', 'nearest' (todo), 'cubic' (todo), 'area' (todo) | 'bilinear'(default), 'linear', 'nearest' (todo), 'cubic' (todo), 'area' (todo) | ||||
Examples: | Examples: | ||||
@@ -743,7 +743,9 @@ def dropout(inp: Tensor, drop_prob: float, rescale: bool = True) -> Tensor: | |||||
import numpy as np | import numpy as np | ||||
from megengine import tensor | from megengine import tensor | ||||
import megengine.functional as F | import megengine.functional as F | ||||
from megengine.random import manual_seed | |||||
manual_seed(0) | |||||
data = tensor(np.ones(10, dtype=np.float32)) | data = tensor(np.ones(10, dtype=np.float32)) | ||||
out = F.dropout(data, 1./3.) | out = F.dropout(data, 1./3.) | ||||
print(out.numpy()) | print(out.numpy()) | ||||
@@ -767,7 +769,7 @@ def dropout(inp: Tensor, drop_prob: float, rescale: bool = True) -> Tensor: | |||||
@wrap_io_tensor | @wrap_io_tensor | ||||
def identity(inp: Tensor) -> Tensor: | def identity(inp: Tensor) -> Tensor: | ||||
"""applies an identity transform to the input tensor. | """applies an identity transform to the input tensor. | ||||
:param inp: The input tensor | :param inp: The input tensor | ||||
""" | """ | ||||
return mgb.opr.identity(inp) | return mgb.opr.identity(inp) | ||||
@@ -42,13 +42,14 @@ def gaussian( | |||||
import megengine as mge | import megengine as mge | ||||
import megengine.random as rand | import megengine.random as rand | ||||
rand.manual_seed(0) | |||||
x = rand.gaussian((2, 2), mean=0, std=1) | x = rand.gaussian((2, 2), mean=0, std=1) | ||||
print(x.numpy()) | print(x.numpy()) | ||||
.. testoutput:: | .. testoutput:: | ||||
[[ 0.2925366 -0.718359 ] | |||||
[ 0.09999694 -0.3931978 ]] | |||||
[[-0.20235455 -0.6959438 ] | |||||
[-1.4939808 -1.5824696 ]] | |||||
""" | """ | ||||
comp_node, comp_graph = _use_default_if_none(comp_node, comp_graph) | comp_node, comp_graph = _use_default_if_none(comp_node, comp_graph) | ||||
@@ -78,13 +79,14 @@ def uniform( | |||||
import megengine as mge | import megengine as mge | ||||
import megengine.random as rand | import megengine.random as rand | ||||
rand.manual_seed(0) | |||||
x = rand.uniform((2, 2)) | x = rand.uniform((2, 2)) | ||||
print(x.numpy()) | print(x.numpy()) | ||||
.. testoutput:: | .. testoutput:: | ||||
[[0.74021935 0.9209938 ] | |||||
[0.03902049 0.9689629 ]] | |||||
[[0.76901674 0.70496535] | |||||
[0.09365904 0.62957656]] | |||||
""" | """ | ||||
comp_node, comp_graph = _use_default_if_none(comp_node, comp_graph) | comp_node, comp_graph = _use_default_if_none(comp_node, comp_graph) | ||||
@@ -0,0 +1,4 @@ | |||||
black==19.10b0 | |||||
isort==4.3.21 | |||||
pylint==2.4.3 | |||||
mypy==0.750 |
@@ -0,0 +1,2 @@ | |||||
pytest==5.3.0 | |||||
pytest-sphinx==0.2.2 |
@@ -0,0 +1,7 @@ | |||||
numpy>=1.17 | |||||
opencv-python | |||||
pyarrow | |||||
requests | |||||
tabulate | |||||
tqdm | |||||
redispy |
@@ -55,6 +55,13 @@ package_data += [ | |||||
os.path.join('module', 'pytorch', 'torch_mem_fwd.cpp') | os.path.join('module', 'pytorch', 'torch_mem_fwd.cpp') | ||||
] | ] | ||||
with open('requires.txt') as f: | |||||
requires = f.read().splitlines() | |||||
with open('requires-style.txt') as f: | |||||
requires_style = f.read().splitlines() | |||||
with open('requires-test.txt') as f: | |||||
requires_test = f.read().splitlines() | |||||
setup_kwargs = dict( | setup_kwargs = dict( | ||||
name=package_name, | name=package_name, | ||||
version=__version__, | version=__version__, | ||||
@@ -67,29 +74,10 @@ setup_kwargs = dict( | |||||
'megengine': package_data, | 'megengine': package_data, | ||||
}, | }, | ||||
ext_modules=[PrecompiledExtesion('megengine._internal._mgb')], | ext_modules=[PrecompiledExtesion('megengine._internal._mgb')], | ||||
install_requires=[ | |||||
'numpy>=1.17', | |||||
'opencv-python', | |||||
'pyarrow', | |||||
'requests', | |||||
'tabulate', | |||||
'tqdm', | |||||
], | |||||
install_requires=requires, | |||||
extras_require={ | extras_require={ | ||||
'dev': [ | |||||
'black==19.10b0', | |||||
'isort==4.3.21', | |||||
'pylint==2.4.3', | |||||
'mypy==0.750', | |||||
'pytest==5.3.0', | |||||
'pytest-sphinx==0.2.2', | |||||
], | |||||
'data': [ | |||||
'scipy', | |||||
], | |||||
'ci': [ | |||||
'pytest==5.3.0', | |||||
], | |||||
'dev': [*requires_style, *requires_test], | |||||
'ci': requires_test, | |||||
}, | }, | ||||
cmdclass={'build_ext': build_ext}, | cmdclass={'build_ext': build_ext}, | ||||
) | ) | ||||
@@ -1,13 +1,12 @@ | |||||
#!/bin/bash -e | #!/bin/bash -e | ||||
pushd $(dirname "${BASH_SOURCE[0]}")/.. >/dev/null | pushd $(dirname "${BASH_SOURCE[0]}")/.. >/dev/null | ||||
pytest -xv -m 'not internet'\ | |||||
pytest -xv -m 'not internet' \ | |||||
--ignore test/unit/module/test_pytorch.py \ | --ignore test/unit/module/test_pytorch.py \ | ||||
--ignore test/pytorch_comparison \ | --ignore test/pytorch_comparison \ | ||||
--ignore test/unit/hub/test_hub.py \ | --ignore test/unit/hub/test_hub.py \ | ||||
--ignore test/unit/data \ | --ignore test/unit/data \ | ||||
--ignore test/integration/manual \ | --ignore test/integration/manual \ | ||||
--ignore megengine/docs/ \ | |||||
--ignore megengine/module/pytorch \ | --ignore megengine/module/pytorch \ | ||||
megengine test | megengine test | ||||
popd >/dev/null | popd >/dev/null |