Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
cdf7baa2
MegEngine
项目概览
MegEngine 天元
/
MegEngine
接近 2 年 前同步成功
通知
414
Star
4708
Fork
583
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cdf7baa2
编写于
10月 17, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(python): support python 3.10
GitOrigin-RevId: a338ad5c68e2c71064f0094da0b774cb973aa5ba
上级
30ef28b0
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
56 addition
and
25 deletion
+56
-25
imperative/python/megengine/traced_module/expr.py
imperative/python/megengine/traced_module/expr.py
+1
-1
imperative/python/megengine/utils/comp_graph_tools.py
imperative/python/megengine/utils/comp_graph_tools.py
+1
-1
imperative/python/megengine/utils/network.py
imperative/python/megengine/utils/network.py
+4
-4
imperative/python/requires-style.txt
imperative/python/requires-style.txt
+1
-0
imperative/python/requires-test.txt
imperative/python/requires-test.txt
+2
-1
imperative/python/src/helper.h
imperative/python/src/helper.h
+7
-0
imperative/python/test/unit/data/test_dataloader.py
imperative/python/test/unit/data/test_dataloader.py
+13
-0
imperative/python/test/unit/data/test_pre_dataloader.py
imperative/python/test/unit/data/test_pre_dataloader.py
+9
-0
imperative/src/test/helper.h
imperative/src/test/helper.h
+7
-0
scripts/whl/macos/macos_build_whl.sh
scripts/whl/macos/macos_build_whl.sh
+1
-1
scripts/whl/manylinux2014/Dockerfile
scripts/whl/manylinux2014/Dockerfile
+1
-1
scripts/whl/manylinux2014/Dockerfile_aarch64
scripts/whl/manylinux2014/Dockerfile_aarch64
+1
-1
scripts/whl/manylinux2014/do_build_common.sh
scripts/whl/manylinux2014/do_build_common.sh
+1
-1
scripts/whl/manylinux2014/init_image.sh
scripts/whl/manylinux2014/init_image.sh
+4
-12
scripts/whl/utils/utils.sh
scripts/whl/utils/utils.sh
+2
-1
scripts/whl/windows/windows_build_whl.sh
scripts/whl/windows/windows_build_whl.sh
+1
-1
未找到文件。
imperative/python/megengine/traced_module/expr.py
浏览文件 @
cdf7baa2
...
@@ -136,7 +136,7 @@ class Expr:
...
@@ -136,7 +136,7 @@ class Expr:
if
outputs
is
None
:
if
outputs
is
None
:
return
return
current_graph
=
active_module_tracer
().
current_scope
()
current_graph
=
active_module_tracer
().
current_scope
()
if
not
isinstance
(
outputs
,
collections
.
Sequence
):
if
not
isinstance
(
outputs
,
collections
.
abc
.
Sequence
):
outputs
=
(
outputs
,)
outputs
=
(
outputs
,)
for
i
in
outputs
:
for
i
in
outputs
:
assert
isinstance
(
i
,
RawTensor
),
"The output must be a Tensor"
assert
isinstance
(
i
,
RawTensor
),
"The output must be a Tensor"
...
...
imperative/python/megengine/utils/comp_graph_tools.py
浏览文件 @
cdf7baa2
...
@@ -82,7 +82,7 @@ class _OprStableOrderHeapq:
...
@@ -82,7 +82,7 @@ class _OprStableOrderHeapq:
_used_id_name_pairs
=
None
_used_id_name_pairs
=
None
def
__init__
(
self
,
extra_priority
):
def
__init__
(
self
,
extra_priority
):
assert
isinstance
(
extra_priority
,
collections
.
Callable
)
assert
isinstance
(
extra_priority
,
collections
.
abc
.
Callable
)
self
.
_list
=
[]
self
.
_list
=
[]
self
.
_extra_priority
=
extra_priority
self
.
_extra_priority
=
extra_priority
self
.
_used_id_name_pairs
=
{}
self
.
_used_id_name_pairs
=
{}
...
...
imperative/python/megengine/utils/network.py
浏览文件 @
cdf7baa2
...
@@ -324,7 +324,7 @@ class Network:
...
@@ -324,7 +324,7 @@ class Network:
if
isinstance
(
modifier
,
str
):
if
isinstance
(
modifier
,
str
):
om
=
modifier
om
=
modifier
modifier
=
lambda
v
:
"{}.{}"
.
format
(
om
,
v
)
modifier
=
lambda
v
:
"{}.{}"
.
format
(
om
,
v
)
assert
isinstance
(
modifier
,
collections
.
Callable
)
assert
isinstance
(
modifier
,
collections
.
abc
.
Callable
)
for
i
in
self
.
all_oprs
:
for
i
in
self
.
all_oprs
:
v0
=
i
.
name
v0
=
i
.
name
v1
=
modifier
(
v0
)
v1
=
modifier
(
v0
)
...
@@ -550,7 +550,7 @@ def as_varnode(obj):
...
@@ -550,7 +550,7 @@ def as_varnode(obj):
return
ret
return
ret
assert
isinstance
(
assert
isinstance
(
obj
,
collections
.
Iterable
obj
,
collections
.
abc
.
Iterable
),
"{} is not compatible with VarNode"
.
format
(
obj
)
),
"{} is not compatible with VarNode"
.
format
(
obj
)
val
=
list
(
obj
)
val
=
list
(
obj
)
...
@@ -573,7 +573,7 @@ def as_oprnode(obj):
...
@@ -573,7 +573,7 @@ def as_oprnode(obj):
return
obj
return
obj
assert
isinstance
(
assert
isinstance
(
obj
,
collections
.
Iterable
obj
,
collections
.
abc
.
Iterable
),
"{} is not compatible with OpNode"
.
format
(
obj
)
),
"{} is not compatible with OpNode"
.
format
(
obj
)
val
=
list
(
obj
)
val
=
list
(
obj
)
...
@@ -619,7 +619,7 @@ class NodeFilter:
...
@@ -619,7 +619,7 @@ class NodeFilter:
oprs
=
get_oprs_seq
(
node_iter
.
inputs
,
False
,
False
)
oprs
=
get_oprs_seq
(
node_iter
.
inputs
,
False
,
False
)
node_iter
=
itertools
.
islice
(
oprs
,
len
(
oprs
)
-
1
)
node_iter
=
itertools
.
islice
(
oprs
,
len
(
oprs
)
-
1
)
assert
isinstance
(
node_iter
,
collections
.
Iterable
)
assert
isinstance
(
node_iter
,
collections
.
abc
.
Iterable
)
if
(
not
isinstance
(
node_iter
,
NodeFilter
))
and
type
(
if
(
not
isinstance
(
node_iter
,
NodeFilter
))
and
type
(
self
self
)
is
not
NodeFilterCheckType
:
)
is
not
NodeFilterCheckType
:
...
...
imperative/python/requires-style.txt
浏览文件 @
cdf7baa2
...
@@ -2,3 +2,4 @@ black==19.10b0
...
@@ -2,3 +2,4 @@ black==19.10b0
isort==4.3.21
isort==4.3.21
pylint==2.4.3
pylint==2.4.3
mypy==0.982
mypy==0.982
typed_ast==1.5.0; python_version > '3.8'
imperative/python/requires-test.txt
浏览文件 @
cdf7baa2
pytest==5.3.0
pytest==5.3.0 ; python_version <= '3.9'
pytest==6.2.5 ; python_version > '3.9'
pytest-sphinx==0.3.1
pytest-sphinx==0.3.1
tensorboardX==2.4
tensorboardX==2.4
protobuf==3.20.0 ; python_version > '3.8'
protobuf==3.20.0 ; python_version > '3.8'
...
...
imperative/python/src/helper.h
浏览文件 @
cdf7baa2
...
@@ -4,6 +4,13 @@
...
@@ -4,6 +4,13 @@
#include "megbrain/imperative/op_def.h"
#include "megbrain/imperative/op_def.h"
#include "megbrain/utils/persistent_cache.h"
#include "megbrain/utils/persistent_cache.h"
// in python 3.10, ssize_t is not defined on windows
// so ssize_t should be defined manually before include pybind headers
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef
SSIZE_T
ssize_t
;
#endif
#include <Python.h>
#include <Python.h>
#include <iterator>
#include <iterator>
#include <string>
#include <string>
...
...
imperative/python/test/unit/data/test_dataloader.py
浏览文件 @
cdf7baa2
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
# software distributed under the License is distributed on an
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
math
import
math
import
multiprocessing
import
os
import
os
import
platform
import
platform
import
time
import
time
...
@@ -134,6 +135,10 @@ def test_dataloader_parallel():
...
@@ -134,6 +135,10 @@ def test_dataloader_parallel():
platform
.
system
()
==
"Windows"
,
platform
.
system
()
==
"Windows"
,
reason
=
"dataloader do not support parallel on windows"
,
reason
=
"dataloader do not support parallel on windows"
,
)
)
@
pytest
.
mark
.
skipif
(
multiprocessing
.
get_start_method
()
!=
"fork"
,
reason
=
"the runtime error is only raised when fork"
,
)
def
test_dataloader_parallel_timeout
():
def
test_dataloader_parallel_timeout
():
dataset
=
init_dataset
()
dataset
=
init_dataset
()
...
@@ -161,6 +166,10 @@ def test_dataloader_parallel_timeout():
...
@@ -161,6 +166,10 @@ def test_dataloader_parallel_timeout():
platform
.
system
()
==
"Windows"
,
platform
.
system
()
==
"Windows"
,
reason
=
"dataloader do not support parallel on windows"
,
reason
=
"dataloader do not support parallel on windows"
,
)
)
@
pytest
.
mark
.
skipif
(
multiprocessing
.
get_start_method
()
!=
"fork"
,
reason
=
"the runtime error is only raised when fork"
,
)
def
test_dataloader_parallel_worker_exception
():
def
test_dataloader_parallel_worker_exception
():
dataset
=
init_dataset
()
dataset
=
init_dataset
()
...
@@ -287,6 +296,10 @@ def test_prestream_dataloader_multiprocessing():
...
@@ -287,6 +296,10 @@ def test_prestream_dataloader_multiprocessing():
platform
.
system
()
==
"Windows"
,
platform
.
system
()
==
"Windows"
,
reason
=
"dataloader do not support parallel on windows"
,
reason
=
"dataloader do not support parallel on windows"
,
)
)
@
pytest
.
mark
.
skipif
(
multiprocessing
.
get_start_method
()
!=
"fork"
,
reason
=
"the runtime error is only raised when fork"
,
)
def
test_predataloader_parallel_worker_exception
():
def
test_predataloader_parallel_worker_exception
():
dataset
=
MyPreStream
(
100
)
dataset
=
MyPreStream
(
100
)
...
...
imperative/python/test/unit/data/test_pre_dataloader.py
浏览文件 @
cdf7baa2
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
gc
import
gc
import
math
import
math
import
multiprocessing
import
os
import
os
import
platform
import
platform
import
time
import
time
...
@@ -146,6 +147,10 @@ def test_dataloader_parallel():
...
@@ -146,6 +147,10 @@ def test_dataloader_parallel():
platform
.
system
()
==
"Windows"
,
platform
.
system
()
==
"Windows"
,
reason
=
"dataloader do not support parallel on windows"
,
reason
=
"dataloader do not support parallel on windows"
,
)
)
@
pytest
.
mark
.
skipif
(
multiprocessing
.
get_start_method
()
!=
"fork"
,
reason
=
"the runtime error is only raised when fork"
,
)
def
test_dataloader_parallel_timeout
():
def
test_dataloader_parallel_timeout
():
dataset
=
init_dataset
()
dataset
=
init_dataset
()
...
@@ -174,6 +179,10 @@ def test_dataloader_parallel_timeout():
...
@@ -174,6 +179,10 @@ def test_dataloader_parallel_timeout():
platform
.
system
()
==
"Windows"
,
platform
.
system
()
==
"Windows"
,
reason
=
"dataloader do not support parallel on windows"
,
reason
=
"dataloader do not support parallel on windows"
,
)
)
@
pytest
.
mark
.
skipif
(
multiprocessing
.
get_start_method
()
!=
"fork"
,
reason
=
"the runtime error is only raised when fork"
,
)
def
test_dataloader_parallel_worker_exception
():
def
test_dataloader_parallel_worker_exception
():
dataset
=
init_dataset
()
dataset
=
init_dataset
()
...
...
imperative/src/test/helper.h
浏览文件 @
cdf7baa2
...
@@ -2,6 +2,13 @@
...
@@ -2,6 +2,13 @@
#include <variant>
#include <variant>
// in python 3.10, ssize_t is not defined on windows
// so ssize_t should be defined manually before include pybind headers
#if defined(_MSC_VER)
#include <BaseTsd.h>
typedef
SSIZE_T
ssize_t
;
#endif
#include "megbrain/imperative.h"
#include "megbrain/imperative.h"
#include "megbrain/test/helper.h"
#include "megbrain/test/helper.h"
...
...
scripts/whl/macos/macos_build_whl.sh
浏览文件 @
cdf7baa2
...
@@ -42,7 +42,7 @@ platform=$(uname -m | awk '{print $0}')
...
@@ -42,7 +42,7 @@ platform=$(uname -m | awk '{print $0}')
if
[
$platform
=
'arm64'
]
;
then
if
[
$platform
=
'arm64'
]
;
then
FULL_PYTHON_VER
=
"3.8.10 3.9.4 3.10.1"
FULL_PYTHON_VER
=
"3.8.10 3.9.4 3.10.1"
else
else
FULL_PYTHON_VER
=
"3.6.10 3.7.7 3.8.3 3.9.4"
FULL_PYTHON_VER
=
"3.6.10 3.7.7 3.8.3 3.9.4
3.10.1
"
fi
fi
if
[[
-z
${
ALL_PYTHON
}
]]
if
[[
-z
${
ALL_PYTHON
}
]]
...
...
scripts/whl/manylinux2014/Dockerfile
浏览文件 @
cdf7baa2
FROM
quay.io/pypa/manylinux2014_x86_64:202
0-12-31-56195b3
FROM
quay.io/pypa/manylinux2014_x86_64:202
1-12-30-cb9fd5b
ENV
UID=1024 \
ENV
UID=1024 \
PATH=${PATH}:/usr/local/cuda/bin \
PATH=${PATH}:/usr/local/cuda/bin \
...
...
scripts/whl/manylinux2014/Dockerfile_aarch64
浏览文件 @
cdf7baa2
FROM quay.io/pypa/manylinux2014_aarch64:202
0-12-31-56195b3
FROM quay.io/pypa/manylinux2014_aarch64:202
1-12-30-cb9fd5b
ENV UID=1024 PATH=${PATH}:/usr/local/cuda/bin
ENV UID=1024 PATH=${PATH}:/usr/local/cuda/bin
...
...
scripts/whl/manylinux2014/do_build_common.sh
浏览文件 @
cdf7baa2
...
@@ -74,7 +74,7 @@ function patch_elf_depend_lib_megenginelite() {
...
@@ -74,7 +74,7 @@ function patch_elf_depend_lib_megenginelite() {
SRC_DIR
=
$(
readlink
-f
"
`
dirname
$0
`
/../../../"
)
SRC_DIR
=
$(
readlink
-f
"
`
dirname
$0
`
/../../../"
)
source
${
SRC_DIR
}
/scripts/whl/utils/utils.sh
source
${
SRC_DIR
}
/scripts/whl/utils/utils.sh
SUPPORT_ALL_VERSION
=
"36m 37m 38 39"
SUPPORT_ALL_VERSION
=
"36m 37m 38 39
310
"
ALL_PYTHON
=
${
ALL_PYTHON
}
ALL_PYTHON
=
${
ALL_PYTHON
}
if
[[
-z
${
ALL_PYTHON
}
]]
if
[[
-z
${
ALL_PYTHON
}
]]
then
then
...
...
scripts/whl/manylinux2014/init_image.sh
浏览文件 @
cdf7baa2
#!/bin/bash -e
#!/bin/bash -e
GET_PIP_URL
=
'https://bootstrap.pypa.io/get-pip.py'
GET_PIP_URL_36
=
'https://bootstrap.pypa.io/pip/3.6/get-pip.py'
SWIG_URL
=
'https://codeload.github.com/swig/swig/tar.gz/refs/tags/rel-3.0.12'
SWIG_URL
=
'https://codeload.github.com/swig/swig/tar.gz/refs/tags/rel-3.0.12'
LLVM_URL
=
'https://github.com/llvm-mirror/llvm/archive/release_60.tar.gz'
LLVM_URL
=
'https://github.com/llvm-mirror/llvm/archive/release_60.tar.gz'
CLANG_URL
=
'https://github.com/llvm-mirror/clang/archive/release_60.tar.gz'
CLANG_URL
=
'https://github.com/llvm-mirror/clang/archive/release_60.tar.gz'
...
@@ -17,20 +15,14 @@ yum install -y python3 python3-devel
...
@@ -17,20 +15,14 @@ yum install -y python3 python3-devel
python3
-m
pip
install
cython
-i
https://mirrors.aliyun.com/pypi/simple
python3
-m
pip
install
cython
-i
https://mirrors.aliyun.com/pypi/simple
python3
-m
pip
install
numpy
-i
https://mirrors.aliyun.com/pypi/simple
python3
-m
pip
install
numpy
-i
https://mirrors.aliyun.com/pypi/simple
# FIXME: failed when install pip with python3.10 because python3.10
ALL_PYTHON
=
"36m 37m 38 39 310"
# is not installed on aarch64, so we remove 310 from ALL_PYTHON version now
ALL_PYTHON
=
"36m 37m 38 39"
numpy_version
=
"1.19.5"
for
ver
in
${
ALL_PYTHON
}
for
ver
in
${
ALL_PYTHON
}
do
do
python_ver
=
`
echo
$ver
|
tr
-d
m
`
python_ver
=
`
echo
$ver
|
tr
-d
m
`
PIP_URL
=
${
GET_PIP_URL
}
numpy_version
=
"1.19.5"
if
[
${
ver
}
=
"3
6m
"
]
;
then
if
[
${
ver
}
=
"3
10
"
]
;
then
PIP_URL
=
${
GET_PIP_URL_36
}
numpy_version
=
"1.21.6"
fi
fi
echo
"use pip url:
${
PIP_URL
}
"
curl
${
PIP_URL
}
| /opt/python/cp
${
python_ver
}
-cp
${
ver
}
/bin/python -
\
--no-cache-dir
--only-binary
:all:
/opt/python/cp
${
python_ver
}
-cp
${
ver
}
/bin/pip
install
\
/opt/python/cp
${
python_ver
}
-cp
${
ver
}
/bin/pip
install
\
--no-cache-dir
--only-binary
:all:
numpy
==
${
numpy_version
}
setuptools
==
46.1.3
\
--no-cache-dir
--only-binary
:all:
numpy
==
${
numpy_version
}
setuptools
==
46.1.3
\
-i
https://mirrors.aliyun.com/pypi/simple
-i
https://mirrors.aliyun.com/pypi/simple
...
...
scripts/whl/utils/utils.sh
浏览文件 @
cdf7baa2
...
@@ -78,7 +78,8 @@ function check_build_ninja_python_api() {
...
@@ -78,7 +78,8 @@ function check_build_ninja_python_api() {
INCLUDE_KEYWORD
=
"
${
ver
}
\\\\
include"
INCLUDE_KEYWORD
=
"
${
ver
}
\\\\
include"
PYTHON_API_INCLUDES
=
"3.6.8
\\\\
include 3.7.7
\\\\
include 3.8.3
\\\\
include 3.9.4
\\\\
include 3.10.1
\\\\
include"
PYTHON_API_INCLUDES
=
"3.6.8
\\\\
include 3.7.7
\\\\
include 3.8.3
\\\\
include 3.9.4
\\\\
include 3.10.1
\\\\
include"
elif
[[
$OS
=
~
"Linux"
]]
;
then
elif
[[
$OS
=
~
"Linux"
]]
;
then
INCLUDE_KEYWORD
=
"include/python3.
${
ver
:1:1
}
"
ver
=
`
echo
$ver
|
tr
-d
m
`
INCLUDE_KEYWORD
=
"include/python3.
${
ver
:1
}
"
# like 39/310
info
=
`
command
-v
termux-info
||
true
`
info
=
`
command
-v
termux-info
||
true
`
if
[[
"
${
info
}
"
=
~
"com.termux"
]]
;
then
if
[[
"
${
info
}
"
=
~
"com.termux"
]]
;
then
echo
"find termux-info at:
${
info
}
"
echo
"find termux-info at:
${
info
}
"
...
...
scripts/whl/windows/windows_build_whl.sh
浏览文件 @
cdf7baa2
...
@@ -26,7 +26,7 @@ SRC_DIR=$(READLINK -f "`dirname $0`/../../../")
...
@@ -26,7 +26,7 @@ SRC_DIR=$(READLINK -f "`dirname $0`/../../../")
source
${
SRC_DIR
}
/scripts/whl/utils/utils.sh
source
${
SRC_DIR
}
/scripts/whl/utils/utils.sh
ALL_PYTHON
=
${
ALL_PYTHON
}
ALL_PYTHON
=
${
ALL_PYTHON
}
FULL_PYTHON_VER
=
"3.6.8 3.7.7 3.8.3 3.9.4"
FULL_PYTHON_VER
=
"3.6.8 3.7.7 3.8.3 3.9.4
3.10.1
"
if
[[
-z
${
ALL_PYTHON
}
]]
if
[[
-z
${
ALL_PYTHON
}
]]
then
then
ALL_PYTHON
=
${
FULL_PYTHON_VER
}
ALL_PYTHON
=
${
FULL_PYTHON_VER
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录