Browse Source

!9470 support arange in functional.py

From: @bairongz
Reviewed-by: @ginfung
Signed-off-by:
tags/v1.1.0
mindspore-ci-bot Gitee 5 years ago
parent
commit
6d34bacc17
2 changed files with 15 additions and 0 deletions
  1. +6
    -0
      mindspore/ops/functional.py
  2. +9
    -0
      tests/ut/python/ops/test_math_ops.py

+ 6
- 0
mindspore/ops/functional.py 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()


+ 9
- 0
tests/ut/python/ops/test_math_ops.py 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 """



Loading…
Cancel
Save