• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_int64_support """
16import numpy as np
17import mindspore.nn as nn
18from mindspore import context
19from mindspore.common.tensor import Tensor
20import mindspore as ms
21
22
23def test_parser_support_int64_normal_graph():
24    """ test tensor index support int64 -index, graph mode"""
25    class Net(nn.Cell):
26        def __init__(self):
27            super().__init__()
28
29        def construct(self, inputs, tensor_in):
30            result = inputs[tensor_in]
31            return result
32
33    context.set_context(mode=context.GRAPH_MODE)
34    input_np_x = np.random.randn(2, 3, 4, 5).astype(np.float32)
35    input_me_x = Tensor(input_np_x, ms.float32)
36    input_np_y = np.random.randint(2, size=[1, 2]).astype(np.int64)
37    tensor = Tensor(input_np_y, ms.int64)
38    net = Net()
39    net(input_me_x, tensor).asnumpy()
40