You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

lite_utils.h 1.9 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifndef MINDSPORE_LITE_INCLUDE_LITE_UTILS_H_
  17. #define MINDSPORE_LITE_INCLUDE_LITE_UTILS_H_
  18. #include <vector>
  19. #include <string>
  20. #include <memory>
  21. #include "schema/model_generated.h"
  22. #include "include/ms_tensor.h"
  23. namespace mindspore::lite {
  24. /// \brief Allocator defined a memory pool for malloc memory and free memory dynamically.
  25. ///
  26. /// \note List public class and interface for reference.
  27. class Allocator;
  28. /// \brief DeviceContext defined a device context.
  29. struct DeviceContext;
  30. using TensorPtrVector = std::vector<mindspore::schema::Tensor *>;
  31. using DeviceContextVector = std::vector<DeviceContext>;
  32. using Uint32Vector = std::vector<uint32_t>;
  33. using String = std::string;
  34. using NodeType = schema::NodeType;
  35. using AllocatorPtr = std::shared_ptr<Allocator>;
  36. /// \brief Set data of MSTensor from string vector.
  37. ///
  38. /// \param[in] input string vector.
  39. /// \param[out] MSTensor.
  40. ///
  41. /// \return STATUS as an error code of this interface, STATUS is defined in errorcode.h.
  42. int StringsToMSTensor(const std::vector<std::string> &inputs, tensor::MSTensor *tensor);
  43. /// \brief Get string vector from MSTensor.
  44. /// \param[in] MSTensor.
  45. /// \return string vector.
  46. std::vector<std::string> MSTensorToStrings(const tensor::MSTensor *tensor);
  47. } // namespace mindspore::lite
  48. #endif // MINDSPORE_LITE_INCLUDE_LITE_UTILS_H_