Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
b5e46ae9
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
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看板
提交
b5e46ae9
编写于
12月 25, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(mge): restore Function
GitOrigin-RevId: dd455238bae9e937b70eaaa164ad215ef3126d5d
上级
dc250745
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
35 addition
and
13 deletion
+35
-13
imperative/python/megengine/__init__.py
imperative/python/megengine/__init__.py
+6
-5
imperative/python/megengine/core/autodiff/grad.py
imperative/python/megengine/core/autodiff/grad.py
+23
-1
imperative/python/megengine/quantization/fake_quant.py
imperative/python/megengine/quantization/fake_quant.py
+1
-1
imperative/python/megengine/quantization/internal_fake_quant.py
...tive/python/megengine/quantization/internal_fake_quant.py
+1
-1
imperative/python/megengine/quantization/utils.py
imperative/python/megengine/quantization/utils.py
+1
-1
imperative/python/test/unit/core/test_function.py
imperative/python/test/unit/core/test_function.py
+2
-2
imperative/python/test/unit/quantization/test_fake_quant.py
imperative/python/test/unit/quantization/test_fake_quant.py
+1
-2
未找到文件。
imperative/python/megengine/__init__.py
浏览文件 @
b5e46ae9
...
...
@@ -6,11 +6,11 @@
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import
atexit
import
ctypes
import
os
import
sys
import
platform
import
ctypes
import
atexit
import
sys
if
sys
.
platform
==
"win32"
:
lib_path
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
"core/lib"
)
...
...
@@ -71,14 +71,15 @@ if sys.platform == "win32":
kernel32
.
SetErrorMode
(
old_error_mode
)
from
.core._imperative_rt.utils
import
_set_fork_exec_path_for_timed_func
from
.core._imperative_rt.core2
import
sync
from
.core._imperative_rt.utils
import
_set_fork_exec_path_for_timed_func
from
.device
import
*
from
.logger
import
enable_debug_log
,
get_logger
,
set_log_file
,
set_log_level
from
.serialization
import
load
,
save
from
.tensor
import
Parameter
,
Tensor
,
tensor
from
.utils
import
comp_graph_tools
as
cgtools
from
.utils
import
persistent_cache
from
.version
import
__version__
from
.utils
import
persistent_cache
,
comp_graph_tools
as
cgtools
_set_fork_exec_path_for_timed_func
(
sys
.
executable
,
...
...
imperative/python/megengine/core/autodiff/grad.py
浏览文件 @
b5e46ae9
...
...
@@ -16,7 +16,7 @@ import numpy as np
import
megengine
as
mge
from
.._imperative_rt
import
core2
from
.._imperative_rt
import
core2
,
ops
from
..ops.builtin
import
Elemwise
,
OpDef
,
RemoteSend
from
..ops.special
import
Const
from
..tensor.core
import
TensorBase
,
TensorWrapperBase
,
apply
...
...
@@ -211,3 +211,25 @@ class Grad:
def
__exit__
(
self
,
_1
,
_2
,
_3
):
del
self
.
_impl
class
Function
(
ops
.
PyOpBase
):
def
_default_rule
(
self
,
*
args
):
ret
=
self
.
forward
(
*
args
)
self
.
__single_output
=
isinstance
(
ret
,
core2
.
Tensor
)
return
ret
def
_grad_rule
(
self
,
*
args
):
return
self
.
_default_rule
(
*
args
),
self
.
backward
def
__call__
(
self
,
*
args
):
ret
=
core2
.
apply
(
self
,
*
args
)
if
self
.
__single_output
:
(
ret
,)
=
ret
return
ret
def
__getstate__
(
self
):
return
self
.
__dict__
def
__setstate__
(
self
,
state
):
self
.
__dict__
.
update
(
state
)
imperative/python/megengine/quantization/fake_quant.py
浏览文件 @
b5e46ae9
...
...
@@ -11,8 +11,8 @@ from typing import Iterable
import
numpy
as
np
from
..
import
functional
as
F
from
..core.autodiff.grad
import
Function
from
..core.tensor.dtype
import
_metadata_dict
,
get_quantized_dtype
from
..core.tensor.function
import
Function
from
..module
import
Module
from
..tensor
import
Parameter
,
Tensor
from
.utils
import
QuantMode
,
fake_quant_tensor
,
get_qparam_dict
...
...
imperative/python/megengine/quantization/internal_fake_quant.py
浏览文件 @
b5e46ae9
...
...
@@ -12,7 +12,7 @@ from functools import partial
import
numpy
as
np
from
..
import
functional
as
F
from
..core.
tensor.function
import
Function
from
..core.
autodiff.grad
import
Function
from
.fake_quant
import
_FakeQuantize
from
.observer
import
MinMaxObserver
from
.qconfig
import
QConfig
...
...
imperative/python/megengine/quantization/utils.py
浏览文件 @
b5e46ae9
...
...
@@ -12,11 +12,11 @@ from typing import Dict
import
numpy
as
np
from
..
import
functional
as
F
from
..core.autodiff.grad
import
Function
from
..core.ops
import
builtin
from
..core.tensor
import
megbrain_graph
from
..core.tensor.core
import
apply
from
..core.tensor.dtype
import
_metadata_dict
from
..core.tensor.function
import
Function
from
..tensor
import
Tensor
...
...
imperative/python/test/unit/core/test_function.py
浏览文件 @
b5e46ae9
...
...
@@ -15,7 +15,7 @@ import megengine.optimizer as optimizer
from
megengine
import
Parameter
from
megengine
import
Tensor
as
tensor
from
megengine
import
tensor
from
megengine.core.
tensor.function
import
Function
from
megengine.core.
autodiff.grad
import
Function
from
megengine.module
import
Module
...
...
@@ -239,7 +239,7 @@ def test_none_in_out_grad():
def
backward
(
self
,
grad_a
,
grad_b
):
assert
grad_b
is
None
return
(
grad_a
,
0.0
)
return
(
grad_a
,
None
)
class
Simple
(
Module
):
def
__init__
(
self
,
a
,
b
):
...
...
imperative/python/test/unit/quantization/test_fake_quant.py
浏览文件 @
b5e46ae9
...
...
@@ -11,8 +11,7 @@ import pytest
import
megengine
as
mge
from
megengine
import
tensor
from
megengine.core.autodiff.grad
import
Grad
from
megengine.core.tensor.function
import
Function
from
megengine.core.autodiff.grad
import
Function
,
Grad
from
megengine.core.tensor.utils
import
make_shape_tuple
from
megengine.quantization.fake_quant
import
TQT_Function
from
megengine.quantization.internal_fake_quant
import
*
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录