Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
ee790cb6
MegEngine
项目概览
MegEngine 天元
/
MegEngine
大约 1 年 前同步成功
通知
399
Star
4705
Fork
582
代码
文件
提交
分支
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看板
提交
ee790cb6
编写于
9月 03, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(imperative/python): fix warp_perspective doc and arange dtype
GitOrigin-RevId: dc4e021ec0d06c5478ca0449c4a0cc6a497f512d
上级
c5f8b583
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
25 addition
and
31 deletion
+25
-31
imperative/python/megengine/functional/elemwise.py
imperative/python/megengine/functional/elemwise.py
+0
-2
imperative/python/megengine/functional/tensor.py
imperative/python/megengine/functional/tensor.py
+2
-2
imperative/python/megengine/functional/vision.py
imperative/python/megengine/functional/vision.py
+2
-2
imperative/python/megengine/jit/tracing.py
imperative/python/megengine/jit/tracing.py
+0
-6
imperative/python/test/run.sh
imperative/python/test/run.sh
+4
-4
imperative/python/test/unit/core/test_function.py
imperative/python/test/unit/core/test_function.py
+1
-1
imperative/python/test/unit/core/test_indexing_op.py
imperative/python/test/unit/core/test_indexing_op.py
+10
-12
imperative/python/test/unit/jit/test_tracing.py
imperative/python/test/unit/jit/test_tracing.py
+6
-2
未找到文件。
imperative/python/megengine/functional/elemwise.py
浏览文件 @
ee790cb6
...
...
@@ -487,8 +487,6 @@ def clip(x: Tensor, lower=None, upper=None) -> Tensor:
),
"At least one of 'lower' or 'upper' must not be None"
if
lower
is
not
None
:
if
upper
is
not
None
:
# FIXME: following assertion won't work during trace if upper and lower are Tensors
# assert lower <= upper, "clip lower bound is bigger that upper bound"
return
minimum
(
maximum
(
x
,
lower
),
upper
)
else
:
return
maximum
(
x
,
lower
)
...
...
imperative/python/megengine/functional/tensor.py
浏览文件 @
ee790cb6
...
...
@@ -1063,7 +1063,7 @@ def linspace(
op
=
builtin
.
Linspace
(
comp_node
=
device
)
(
result
,)
=
apply
(
op
,
start
,
stop
,
num
)
if
np
.
dtype
(
dtype
)
==
np
.
in
t32
:
if
np
.
dtype
(
dtype
)
!=
np
.
floa
t32
:
return
result
.
astype
(
dtype
)
return
result
...
...
@@ -1112,7 +1112,7 @@ def arange(
num
=
ceil
((
stop
-
start
)
/
step
)
stop
=
start
+
step
*
(
num
-
1
)
result
=
linspace
(
start
,
stop
,
num
,
device
=
device
)
if
np
.
dtype
(
dtype
)
==
np
.
in
t32
:
if
np
.
dtype
(
dtype
)
!=
np
.
floa
t32
:
return
result
.
astype
(
dtype
)
return
result
...
...
imperative/python/megengine/functional/vision.py
浏览文件 @
ee790cb6
...
...
@@ -398,8 +398,8 @@ def warp_perspective(
.. math::
\text{output}(n, c, h, w) = \text{input} \left( n, c,
\frac{M_{00}
h + M_{01}w + M_{02}}{M_{20}h + M_{21}w
+ M_{22}},
\frac{M_{10}
h + M_{11}w + M_{12}}{M_{20}h + M_{21}w
+ M_{22}}
\frac{M_{00}
w + M_{01}h + M_{02}}{M_{20}w + M_{21}h
+ M_{22}},
\frac{M_{10}
w + M_{11}h + M_{12}}{M_{20}w + M_{21}h
+ M_{22}}
\right)
Optionally, we can set `mat_idx` to assign different transformations to the same image,
...
...
imperative/python/megengine/jit/tracing.py
浏览文件 @
ee790cb6
...
...
@@ -1041,12 +1041,6 @@ class trace:
raise
RuntimeError
(
"trace is not set with profiling=True"
)
return
json
.
loads
(
self
.
_profiler
.
get
())
def
trace
(
self
,
*
args
,
**
kwargs
):
raise
NotImplementedError
(
"trace is deemed unbeneficial with the new "
"tracing mechanism. You should alwasy use __call__."
)
class
CompiledTensorProxy
:
r
"""Duck-typed RawTensor"""
...
...
imperative/python/test/run.sh
浏览文件 @
ee790cb6
...
...
@@ -34,18 +34,18 @@ if [[ "$TEST_PLAT" =~ "local" ]]; then
esac
echo
"test local env at:
${
test_dirs
}
"
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-v
$test_dirs
-m
'not isolated_distributed'
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-
s
-
v
$test_dirs
-m
'not isolated_distributed'
if
[[
"
$TEST_PLAT
"
=
~
"cuda"
]]
;
then
echo
"test GPU pytest now"
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-v
$test_dirs
-m
'isolated_distributed'
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-
s
-
v
$test_dirs
-m
'isolated_distributed'
fi
else
cd
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
/..
test_dirs
=
"megengine test"
echo
"test develop env"
PYTHONPATH
=
"."
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-v
$test_dirs
-m
'not isolated_distributed'
PYTHONPATH
=
"."
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-
s
-
v
$test_dirs
-m
'not isolated_distributed'
if
[[
"
$TEST_PLAT
"
=
~
"cuda"
]]
;
then
echo
"test GPU pytest now"
PYTHONPATH
=
"."
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-v
$test_dirs
-m
'isolated_distributed'
PYTHONPATH
=
"."
PY_IGNORE_IMPORTMISMATCH
=
1 python3
-m
pytest
-
s
-
v
$test_dirs
-m
'isolated_distributed'
fi
fi
imperative/python/test/unit/core/test_function.py
浏览文件 @
ee790cb6
...
...
@@ -272,7 +272,7 @@ def test_none_in_out_grad():
)
def
test_
zero
_grad
():
def
test_
clear
_grad
():
class
StopGradient
(
Function
):
def
forward
(
self
,
a
):
return
a
...
...
imperative/python/test/unit/core/test_indexing_op.py
浏览文件 @
ee790cb6
...
...
@@ -556,18 +556,16 @@ def test_advance_indexing_with_bool(test_varnode):
aa
[
bb
]
=
False
np
.
testing
.
assert_equal
(
a
,
aa
.
numpy
())
# XXX: trace does not expect empty condtake tensor
if
not
use_symbolic_shape
():
a
=
np
.
ones
((
2
,
2
),
dtype
=
np
.
int32
)
b
=
np
.
array
([[
False
,
False
],
[
False
,
False
]])
aa
=
Tensor
(
a
)
bb
=
Tensor
(
b
)
np
.
testing
.
assert_equal
(
a
[
b
],
aa
[
b
].
numpy
())
np
.
testing
.
assert_equal
(
a
[
b
],
aa
[
bb
].
numpy
())
b
=
np
.
array
([
False
,
False
])
bb
=
Tensor
(
b
)
np
.
testing
.
assert_equal
(
a
[
b
],
aa
[
bb
].
numpy
().
reshape
(
a
[
b
].
shape
))
# FIXME
a
=
np
.
ones
((
2
,
2
),
dtype
=
np
.
int32
)
b
=
np
.
array
([[
False
,
False
],
[
False
,
False
]])
aa
=
Tensor
(
a
)
bb
=
Tensor
(
b
)
np
.
testing
.
assert_equal
(
a
[
b
],
aa
[
b
].
numpy
())
np
.
testing
.
assert_equal
(
a
[
b
],
aa
[
bb
].
numpy
())
b
=
np
.
array
([
False
,
False
])
bb
=
Tensor
(
b
)
np
.
testing
.
assert_equal
(
a
[
b
],
aa
[
bb
].
numpy
().
reshape
(
a
[
b
].
shape
))
a
=
np
.
arange
(
576
).
reshape
(
2
,
3
,
4
,
3
,
4
,
2
).
astype
(
"int32"
)
aa
=
Tensor
(
a
)
...
...
imperative/python/test/unit/jit/test_tracing.py
浏览文件 @
ee790cb6
...
...
@@ -521,10 +521,11 @@ def test_trace_valid_broadcast():
f
(
x2
,
shape
)
def
test_clip
():
@
pytest
.
mark
.
parametrize
(
"trace_mode"
,
[
False
,
True
])
def
test_clip
(
trace_mode
):
x
=
tensor
(
np
.
random
.
randn
(
10
,
10
))
@
trace
(
symbolic
=
Tru
e
)
@
trace
(
symbolic
=
trace_mod
e
)
def
f
(
x
,
lower
,
upper
):
y
=
F
.
clip
(
x
,
lower
,
upper
)
return
y
...
...
@@ -532,6 +533,9 @@ def test_clip():
for
i
in
range
(
3
):
f
(
x
,
tensor
([
0
]),
tensor
([
1
]))
for
i
in
range
(
3
):
f
(
x
,
tensor
([
5
]),
tensor
([
4
]))
# test returning noncontiguous tensor from trace
def
test_slice
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录