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 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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({-1})});
  42. instr.push_back({Instruction::kTailCall, VectorRef({-2, 1, 1})});
  43. instr.push_back({Instruction::kReturn, VectorRef({-1, 1})});
  44. instr.push_back({Instruction::kPartial, VectorRef({0, "cc"})});
  45. BackendPtr backend = std::make_shared<Backend>("vm");
  46. auto vm = new FinalVM(instr, backend);
  47. vm->Eval(VectorRef({1, 2, 3, -1, "a", "b", "c"}));
  48. delete vm;
  49. vm = nullptr;
  50. }
  51. } // namespace compile
  52. } // namespace mindspore