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.

context.h 1.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright 2019 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 PREDICT_INCLUDE_CONTEXT_H_
  17. #define PREDICT_INCLUDE_CONTEXT_H_
  18. #include <memory>
  19. #include "dlpack/dlpack.h"
  20. #include "include/tensor.h"
  21. #define MSPREDICT_API __attribute__((visibility("default")))
  22. namespace mindspore {
  23. namespace predict {
  24. ///\brief Resource management definition of MindSpore predict.
  25. class MSPREDICT_API Context {
  26. public:
  27. ///\brief Constructor of MindSpore predict context using default value for parameters.
  28. ///
  29. ///\return Instance of MindSpore predict context.
  30. Context();
  31. ///\brief Custum constructor of MindSpore predict context using input value for parameters.
  32. ///
  33. ///\param[in] threadNum The number of thread during the runtime.
  34. ///\param[in] allocator The memory management during the runtime
  35. ///\param[in] deviceCtx The device information during the runtime.
  36. ///
  37. ///\return Instance of MindSpore predict context.
  38. Context(int threadNum, std::shared_ptr<Allocator> allocator, DLContext deviceCtx);
  39. ///\brief Destructor of MindSpore predict context.
  40. virtual ~Context();
  41. public:
  42. DLContext deviceCtx;
  43. int threadNum = 1;
  44. std::shared_ptr<Allocator> allocator;
  45. };
  46. } // namespace predict
  47. } // namespace mindspore
  48. #endif // PREDICT_INCLUDE_CONTEXT_H_