From 8485eff12cfc59ae53612542cf47823ba4a0a4a8 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Wed, 25 Aug 2021 20:47:48 +0800 Subject: [PATCH] docs(mge/functional): add docs for megengine.functional.sub GitOrigin-RevId: 40208739bdb6a220ec644a69bc6adb1f65ffe8fd --- imperative/python/megengine/functional/elemwise.py | 24 +++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/imperative/python/megengine/functional/elemwise.py b/imperative/python/megengine/functional/elemwise.py index 03daa9e8..e54fecb4 100644 --- a/imperative/python/megengine/functional/elemwise.py +++ b/imperative/python/megengine/functional/elemwise.py @@ -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)