1# Copyright 2020 Huawei Technologies Co., Ltd 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14# ============================================================================ 15"""Test case.""" 16import numpy as np 17 18import mindspore 19import mindspore.nn as nn 20from mindspore import Tensor, context 21 22 23class Net(nn.Cell): 24 def __init__(self): 25 super(Net, self).__init__() 26 self.conv1 = nn.Conv2d(1, 3, 3) 27 self.conv2 = nn.Conv2d(1, 3, 5, has_bias=True) 28 self.layers = (self.conv1, self.conv2) 29 30 def construct(self, x, index): 31 x = self.layers[index](x) 32 return 2 + x 33 34 35def test_case(): 36 context.set_context(mode=context.GRAPH_MODE) 37 net = Net() 38 data = Tensor(np.ones((1, 1, 224, 224)), mindspore.float32) 39 idx = Tensor(1, mindspore.int32) 40 net(data, idx) 41