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 2.1 kB

5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 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_CONTEXT_H_
  17. #define MINDSPORE_LITE_INCLUDE_CONTEXT_H_
  18. #include <string>
  19. #include <memory>
  20. #include "include/ms_tensor.h"
  21. #include "include/lite_utils.h"
  22. #include "include/lite_types.h"
  23. namespace mindspore::lite {
  24. /// \brief CpuDeviceInfo defined for CPU's configuration information.
  25. typedef struct {
  26. bool enable_float16_ = false; /**< prior enable float16 inference */
  27. CpuBindMode cpu_bind_mode_ = MID_CPU;
  28. } CpuDeviceInfo;
  29. /// \brief GpuDeviceInfo defined for GPU's configuration information.
  30. typedef struct {
  31. bool enable_float16_ = false; /**< prior enable float16 inference */
  32. } GpuDeviceInfo;
  33. /// \brief NpuDeviceInfo defined for NPU's configuration information.
  34. typedef struct {
  35. int frequency_ = 3; /**< npu frequency inference */
  36. } NpuDeviceInfo;
  37. /// \brief DeviceInfo defined for backend's configuration information.
  38. union DeviceInfo {
  39. CpuDeviceInfo cpu_device_info_;
  40. GpuDeviceInfo gpu_device_info_;
  41. NpuDeviceInfo npu_device_info_;
  42. };
  43. /// \brief DeviceContext defined for holding backend's configuration information.
  44. struct DeviceContext {
  45. DeviceType device_type_ = DT_CPU;
  46. DeviceInfo device_info_;
  47. };
  48. /// \brief Context defined for holding environment variables during runtime.
  49. struct Context {
  50. std::string vendor_name_;
  51. int thread_num_ = 2; /**< thread number config for thread pool */
  52. AllocatorPtr allocator = nullptr;
  53. DeviceContextVector device_list_ = {{DT_CPU, {false, MID_CPU}}};
  54. };
  55. } // namespace mindspore::lite
  56. #endif // MINDSPORE_LITE_INCLUDE_CONTEXT_H_