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