1 /** 2 * Copyright 2020 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_LITE_SRC_RUNTIME_CXX_API_TENSOR_UTILS_H_ 18 #define MINDSPORE_LITE_SRC_RUNTIME_CXX_API_TENSOR_UTILS_H_ 19 20 #include <limits.h> 21 #include <vector> 22 #include <memory> 23 #include "ir/dtype/type_id.h" 24 #include "src/tensor.h" 25 #include "include/api/types.h" 26 #include "src/litert/cxx_api/tensor/tensor_impl.h" 27 28 namespace mindspore { 29 std::vector<int32_t> MS_API TruncateShape(const std::vector<int64_t> &shape, enum TypeId type, size_t data_len, 30 bool verify_size); 31 32 size_t MS_API CalTensorDataSize(const std::vector<int64_t> &shape, enum DataType type); 33 34 Status MS_API LiteTensorToMSTensor(lite::Tensor *srcTensor, MSTensor *dstTensor, bool fromSession = true); 35 36 std::vector<MSTensor> MS_API LiteTensorsToMSTensors(const std::vector<mindspore::lite::Tensor *> &srcTensors, 37 bool fromSession = true); 38 39 } // namespace mindspore 40 41 #endif // MINDSPORE_LITE_SRC_RUNTIME_CXX_API_TENSOR_UTILS_H_ 42