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_COMMON_TENSOR_UTIL_H_ 18 #define MINDSPORE_LITE_SRC_COMMON_TENSOR_UTIL_H_ 19 #include <vector> 20 21 #include <memory> 22 #include "src/tensor.h" 23 #include "nnacl/tensor_c.h" 24 #ifndef CONTROLFLOW_TENSORLIST_CLIP 25 #include "src/tensorlist.h" 26 #include "nnacl/infer/common_infer.h" 27 #endif 28 #include "src/cxx_api/tensor/tensor_impl.h" 29 30 namespace mindspore { 31 namespace lite { 32 int OutputTensor2TensorC(const std::vector<lite::Tensor *> &tensors_in, std::vector<TensorC *> *tensors_out); 33 void FreeAllTensorC(std::vector<TensorC *> *tensors_in); 34 int Tensor2TensorC(const Tensor *src, TensorC *dst); 35 int TensorC2Tensor(const TensorC *src, Tensor *dst); 36 #ifndef CONTROLFLOW_TENSORLIST_CLIP 37 void FreeTensorListC(TensorListC *tensorListC); 38 int TensorList2TensorListC(TensorList *src, TensorListC *dst); 39 int TensorListC2TensorList(const TensorListC *src, TensorList *dst); 40 int GenerateMergeSwitchOutTensorC(const std::vector<lite::Tensor *> &inputs, int output_size, 41 std::vector<TensorC *> *out_tensor_c); 42 #endif 43 int GenerateInTensorC(const OpParameter *const parameter, const std::vector<lite::Tensor *> &inputs, 44 const std::vector<lite::Tensor *> &outputs, std::vector<TensorC *> *in_tensor_c); 45 int GenerateOutTensorC(const OpParameter *const parameter, const std::vector<lite::Tensor *> &inputs, 46 const std::vector<lite::Tensor *> &outputs, std::vector<TensorC *> *out_tensor_c); 47 48 int CheckTensorsInvalid(const std::vector<Tensor *> &tensors); 49 50 std::vector<mindspore::MSTensor> LiteTensorsToMSTensors(const std::vector<lite::Tensor *> &lite_tensors); 51 52 } // namespace lite 53 } // namespace mindspore 54 55 #endif // MINDSPORE_LITE_SRC_COMMON_TENSOR_UTIL_H_ 56