!9470 support arange in functional.py

From: @bairongz
Reviewed-by: @ginfung
Signed-off-by:
This commit is contained in:
mindspore-ci-bot 2020-12-09 14:39:36 +08:00 committed by Gitee
commit 6d34bacc17
2 changed files with 15 additions and 0 deletions

View File

@ -22,6 +22,12 @@ from .primitive import Primitive
from . import operations as P
from .operations import _grad_ops
def arange(start, limit=None, delta=1):
from mindspore.nn import Range
return Range(start, limit, delta)()
typeof = Primitive('typeof')
hastype = Primitive('hastype')
cast = P.Cast()

View File

@ -24,6 +24,7 @@ from mindspore import Tensor
from mindspore.common import dtype as mstype
from mindspore.ops import composite as C
from mindspore.ops import operations as P
from mindspore.ops import functional as F
from mindspore.ops import prim_attr_register, PrimitiveWithInfer
from ..ut_filter import non_graph_engine
from ....mindspore_test_framework.mindspore_test import mindspore_test
@ -41,6 +42,7 @@ context.set_context(mode=context.GRAPH_MODE)
grad = C.GradOperation()
def test_multiply():
""" test_multiply """
input_x = Tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]]))
@ -138,6 +140,13 @@ def test_eye():
assert np.all(eye_output.asnumpy() == expect)
def test_arange():
""" test_arange """
F.arange(10)
F.arange(1, 5)
F.arange(1, 10, 2)
class VirtualLossGrad(PrimitiveWithInfer):
""" VirtualLossGrad definition """