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 #ifndef NEURAL_NETWORK_RUNTIME_OPS_TEST_H
17 #define NEURAL_NETWORK_RUNTIME_OPS_TEST_H
18 
19 #include <memory>
20 
21 #include "mindir.h"
22 
23 #include "nn_tensor.h"
24 #include "test/unittest/common/base_test.h"
25 
26 namespace OHOS {
27 namespace NeuralNetworkRuntime {
28 namespace UnitTest {
29 class OpsTest : public BaseTest {
30 public:
31     OpsTest() = default;
32     virtual void SaveInputTensor(const std::vector<uint32_t>& inputsIndex, OH_NN_DataType dataType,
33         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam);
34     virtual void SaveOutputTensor(const std::vector<uint32_t>& outputsIndex, OH_NN_DataType dataType,
35         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam);
InitTensor(const std::vector<uint32_t> & inputsIndex,const std::vector<uint32_t> & outputsIndex)36     virtual void InitTensor(const std::vector<uint32_t>& inputsIndex, const std::vector<uint32_t>& outputsIndex) {};
37 
38     void SetKernelSize(OH_NN_DataType dataType,
39         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type);
40     void SetStride(OH_NN_DataType dataType,
41         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type);
42     void SetActivation(OH_NN_DataType dataType,
43         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type);
44     void SetDilation(OH_NN_DataType dataType,
45         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type);
46     void SetGroup(OH_NN_DataType dataType,
47         const std::vector<int32_t> &dim,  const OH_NN_QuantParam* quantParam, OH_NN_TensorType type);
48 
49 public:
50     std::vector<uint32_t> m_inputsIndex {};
51     std::vector<uint32_t> m_outputsIndex {};
52     std::vector<uint32_t> m_paramsIndex {};
53     std::vector<std::shared_ptr<NNTensor>> m_allTensors;
54 };
55 } // namespace UnitTest
56 } // namespace NeuralNetworkRuntime
57 } // namespace OHOS
58 #endif // NEURAL_NETWORK_RUNTIME_OPS_TEST_H
59