1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gmock/gmock.h>
17 #include <gtest/gtest.h>
18
19 #include "common/utils.h"
20 #include "inner_model.h"
21 #include "hdi_device_v2_0.h"
22 #include "ops/div_builder.h"
23 #include "mock_idevice.h"
24
25 namespace OHOS {
26 namespace NeuralNetworkRuntime {
27
28 // Mock the palce where the operator GetPrimitive is called in inner_model build function.
GetPrimitive()29 Ops::LiteGraphPrimitvePtr Ops::DivBuilder::GetPrimitive()
30 {
31 Ops::LiteGraphPrimitvePtr primitive = {nullptr, DestroyLiteGraphTensor};
32 return primitive;
33 }
34
35 // Mock the palce where the device GetSupportedOperation is called in inner_model build function.
GetSupportedOperation(std::shared_ptr<const mindspore::lite::LiteGraph> model,std::vector<bool> & supportedOperations)36 OH_NN_ReturnCode HDIDeviceV2_0::GetSupportedOperation(std::shared_ptr<const mindspore::lite::LiteGraph> model,
37 std::vector<bool>& supportedOperations)
38 {
39 supportedOperations = {true, true, true};
40
41 if (model->name_ == "Loaded_NNR_Model") {
42 return OH_NN_UNAVAILABLE_DEVICE;
43 } else {
44 return OH_NN_SUCCESS;
45 }
46 }
47 } // NeuralNetworkRuntime
48 } // OHOS
49