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.

strategy_test.cc 2.0 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Copyright 2019 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 <string>
  17. #include <list>
  18. #include <vector>
  19. #include "common/common_test.h"
  20. #include "parallel/strategy.h"
  21. namespace mindspore {
  22. namespace parallel {
  23. class TestStrategy : public UT::Common {
  24. public:
  25. TestStrategy() {}
  26. void SetUp() {}
  27. void TearDown() {}
  28. };
  29. TEST_F(TestStrategy, GetInputNumber) {
  30. int32_t number = 2;
  31. int32_t stage = 1;
  32. std::vector<int32_t> dimension1 = {2, 4};
  33. std::vector<int32_t> dimension2 = {2, 2};
  34. std::vector<std::vector<int32_t>> inputs = {dimension1, dimension2};
  35. Strategy strategy(stage, inputs);
  36. int32_t number_test = strategy.GetInputNumber();
  37. ASSERT_EQ(number, number_test);
  38. }
  39. TEST_F(TestStrategy, GetInputStage) {
  40. int32_t stage = 1;
  41. std::vector<int32_t> dimension1 = {2, 4};
  42. std::vector<int32_t> dimension2 = {2, 2};
  43. std::vector<std::vector<int32_t>> inputs = {dimension1, dimension2};
  44. Strategy strategy(stage, inputs);
  45. int32_t stage_test = strategy.GetInputStage();
  46. ASSERT_EQ(stage, stage_test);
  47. }
  48. TEST_F(TestStrategy, GetInputDim) {
  49. int32_t stage = 1;
  50. std::vector<int32_t> dimension1 = {2, 4};
  51. std::vector<int32_t> dimension2 = {2, 2};
  52. std::vector<std::vector<int32_t>> inputs = {dimension1, dimension2};
  53. Strategy strategy(stage, inputs);
  54. std::vector<std::vector<int32_t>> inputs_test = strategy.GetInputDim();
  55. ASSERT_EQ(inputs, inputs_test);
  56. }
  57. } // namespace parallel
  58. } // namespace mindspore