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.

vm_test.cc 2.1 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "vm/vm.h"
  17. #include "common/common_test.h"
  18. #include "frontend/operator/ops.h"
  19. #include "vm/backend.h"
  20. namespace mindspore {
  21. namespace compile {
  22. class TestCompileVM : public UT::Common {
  23. public:
  24. TestCompileVM() {}
  25. virtual ~TestCompileVM() {}
  26. public:
  27. virtual void SetUp();
  28. virtual void TearDown();
  29. };
  30. void TestCompileVM::SetUp() { MS_LOG(INFO) << "TestCompileVM::SetUp()"; }
  31. void TestCompileVM::TearDown() { MS_LOG(INFO) << "TestCompileVM::TearDown()"; }
  32. TEST_F(TestCompileVM, StructPartial) {
  33. auto partial = new StructPartial(100, VectorRef({20, 60, 100.0}));
  34. std::stringstream ss;
  35. ss << *partial;
  36. delete partial;
  37. partial = nullptr;
  38. }
  39. TEST_F(TestCompileVM, FinalVM) {
  40. std::vector<std::pair<Instruction, VectorRef>> instr;
  41. instr.push_back({Instruction::kCall, VectorRef({static_cast<int64_t>(-1)})});
  42. instr.push_back(
  43. {Instruction::kTailCall, VectorRef({static_cast<int64_t>(-2), static_cast<int64_t>(1), static_cast<int64_t>(1)})});
  44. instr.push_back({Instruction::kReturn, VectorRef({static_cast<int64_t>(-1), static_cast<int64_t>(1)})});
  45. instr.push_back({Instruction::kPartial, VectorRef({static_cast<int64_t>(0), "cc"})});
  46. BackendPtr backend = std::make_shared<Backend>("vm");
  47. auto vm = new FinalVM(instr, backend);
  48. vm->Eval(VectorRef({static_cast<int64_t>(1), static_cast<int64_t>(2), static_cast<int64_t>(3),
  49. static_cast<int64_t>(-1), "a", "b", "c"}));
  50. delete vm;
  51. vm = nullptr;
  52. }
  53. } // namespace compile
  54. } // namespace mindspore