Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
5b697c71
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
410
Star
4707
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看板
提交
5b697c71
编写于
2月 22, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
chore(imperative): remove unused reference to megbrain_graph
GitOrigin-RevId: 2c31f13bb8e1df28c7cf6e8c3d34b5d68d430b0f
上级
f0170b9c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
9 addition
and
22 deletion
+9
-22
imperative/python/megengine/core/tensor/utils.py
imperative/python/megengine/core/tensor/utils.py
+1
-2
imperative/python/megengine/functional/elemwise.py
imperative/python/megengine/functional/elemwise.py
+2
-4
imperative/python/megengine/functional/nn.py
imperative/python/megengine/functional/nn.py
+1
-5
imperative/python/megengine/quantization/utils.py
imperative/python/megengine/quantization/utils.py
+0
-9
imperative/python/src/tensor.cpp
imperative/python/src/tensor.cpp
+5
-2
未找到文件。
imperative/python/megengine/core/tensor/utils.py
浏览文件 @
5b697c71
...
...
@@ -15,7 +15,6 @@ from .._imperative_rt.core2 import Tensor, apply, dtype_promotion, get_device
from
..ops
import
builtin
from
..ops.special
import
Const
from
.dtype
import
is_dtype_equal
,
is_quantize
from
.megbrain_graph
import
VarNode
_enable_convert_inputs
=
True
...
...
@@ -60,7 +59,7 @@ def astype(x, dtype):
def
convert_single_value
(
v
,
*
,
dtype
=
None
,
device
=
None
):
if
isinstance
(
v
,
(
Tensor
,
VarNode
)
):
if
isinstance
(
v
,
Tensor
):
if
not
is_quantize
(
v
.
dtype
):
v
=
astype
(
v
,
dtype
)
else
:
...
...
imperative/python/megengine/functional/elemwise.py
浏览文件 @
5b697c71
...
...
@@ -14,7 +14,7 @@ import numpy as np
from
..core._imperative_rt.core2
import
apply
from
..core.ops
import
builtin
from
..core.ops.builtin
import
Elemwise
from
..core.tensor
import
megbrain_graph
,
utils
from
..core.tensor
import
utils
from
..core.tensor.array_method
import
_elwise_apply
from
..core.tensor.utils
import
isscalar
,
setscalar
from
..device
import
get_default_device
...
...
@@ -77,9 +77,7 @@ __all__ = [
def
_elwise
(
*
args
,
mode
):
tensor_args
=
list
(
filter
(
lambda
x
:
isinstance
(
x
,
(
Tensor
,
megbrain_graph
.
VarNode
)),
args
)
)
tensor_args
=
list
(
filter
(
lambda
x
:
isinstance
(
x
,
Tensor
),
args
))
if
len
(
tensor_args
)
==
0
:
dtype
=
utils
.
dtype_promotion
(
args
)
first_arg
=
Tensor
(
args
[
0
],
dtype
=
dtype
,
device
=
get_default_device
())
...
...
imperative/python/megengine/functional/nn.py
浏览文件 @
5b697c71
...
...
@@ -15,7 +15,7 @@ from ..core._trace_option import use_symbolic_shape
from
..core.ops
import
builtin
from
..core.ops.builtin
import
BatchNorm
from
..core.ops.special
import
Const
from
..core.tensor
import
megbrain_graph
,
utils
from
..core.tensor
import
utils
from
..core.tensor.utils
import
astensor1d
,
setscalar
from
..distributed
import
WORLD
,
is_distributed
from
..jit.tracing
import
is_tracing
...
...
@@ -416,7 +416,6 @@ def adaptive_max_pool2d(
:param oshp: `(OH, OW)` size of the output shape.
:return: output tensor.
"""
assert
isinstance
(
inp
,
(
Tensor
,
megbrain_graph
.
VarNode
)),
"inp must be Tensor type"
if
isinstance
(
oshp
,
int
):
oshp
=
(
oshp
,
oshp
)
...
...
@@ -438,7 +437,6 @@ def adaptive_avg_pool2d(
:param oshp: `(OH, OW)` size of the output shape.
:return: output tensor.
"""
assert
isinstance
(
inp
,
(
Tensor
,
megbrain_graph
.
VarNode
)),
"inp must be Tensor type"
if
isinstance
(
oshp
,
int
):
oshp
=
(
oshp
,
oshp
)
...
...
@@ -1181,7 +1179,6 @@ def remap(
op
=
builtin
.
Remap
(
imode
=
interp_mode
,
border_type
=
border_mode
,
format
=
"NCHW"
,
scalar
=
scalar
)
assert
isinstance
(
inp
,
(
Tensor
,
megbrain_graph
.
VarNode
)),
"inp must be Tensor type"
(
result
,)
=
apply
(
op
,
inp
,
map_xy
)
return
result
...
...
@@ -1759,7 +1756,6 @@ def nvof(src: Tensor, precision: int = 1) -> Tensor:
print(result.numpy())
"""
assert
isinstance
(
src
,
(
Tensor
,
megbrain_graph
.
VarNode
)),
"src must be Tensor type"
assert
src
.
ndim
==
5
and
src
.
shape
[
4
]
==
4
src
=
src
.
detach
()
...
...
imperative/python/megengine/quantization/utils.py
浏览文件 @
5b697c71
...
...
@@ -15,7 +15,6 @@ from .. import functional as F
from
..autodiff
import
Function
from
..core._imperative_rt.core2
import
apply
from
..core.ops
import
builtin
from
..core.tensor
import
megbrain_graph
from
..core.tensor.dtype
import
_metadata_dict
from
..tensor
import
Tensor
...
...
@@ -94,14 +93,6 @@ def fake_quant_tensor(inp: Tensor, qmin: int, qmax: int, q_dict: Dict) -> Tensor
if
q_dict
[
"mode"
]
==
QuantMode
.
ASYMMERTIC
:
zero_point
=
q_dict
[
"zero_point"
]
assert
isinstance
(
inp
,
(
Tensor
,
megbrain_graph
.
VarNode
)),
"inp must be Tensor type"
assert
isinstance
(
scale
,
(
Tensor
,
megbrain_graph
.
VarNode
)
),
"scale must be Tensor type"
assert
isinstance
(
zero_point
,
(
Tensor
,
megbrain_graph
.
VarNode
)
),
"zero point must be Tensor type"
op
=
builtin
.
FakeQuant
(
qmin
=
qmin
,
qmax
=
qmax
)
return
apply
(
op
,
inp
,
scale
,
zero_point
)[
0
]
...
...
imperative/python/src/tensor.cpp
浏览文件 @
5b697c71
...
...
@@ -12,6 +12,7 @@
#include "megbrain/dtype.h"
#include "megbrain/common.h"
#include "megbrain/imperative/ops/utility.h"
#include "megbrain/imperative/ops/backward_graph.h"
#include "./tensor.h"
#include "./grad.h"
...
...
@@ -156,7 +157,7 @@ PyObject* py_apply(PyObject* self, PyObject*const* args, size_t nargs/* , PyObje
ctx
.
args
=
&
tensors
[
0
];
ctx
.
nargs
=
nargs
;
ctx
.
pytype
=
pytype
;
if
(
strstr
(
op
->
ob_type
->
tp_name
,
"BackwardGraph"
))
{
if
(
ctx
.
op
->
same_type
<
BackwardGraph
>
(
))
{
ctx
.
backward
=
true
;
}
...
...
@@ -165,7 +166,9 @@ PyObject* py_apply(PyObject* self, PyObject*const* args, size_t nargs/* , PyObje
auto
*
t
=
tensors
[
i
]
=
tw
->
m_tensor
.
get
();
ctx
.
flags
|=
t
->
m_flags
;
}
else
{
PyErr_SetString
(
PyExc_TypeError
,
"expect Tensor"
);
PyErr_SetString
(
PyExc_TypeError
,
ssprintf
(
"op %s expect type Tensor as inputs, got %s actually"
,
ctx
.
op
->
make_name
().
c_str
(),
Py_TYPE
(
args
[
i
])
->
tp_name
).
c_str
());
return
nullptr
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录