Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
4ab259f5
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看板
提交
4ab259f5
编写于
9月 14, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(mge): add some deprecation and migration guides
GitOrigin-RevId: 4793adf02bc188e6b745952a01c497391854b291
上级
715009b5
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
35 addition
and
4 deletion
+35
-4
imperative/python/megengine/jit/tracing.py
imperative/python/megengine/jit/tracing.py
+6
-0
imperative/python/megengine/module/module.py
imperative/python/megengine/module/module.py
+11
-2
imperative/python/megengine/optimizer/optimizer.py
imperative/python/megengine/optimizer/optimizer.py
+15
-1
imperative/python/megengine/tensor.py
imperative/python/megengine/tensor.py
+3
-1
未找到文件。
imperative/python/megengine/jit/tracing.py
浏览文件 @
4ab259f5
...
...
@@ -725,6 +725,12 @@ 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
(
RawTensor
):
"""
...
...
imperative/python/megengine/module/module.py
浏览文件 @
4ab259f5
...
...
@@ -174,7 +174,11 @@ class Module(metaclass=ABCMeta):
if
"requires_grad"
in
kwargs
:
del
kwargs
[
"requires_grad"
]
warnings
.
warn
(
"passing requires_grad has no effect currently"
)
warnings
.
warn
(
"Tensor currently has no requires_grad attribute "
"so requires_grad argument is ignored here"
,
DeprecationWarning
,
)
def
predicate
(
obj
)
->
bool
:
return
_is_parameter
(
obj
)
...
...
@@ -197,7 +201,11 @@ class Module(metaclass=ABCMeta):
if
"requires_grad"
in
kwargs
:
del
kwargs
[
"requires_grad"
]
warnings
.
warn
(
"passing requires_grad has no effect currently"
)
warnings
.
warn
(
"Tensor currently has no requires_grad attribute "
"so requires_grad argument is ignored here"
,
DeprecationWarning
,
)
def
predicate
(
obj
)
->
bool
:
return
_is_parameter
(
obj
)
...
...
@@ -339,6 +347,7 @@ class Module(metaclass=ABCMeta):
self
.
apply
(
fn
)
@
deprecated
(
version
=
"1.0"
)
def
replace_param
(
self
,
params
:
dict
,
start_pos
:
int
,
seen
:
Optional
[
Set
[
int
]]
=
None
):
...
...
imperative/python/megengine/optimizer/optimizer.py
浏览文件 @
4ab259f5
...
...
@@ -16,6 +16,7 @@ from typing import Union
import
numpy
as
np
from
..tensor
import
Parameter
,
Tensor
from
..utils.deprecation
import
deprecated
class
_RequiredParameter
:
...
...
@@ -149,8 +150,15 @@ class Optimizer(metaclass=ABCMeta):
self
.
_updates
(
group
)
return
self
@
deprecated
(
version
=
"1.0"
,
reason
=
"use clear_grad instead"
)
def
zero_grad
(
self
):
for
param_group
in
self
.
param_groups
:
for
param
in
param_group
[
"params"
]:
if
param
.
grad
is
not
None
:
param
.
grad
.
reset_zero
()
def
clear_grad
(
self
):
r
"""
Clear the grad buffer
.
r
"""
Set the grad attribute to None for all parameters
.
"""
for
param_group
in
self
.
param_groups
:
...
...
@@ -224,3 +232,9 @@ class Optimizer(metaclass=ABCMeta):
"loaded state dict contains a state that doesn't match "
"the size of optimizer's state"
)
def
backward
(
self
,
loss
):
raise
NotImplementedError
(
"use autodiff.GradManager instead"
)
def
bcast_param
(
self
):
raise
NotImplementedError
(
"use distributed.bcast_list_ instead"
)
imperative/python/megengine/tensor.py
浏览文件 @
4ab259f5
...
...
@@ -13,6 +13,7 @@ import collections
from
.core
import
Tensor
as
_Tensor
from
.core.ops.builtin
import
Copy
from
.core.tensor.core
import
apply
from
.core.tensor.raw_tensor
import
as_device
from
.device
import
get_default_device
from
.utils.deprecation
import
deprecated
...
...
@@ -35,7 +36,8 @@ class Tensor(_Tensor):
def
reset_zero
(
self
):
self
*=
0
def
to
(
self
,
cn
):
def
to
(
self
,
device
):
cn
=
as_device
(
device
).
to_c
()
return
apply
(
Copy
(
comp_node
=
cn
),
self
)[
0
]
@
property
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录