提交 c8920945 编写于 作者: M Megvii Engine Team

ci(mge): remove blank line for windows doctest

GitOrigin-RevId: 09cf6518e8cf96113f455a6222ba17f271143bb4
上级 e082e277
......@@ -208,25 +208,16 @@ def broadcast_to(inp: Tensor, shape: Union[int, Iterable[int]]) -> Tensor:
from megengine import tensor
import megengine.functional as F
data = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3))
out = F.broadcast_to(data, (4, 2, 3))
data = tensor(np.arange(0, 3, dtype=np.float32).reshape(3))
out = F.broadcast_to(data, (2, 3))
print(out.numpy())
Outputs:
.. testoutput::
[[[0. 1. 2.]
[3. 4. 5.]]
[[0. 1. 2.]
[3. 4. 5.]]
[[0. 1. 2.]
[3. 4. 5.]]
[[0. 1. 2.]
[3. 4. 5.]]]
[[0. 1. 2.]
[0. 1. 2.]]
"""
return _broadcast(inp, shape)
......@@ -298,8 +289,8 @@ def stack(inps, axis=0, device=None):
from megengine import tensor
import megengine.functional as F
x1 = tensor(np.arange(0, 6, dtype=np.float32).reshape((2, 3)))
x2 = tensor(np.arange(6, 12, dtype=np.float32).reshape((2, 3)))
x1 = tensor(np.arange(0, 3, dtype=np.float32).reshape((3)))
x2 = tensor(np.arange(6, 9, dtype=np.float32).reshape((3)))
out = F.stack([x1, x2], axis=0)
print(out.numpy())
......@@ -307,11 +298,8 @@ def stack(inps, axis=0, device=None):
.. testoutput::
[[[ 0. 1. 2.]
[ 3. 4. 5.]]
[[ 6. 7. 8.]
[ 9. 10. 11.]]]
[[0. 1. 2.]
[6. 7. 8.]]
"""
if len(inps) > 0 and not isinstance(inps[0].shape, inps[0].__class__):
......@@ -751,21 +739,16 @@ def reshape(inp: Tensor, target_shape: Iterable[int]) -> Tensor:
from megengine import tensor
import megengine.functional as F
x = tensor(np.arange(12, dtype=np.int32))
out = F.reshape(x, (3, 2, 2))
out = F.reshape(x, (3, 4))
print(out.numpy())
Outputs:
.. testoutput::
[[[ 0 1]
[ 2 3]]
[[ 4 5]
[ 6 7]]
[[ 8 9]
[10 11]]]
[[ 0 1 2 3]
[ 4 5 6 7]
[ 8 9 10 11]]
"""
return inp.reshape(target_shape)
......
......@@ -38,10 +38,10 @@ class Embedding(Module):
import numpy as np
import megengine as mge
import megengine.module as M
weight = mge.tensor(np.array([(1.2,2.3,3.4,4.5,5.6),(0.1,1.1,2.1,3.1,4.1)], dtype=np.float32))
data = mge.tensor(np.array([(0,1,1),(1,0,1),(0,0,1)], dtype=np.int32))
weight = mge.tensor(np.array([(1.2,2.3,3.4,4.5,5.6)], dtype=np.float32))
data = mge.tensor(np.array([(0,0)], dtype=np.int32))
embedding = M.Embedding(2, 5, initial_weight=weight)
embedding = M.Embedding(1, 5, initial_weight=weight)
output = embedding(data)
with np.printoptions(precision=6):
print(output.numpy())
......@@ -51,16 +51,7 @@ class Embedding(Module):
.. testoutput::
[[[1.2 2.3 3.4 4.5 5.6]
[0.1 1.1 2.1 3.1 4.1]
[0.1 1.1 2.1 3.1 4.1]]
[[0.1 1.1 2.1 3.1 4.1]
[1.2 2.3 3.4 4.5 5.6]
[0.1 1.1 2.1 3.1 4.1]]
[[1.2 2.3 3.4 4.5 5.6]
[1.2 2.3 3.4 4.5 5.6]
[0.1 1.1 2.1 3.1 4.1]]]
[1.2 2.3 3.4 4.5 5.6]]]
"""
......@@ -134,8 +125,8 @@ class Embedding(Module):
import numpy as np
import megengine as mge
import megengine.module as M
weight = mge.tensor(np.array([(1.2,2.3,3.4,4.5,5.6),(0.1,1.1,2.1,3.1,4.1)], dtype=np.float32))
data = mge.tensor(np.array([(0,1,1),(1,0,1),(0,0,1)], dtype=np.int32))
weight = mge.tensor(np.array([(1.2,2.3,3.4,4.5,5.6)], dtype=np.float32))
data = mge.tensor(np.array([(0,0)], dtype=np.int32))
embedding = M.Embedding.from_pretrained(weight, freeze=False)
output = embedding(data)
......@@ -146,17 +137,7 @@ class Embedding(Module):
.. testoutput::
[[[1.2 2.3 3.4 4.5 5.6]
[0.1 1.1 2.1 3.1 4.1]
[0.1 1.1 2.1 3.1 4.1]]
[[0.1 1.1 2.1 3.1 4.1]
[1.2 2.3 3.4 4.5 5.6]
[0.1 1.1 2.1 3.1 4.1]]
[[1.2 2.3 3.4 4.5 5.6]
[1.2 2.3 3.4 4.5 5.6]
[0.1 1.1 2.1 3.1 4.1]]]
[1.2 2.3 3.4 4.5 5.6]]]
"""
embeddings_shape = embeddings.shape
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册