Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
111fa975
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看板
提交
111fa975
编写于
1月 06, 2022
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #422 from Asthestarsfalll:zeroslike
GitOrigin-RevId: 4b464446b55e2619b7cc43bb321aeae8a3cb41ef
上级
48e09738
520db818
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
29 deletion
+16
-29
imperative/python/megengine/functional/tensor.py
imperative/python/megengine/functional/tensor.py
+16
-29
未找到文件。
imperative/python/megengine/functional/tensor.py
浏览文件 @
111fa975
...
@@ -113,7 +113,7 @@ def full(
...
@@ -113,7 +113,7 @@ def full(
data type must be inferred from ``value``. If the value is an ``int``,
data type must be inferred from ``value``. If the value is an ``int``,
the output tensor data type must be the default integer data type. If the
the output tensor data type must be the default integer data type. If the
value is a ``float``, the output tensor data type must be the default
value is a ``float``, the output tensor data type must be the default
floating-point data type. If the value is a ``bool``, the output tensor
floating-point data type. If the value is a ``bool``, the output tensor
must have boolean data type. Default: ``None``.
must have boolean data type. Default: ``None``.
device: device on which to place the created tensor. Default: ``None``.
device: device on which to place the created tensor. Default: ``None``.
...
@@ -222,33 +222,20 @@ def zeros(
...
@@ -222,33 +222,20 @@ def zeros(
def
zeros_like
(
inp
:
Union
[
Tensor
,
SymbolVar
])
->
Union
[
Tensor
,
SymbolVar
]:
def
zeros_like
(
inp
:
Union
[
Tensor
,
SymbolVar
])
->
Union
[
Tensor
,
SymbolVar
]:
r
"""Returns a
zero tensor with the same sha
pe as input tensor.
r
"""Returns a
tensor filled with zeros with the same shape and data ty
pe as input tensor.
Args:
Args:
inp: input tensor.
inp
(Tensor)
: input tensor.
Return:
Return:
output tensor
.
a tensor containing zeros
.
Examples:
Examples:
>>> input = F.arange(9, dtype='int32').reshape(3,3)
.. testcode::
>>> F.zeros_like(input)
Tensor([[0 0 0]
import numpy as np
[0 0 0]
from megengine import tensor
[0 0 0]], dtype=int32, device=xpux:0)
import megengine.functional as F
inp = tensor(np.arange(1, 7, dtype=np.int32).reshape(2,3))
out = F.zeros_like(inp)
print(out.numpy())
Outputs:
.. testoutput::
[[0 0 0]
[0 0 0]]
"""
"""
return
full_like
(
inp
,
0.0
)
return
full_like
(
inp
,
0.0
)
...
@@ -1095,18 +1082,18 @@ def arange(
...
@@ -1095,18 +1082,18 @@ def arange(
dtype
=
"float32"
,
dtype
=
"float32"
,
device
:
Optional
[
CompNode
]
=
None
,
device
:
Optional
[
CompNode
]
=
None
,
)
->
Tensor
:
)
->
Tensor
:
r
"""Returns evenly spaced values within the half-open interval ``[start, stop)`` as a one-dimensional tensor.
r
"""Returns evenly spaced values within the half-open interval ``[start, stop)`` as a one-dimensional tensor.
Note:
Note:
This function cannot guarantee that the interval does not include the stop value in those cases
This function cannot guarantee that the interval does not include the stop value in those cases
where step is not an integer and floating-point rounding errors affect the length of the output tensor.
where step is not an integer and floating-point rounding errors affect the length of the output tensor.
Args:
Args:
start: if ``stop`` is specified, the start of interval (inclusive); otherwise,
start: if ``stop`` is specified, the start of interval (inclusive); otherwise,
the end of the interval (exclusive). If ``stop`` is not specified, the default starting value is ``0``.
the end of the interval (exclusive). If ``stop`` is not specified, the default starting value is ``0``.
stop: the end of the interval. Default: ``None``.
stop: the end of the interval. Default: ``None``.
step: the distance between two adjacent elements ( ``out[i+1] - out[i]`` ). Must not be 0 ;
step: the distance between two adjacent elements ( ``out[i+1] - out[i]`` ). Must not be 0 ;
may be negative, this results i an empty tensor if stop >= start . Default: 1 .
may be negative, this results i an empty tensor if stop >= start . Default: 1 .
Keyword args:
Keyword args:
dtype( :attr:`.Tensor.dtype` ): output tensor data type. Default: ``float32``.
dtype( :attr:`.Tensor.dtype` ): output tensor data type. Default: ``float32``.
...
@@ -1115,7 +1102,7 @@ def arange(
...
@@ -1115,7 +1102,7 @@ def arange(
Returns:
Returns:
A one-dimensional tensor containing evenly spaced values.
A one-dimensional tensor containing evenly spaced values.
The length of the output tensor must be ``ceil((stop-start)/step)``
The length of the output tensor must be ``ceil((stop-start)/step)``
if ``stop - start`` and ``step`` have the same sign, and length 0 otherwise.
if ``stop - start`` and ``step`` have the same sign, and length 0 otherwise.
Examples:
Examples:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录