1 /** 2 * Copyright 2020-2021 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 17 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_DETENSOR_H_ 18 #define MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_DETENSOR_H_ 19 #include <string> 20 #include <vector> 21 #include <memory> 22 #include "include/api/status.h" 23 #include "include/api/types.h" 24 #ifdef ENABLE_ANDROID 25 #include "mindspore/lite/src/cxx_api/tensor/tensor_impl.h" 26 #else 27 #include "mindspore/core/ir/api_tensor_impl.h" 28 #endif 29 #include "minddata/dataset/core/tensor.h" 30 31 namespace mindspore { 32 namespace dataset { 33 class DETensor : public mindspore::MSTensor::Impl { 34 public: 35 DETensor() = default; 36 ~DETensor() = default; 37 explicit DETensor(std::shared_ptr<dataset::Tensor> tensor_impl); 38 #ifndef ENABLE_ANDROID 39 DETensor(std::shared_ptr<dataset::DeviceTensor> device_tensor_impl, bool is_device); 40 #endif 41 const std::string &Name() const override; 42 43 enum mindspore::DataType DataType() const override; 44 45 size_t DataSize() const override; 46 47 const std::vector<int64_t> &Shape() const override; 48 49 std::shared_ptr<const void> Data() const override; 50 51 void *MutableData() override; 52 53 bool IsDevice() const override; 54 55 std::shared_ptr<mindspore::MSTensor::Impl> Clone() const override; 56 57 private: 58 std::shared_ptr<dataset::Tensor> tensor_impl_; 59 #ifndef ENABLE_ANDROID 60 std::shared_ptr<dataset::DeviceTensor> device_tensor_impl_; 61 #endif 62 bool is_device_; 63 std::string name_; 64 enum mindspore::DataType type_; 65 std::vector<int64_t> shape_; 66 }; 67 } // namespace dataset 68 } // namespace mindspore 69 #endif // MINDSPORE_CCSRC_MINDDATA_DATASET_CORE_DETENSOR_H_ 70