!5797 add st for pynative mode part2

Merge pull request !5797 from Simson/enhancement-API
pull/5797/MERGE
mindspore-ci-bot 4 years ago committed by Gitee
commit b1fda1d929

@ -16,6 +16,7 @@
import numpy as np
import pytest
import mindspore.nn as nn
from mindspore import context
from mindspore import Tensor, Parameter
from mindspore.nn.wrap.cell_wrapper import WithLossCell
from mindspore.nn.wrap.loss_scale import TrainOneStepWithLossScaleCell
@ -27,6 +28,9 @@ from mindspore.train import Model
from mindspore.nn.optim import Lamb
from mindspore.train.loss_scale_manager import DynamicLossScaleManager
def setup_module():
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
class MindData:
""" Stub for MindData """

@ -15,11 +15,15 @@
import pytest
import numpy as np
from mindspore import context
from mindspore.nn import ReLU
from mindspore.nn import Cell
from mindspore.common.tensor import Tensor
from mindspore.common.api import ms_function
def setup_module():
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
@pytest.mark.level0
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training

@ -0,0 +1,41 @@
# Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ============================================================================
from mindspore import context
from mindspore.nn import ReLU
from mindspore.nn import Cell
from mindspore.common.tensor import Tensor
import numpy as np
def setup_module():
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
def test_parser_operator_floor_div():
class Net(Cell):
def __init__(self):
super(Net, self).__init__()
self.relu = ReLU()
def construct(self, x):
x = self.relu(x)
x = 3 // x
return x
input_np_x = np.array(2).astype(np.float32)
input_me_x = Tensor(input_np_x)
net = Net()
out_me = net(input_me_x)
assert np.allclose(out_me.asnumpy(), 3 // input_np_x, 0.001, 0.001)

@ -16,11 +16,15 @@
import pytest
import numpy as np
import mindspore as ms
from mindspore import context
from mindspore.nn import ReLU
from mindspore.nn import Cell
from mindspore.common.tensor import Tensor
from mindspore.ops import operations as P
def setup_module():
context.set_context(mode=context.PYNATIVE_MODE, device_target="Ascend")
@pytest.mark.level0
@pytest.mark.platform_arm_ascend_training
@pytest.mark.platform_x86_ascend_training

Loading…
Cancel
Save