1 /** 2 * Copyright 2022 Huawei Technologies Co., Ltd 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #ifndef MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_TENSORRT_TENSOR_INFO_H_ 17 #define MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_TENSORRT_TENSOR_INFO_H_ 18 19 #include <utility> 20 #include <string> 21 #include <vector> 22 #include <memory> 23 #include "include/api/kernel.h" 24 #include "core/ir/tensor.h" 25 26 namespace mindspore::lite { 27 class TensorInfoImpl; 28 class TensorInfo { 29 public: 30 TensorInfo() = default; 31 TensorInfo(const std::string &name, mindspore::DataType type, const std::vector<int64_t> &shape, 32 mindspore::Format format, const void *data, size_t data_len, 33 const mindspore::tensor::TensorPtr &tensor_val); 34 ~TensorInfo() = default; 35 36 std::string Name() const; 37 mindspore::DataType DataType() const; 38 mindspore::Format format() const; 39 const std::vector<int64_t> &Shape() const; 40 int64_t ElementNum() const; 41 const void *Data() const; 42 void *MutableData(); 43 size_t DataSize() const; 44 45 bool IsConst() const; 46 47 void SetShape(const std::vector<int64_t> &shape); 48 void SetDataType(const mindspore::DataType data_type); 49 void SetData(const void *data, size_t data_len); 50 51 size_t item_size() const; 52 53 TensorInfo &operator=(const TensorInfo &other); 54 bool operator==(const TensorInfo &other) const; 55 bool operator!=(const TensorInfo &other) const; 56 bool operator<(const TensorInfo &other) const; 57 58 private: 59 std::shared_ptr<TensorInfoImpl> impl_ = nullptr; 60 }; 61 } // namespace mindspore::lite 62 #endif // MINDSPORE_LITE_SRC_EXTENDRT_DELEGATE_TENSORRT_TENSOR_INFO_H_ 63