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_session.h 3.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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_INTERNAL_INCLUDE_LITE_SESSION_H
  17. #define MINDSPORE_LITE_INTERNAL_INCLUDE_LITE_SESSION_H
  18. #include "internal/include/ms_tensor.h"
  19. #include "internal/include/model.h"
  20. #include "internal/include/context.h"
  21. #include "internal/include/lite_utils.h"
  22. /// \brief LiteSession defined session in MindSpore Lite for compiling Model and forwarding model.
  23. typedef struct LiteSession {
  24. /// \brief Static method to create a LiteSession pointer.
  25. ///
  26. /// \param[in] context Define the context of session to be created.
  27. ///
  28. /// \return Pointer of MindSpore Lite LiteSession.
  29. static LiteSession *CreateSession(Context *context);
  30. /// \brief Compile MindSpore Lite model.
  31. ///
  32. /// \note CompileGraph should be called before RunGraph.
  33. ///
  34. /// \param[in] model Define the model to be compiled.
  35. ///
  36. /// \return STATUS as an error code of compiling graph, STATUS is defined in errorcode.h.
  37. int CompileGraph(Model *model);
  38. /// \brief Get input MindSpore Lite MSTensors of model.
  39. ///
  40. /// \return The vector of MindSpore Lite MSTensor.
  41. TensorPtrVector GetInputs() const;
  42. /// \brief Get input MindSpore Lite MSTensors of model by node name.
  43. ///
  44. /// \param[in] node_name Define node name.
  45. ///
  46. /// \return The vector of MindSpore Lite MSTensor.
  47. TensorPtrVector GetInputsByName(const String &node_name) const;
  48. /// \brief Get output MindSpore Lite MSTensors of model by node name.
  49. ///
  50. /// \param[in] node_name Define node name.
  51. ///
  52. /// \return The vector of MindSpore Lite MSTensor.
  53. TensorPtrVector GetOutputsByNodeName(const String &node_name) const;
  54. /// \brief Get output MindSpore Lite MSTensors of model mapped by tensor name.
  55. ///
  56. /// \return The map of output tensor name and MindSpore Lite MSTensor.
  57. TensorPtrVector GetOutputs() const;
  58. /// \brief Get name of output tensors of model compiled by this session.
  59. ///
  60. /// \return The vector of string as output tensor names in order.
  61. StringVector GetOutputTensorNames() const;
  62. /// \brief Get output MindSpore Lite MSTensors of model by tensor name.
  63. ///
  64. /// \param[in] tensor_name Define tensor name.
  65. ///
  66. /// \return Pointer of MindSpore Lite MSTensor.
  67. MSTensor *GetOutputByTensorName(const String &tensor_name) const;
  68. /// \note RunGraph should be called after CompileGraph.
  69. int RunGraph();
  70. /// \brief Resize inputs shape.
  71. ///
  72. /// \param[in] inputs Define the new inputs shape.
  73. /// \param[in] dims Define the inputs new shape.
  74. ///
  75. /// \return STATUS as an error code of resize inputs, STATUS is defined in errorcode.h.
  76. int Resize(const TensorPtrVector &inputs, const Int32VectorVector &dims);
  77. } LiteSession;
  78. #endif // MINDSPORE_LITE_INCLUDE_LITE_SESSION_H