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 "base_test.h"
17 
18 using namespace OHOS::NeuralNetworkRuntime::Ops;
19 using namespace std;
20 namespace OHOS {
21 namespace NeuralNetworkRuntime {
22 namespace UnitTest {
SetUp()23 void BaseTest::SetUp() {}
24 
TearDown()25 void BaseTest::TearDown() {}
26 
TransToNNTensor(OH_NN_DataType dataType,const std::vector<int32_t> & dim,const OH_NN_QuantParam * quantParam,OH_NN_TensorType type)27 std::shared_ptr<OHOS::NeuralNetworkRuntime::NNTensor> BaseTest::TransToNNTensor(
28     OH_NN_DataType dataType, const std::vector<int32_t>& dim, const OH_NN_QuantParam* quantParam,
29     OH_NN_TensorType type)
30 {
31     std::shared_ptr<NNTensor> nnTensor = std::make_shared<NNTensor>();
32     OH_NN_Tensor tensor;
33     tensor.dataType = dataType;
34     tensor.dimensionCount = dim.size();
35     tensor.dimensions = (dim.empty() ? nullptr : dim.data());
36     tensor.quantParam = quantParam;
37     tensor.type = type;
38     nnTensor->BuildFromOHNNTensor(tensor);
39     return nnTensor;
40 }
41 } // namespace UnitTest
42 } // namespace NeuralNetworkRuntime
43 } // namespace OHOS
44