1 /*
2  * Copyright (c) 2023 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_TENSOR_DESC_H
17 #define NEURAL_NETWORK_RUNTIME_TENSOR_DESC_H
18 
19 #include <string>
20 #include <vector>
21 #include "interfaces/kits/c/neural_network_runtime/neural_network_runtime_type.h"
22 
23 namespace OHOS {
24 namespace NeuralNetworkRuntime {
25 class TensorDesc {
26 public:
27     TensorDesc() = default;
28     ~TensorDesc() = default;
29 
30     OH_NN_ReturnCode GetDataType(OH_NN_DataType* dataType) const;
31     OH_NN_ReturnCode SetDataType(OH_NN_DataType dataType);
32 
33     OH_NN_ReturnCode GetFormat(OH_NN_Format* format) const;
34     OH_NN_ReturnCode SetFormat(OH_NN_Format format);
35 
36     OH_NN_ReturnCode GetShape(int32_t** shape, size_t* shapeNum) const;
37     OH_NN_ReturnCode SetShape(const int32_t* shape, size_t shapeNum);
38 
39     OH_NN_ReturnCode GetElementNum(size_t* elementNum) const;
40     OH_NN_ReturnCode GetByteSize(size_t* byteSize) const;
41 
42     OH_NN_ReturnCode SetName(const char* name);
43     OH_NN_ReturnCode GetName(const char** name) const;
44 
45 private:
46     OH_NN_DataType m_dataType {OH_NN_UNKNOWN};
47     OH_NN_Format m_format {OH_NN_FORMAT_NONE};
48     std::vector<int32_t> m_shape;
49     std::string m_name;
50 };
51 }  // namespace NeuralNetworkRuntime
52 }  // namespace OHOS
53 #endif  // NEURAL_NETWORK_RUNTIME_TENSOR_DESC_H