Browse Source

docs(mge/functional): add docs for megengine.functional.sub

GitOrigin-RevId: 40208739bd
release-1.6
Megvii Engine Team 3 years ago
parent
commit
8485eff12c
1 changed files with 23 additions and 1 deletions
  1. +23
    -1
      imperative/python/megengine/functional/elemwise.py

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

@@ -104,7 +104,29 @@ def add(x, y):


def sub(x, y):
r"""Element-wise `subtraction`."""
r"""Element-wise `sub`.

Examples:

.. testcode::

import numpy as np
from megengine import tensor
import megengine.functional as F

x = tensor(np.arange(1, 7, dtype=np.float32).reshape(2, 3))
y = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3))
out = F.sub(x, y)
print(out.numpy())

Outputs:

.. testoutput::

[[1. 1. 1.]
[1. 1. 1.]]

"""
return _elwise(x, y, mode=Elemwise.Mode.SUB)




Loading…
Cancel
Save