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.

inference.h 1.6 kB

5 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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_INCLUDE_MS_SESSION_H
  17. #define MINDSPORE_INCLUDE_MS_SESSION_H
  18. #include <memory>
  19. #include <vector>
  20. #include <string>
  21. #include "include/ms_tensor.h"
  22. namespace mindspore {
  23. class FuncGraph;
  24. namespace inference {
  25. using VectorForMSTensorPtr = std::vector<std::shared_ptr<inference::MSTensor>>;
  26. class MS_API MSSession {
  27. public:
  28. MSSession() = default;
  29. static std::shared_ptr<MSSession> CreateSession(const std::string &device, uint32_t device_id);
  30. virtual uint32_t CompileGraph(std::shared_ptr<FuncGraph> funcGraphPtr) = 0;
  31. virtual MultiTensor RunGraph(uint32_t graph_id, const VectorForMSTensorPtr &inputs) = 0;
  32. virtual bool CheckModelInputs(uint32_t graph_id, const VectorForMSTensorPtr &inputs) const = 0;
  33. };
  34. std::shared_ptr<FuncGraph> MS_API LoadModel(const char *model_buf, size_t size, const std::string &device);
  35. void MS_API ExitInference();
  36. } // namespace inference
  37. } // namespace mindspore
  38. #endif // MINDSPORE_INCLUDE_MS_SESSION_H