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_H 17 #define NEURAL_NETWORK_RUNTIME_TENSOR_H 18 19 #include <memory> 20 #include "tensor_desc.h" 21 22 namespace OHOS { 23 namespace NeuralNetworkRuntime { 24 class Tensor { 25 public: 26 Tensor() = default; 27 Tensor(size_t backendID); 28 virtual ~Tensor() = default; 29 30 virtual OH_NN_ReturnCode SetTensorDesc(const TensorDesc* tensorDesc) = 0; 31 virtual OH_NN_ReturnCode CreateData() = 0; 32 virtual OH_NN_ReturnCode CreateData(size_t size) = 0; 33 virtual OH_NN_ReturnCode CreateData(int fd, size_t size, size_t offset) = 0; 34 35 virtual TensorDesc* GetTensorDesc() const = 0; 36 virtual void* GetData() const = 0; 37 virtual int GetFd() const = 0; 38 virtual size_t GetSize() const = 0; 39 virtual size_t GetOffset() const = 0; 40 virtual size_t GetBackendID() const = 0; 41 }; 42 } // namespace NeuralNetworkRuntime 43 } // namespace OHOS 44 #endif // NEURAL_NETWORK_RUNTIME_TENSOR_H