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.

acl_session.h 2.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_SERVING_ACL_SESSION_H
  17. #define MINDSPORE_SERVING_ACL_SESSION_H
  18. #include <vector>
  19. #include <string>
  20. #include <unordered_map>
  21. #include <utility>
  22. #include <memory>
  23. #include <map>
  24. #include "include/inference.h"
  25. #include "serving/acl/model_process.h"
  26. #include "serving/acl/dvpp_process.h"
  27. namespace mindspore {
  28. namespace inference {
  29. class AclSession : public InferSession {
  30. public:
  31. AclSession();
  32. Status InitEnv(const std::string &device_type, uint32_t device_id) override;
  33. Status FinalizeEnv() override;
  34. Status LoadModelFromFile(const std::string &file_name, uint32_t &model_id) override;
  35. Status UnloadModel(uint32_t model_id) override;
  36. Status ExecuteModel(uint32_t model_id, const RequestBase &request, ReplyBase &reply) override;
  37. Status ExecuteModel(uint32_t model_id, const ImagesRequestBase &images_inputs, // images for preprocess
  38. const RequestBase &request, ReplyBase &reply) override;
  39. private:
  40. std::string device_type_;
  41. int32_t device_id_;
  42. aclrtStream stream_ = nullptr;
  43. aclrtContext context_ = nullptr;
  44. ModelProcess model_process_;
  45. bool execute_with_dvpp_ = false;
  46. DvppProcess dvpp_process_;
  47. Status PreProcess(uint32_t model_id, const InferImagesBase *images_input, ImagesDvppOutput &dvpp_output);
  48. };
  49. } // namespace inference
  50. } // namespace mindspore
  51. #endif // MINDSPORE_SERVING_ACL_SESSION_H