• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 Huawei Technologies Co., Ltd
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #include "abstract/utils.h"
17 
18 #include "common/common_test.h"
19 #include "pipeline/jit/static_analysis/static_analysis.h"
20 
21 namespace mindspore {
22 namespace abstract {
23 class TestUtils : public UT::Common {
24  public:
TestUtils()25   TestUtils() {}
SetUp()26   virtual void SetUp() {}
TearDown()27   virtual void TearDown() {}
28 };
29 
TEST_F(TestUtils,test_join)30 TEST_F(TestUtils, test_join) {
31   // AbstractScalar
32   AbstractBasePtr abs_s1 = FromValue(static_cast<int64_t>(1), false);
33   AbstractBasePtr abs_s2 = FromValue(static_cast<int64_t>(2), false);
34   AbstractBasePtr abs_s_anything = FromValue(static_cast<int64_t>(2), true);
35   abs_s_anything->set_value(kAnyValue);
36 
37   AbstractBasePtr res_s1 = abs_s1->Join(abs_s2);
38   ASSERT_EQ(*res_s1, *abs_s_anything);
39 
40   abs_s1 = FromValue(static_cast<int64_t>(1), false);
41 
42   AbstractBasePtr t1 = std::make_shared<AbstractTuple>(AbstractBasePtrList({abs_s1, abs_s_anything}));
43   AbstractBasePtr t2 = std::make_shared<AbstractTuple>(AbstractBasePtrList({abs_s1, abs_s_anything}));
44   AbstractBasePtr t3 = std::make_shared<AbstractTuple>(AbstractBasePtrList({abs_s_anything, abs_s_anything}));
45 
46   AbstractBasePtr res_t1 = t1->Join(t2);
47   ASSERT_EQ(res_t1, t1);
48 
49   res_t1 = t1->Join(t3);
50   ASSERT_EQ(*res_t1, *t3);
51 
52   res_t1 = t3->Join(t1);
53   ASSERT_EQ(res_t1, t3);
54 }
55 
56 }  // namespace abstract
57 }  // namespace mindspore
58