Browse Source

fix(mge): fix bug of identity()

GitOrigin-RevId: 4bfd3cafb5
tags/v1.0.0-rc1
Megvii Engine Team 4 years ago
parent
commit
70bc746c20
2 changed files with 7 additions and 1 deletions
  1. +1
    -1
      imperative/python/megengine/functional/tensor.py
  2. +6
    -0
      imperative/python/test/unit/functional/test_tensor.py

+ 1
- 1
imperative/python/megengine/functional/tensor.py View File

@@ -189,7 +189,7 @@ def identity(inp: Tensor) -> Tensor:
:return: output tensor.
"""
op = builtin.Identity()
(data,) = utils.convert_inputs(inp)
(data,) = convert_inputs(inp)
(output,) = apply(op, data)
return output



+ 6
- 0
imperative/python/test/unit/functional/test_tensor.py View File

@@ -367,6 +367,12 @@ def test_device():
np.testing.assert_almost_equal(y5.numpy(), y6.numpy())


def test_identity():
x = tensor(np.random.random((5, 10)).astype(np.float32))
y = F.identity(x)
np.testing.assert_equal(y.numpy(), x)


def copy_test(dst, src):
data = np.random.random((2, 3)).astype(np.float32)
x = tensor(data, device=src)


Loading…
Cancel
Save