• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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 syntax for logic expression """
16
17import numpy as np
18
19import mindspore.nn as nn
20import mindspore
21from mindspore import context
22from mindspore.common.tensor import Tensor
23from mindspore.ops import operations as P
24
25context.set_context(mode=context.GRAPH_MODE, save_graphs=True, save_graphs_path="graph_paths")
26
27
28class ArgumentNum(nn.Cell):
29    def __init__(self):
30        super().__init__()
31        self.matmul = P.MatMul()
32
33    def construct(self, x, y):
34        super(ArgumentNum, 2, 3).aa()
35        out = self.matmul(x, y)
36        return out
37
38
39def test_super_argument_num():
40    x = Tensor(np.ones(shape=[1, 3]), mindspore.float32)
41    y = Tensor(np.ones(shape=[3, 4]), mindspore.float32)
42    net = ArgumentNum()
43    ret = net(x, y)
44    print(ret)
45
46
47class ArgumentNotSelf(nn.Cell):
48    def __init__(self):
49        super().__init__()
50        self.matmul = P.MatMul()
51
52    def construct(self, x, y):
53        super(ArgumentNotSelf, 2).aa()
54        out = self.matmul(x, y)
55        return out
56
57
58def test_super_argument_not_self():
59    x = Tensor(np.ones(shape=[1, 3]), mindspore.float32)
60    y = Tensor(np.ones(shape=[3, 4]), mindspore.float32)
61    net = ArgumentNotSelf()
62    ret = net(x, y)
63    print(ret)
64
65
66class ArgumentType(nn.Cell):
67    def __init__(self):
68        super().__init__()
69        self.matmul = P.MatMul()
70
71    def construct(self, x, y):
72        super(ArgumentType, self).aa()
73        out = self.matmul(x, y)
74        return out
75
76
77def test_super_argument_type():
78    x = Tensor(np.ones(shape=[1, 3]), mindspore.float32)
79    y = Tensor(np.ones(shape=[3, 4]), mindspore.float32)
80    net = ArgumentType()
81    ret = net(x, y)
82    print(ret)
83