You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils_test.cc 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. #include "common/common_test.h"
  18. #include "pipeline/jit/static_analysis/static_analysis.h"
  19. namespace mindspore {
  20. namespace abstract {
  21. class TestUtils : public UT::Common {
  22. public:
  23. TestUtils() {}
  24. virtual void SetUp() {}
  25. virtual void TearDown() {}
  26. };
  27. TEST_F(TestUtils, test_join) {
  28. // AbstractScalar
  29. AbstractBasePtr abs_s1 = FromValue(static_cast<int64_t>(1), false);
  30. AbstractBasePtr abs_s2 = FromValue(static_cast<int64_t>(2), false);
  31. AbstractBasePtr abs_s_anything = FromValue(static_cast<int64_t>(2), true);
  32. abs_s_anything->set_value(kAnyValue);
  33. AbstractBasePtr res_s1 = abs_s1->Join(abs_s2);
  34. ASSERT_EQ(*res_s1, *abs_s_anything);
  35. abs_s1 = FromValue(static_cast<int64_t>(1), false);
  36. AbstractBasePtr t1 = std::make_shared<AbstractTuple>(AbstractBasePtrList({abs_s1, abs_s_anything}));
  37. AbstractBasePtr t2 = std::make_shared<AbstractTuple>(AbstractBasePtrList({abs_s1, abs_s_anything}));
  38. AbstractBasePtr t3 = std::make_shared<AbstractTuple>(AbstractBasePtrList({abs_s_anything, abs_s_anything}));
  39. AbstractBasePtr res_t1 = t1->Join(t2);
  40. ASSERT_EQ(res_t1, t1);
  41. res_t1 = t1->Join(t3);
  42. ASSERT_EQ(*res_t1, *t3);
  43. res_t1 = t3->Join(t1);
  44. ASSERT_EQ(res_t1, t3);
  45. }
  46. } // namespace abstract
  47. } // namespace mindspore