MetalDelagate.mm 795 B

123456789101112131415161718192021222324
  1. #import "MetalDelagate.h"
  2. #import "plat_delegate.h"
  3. #import <metal_delegate.h>
  4. @implementation MetalDelagate
  5. void* create_delegate() {
  6. TFLGpuDelegateOptions delegateOpts = {
  7. .allow_precision_loss = true,
  8. .wait_type = TFLGpuDelegateWaitType::TFLGpuDelegateWaitTypeActive,
  9. // .wait_type = TFLGpuDelegateWaitType::TFLGpuDelegateWaitTypePassive,
  10. // .wait_type = TFLGpuDelegateWaitType::TFLGpuDelegateWaitTypeDoNotWait,
  11. // .wait_type = TFLGpuDelegateWaitType::TFLGpuDelegateWaitTypeAggressive,
  12. .enable_quantization = true,
  13. };
  14. auto *TFLGpuDelegate = TFLGpuDelegateCreate(&delegateOpts);
  15. return TFLGpuDelegate;
  16. }
  17. void delete_delegate(void *delegate) {
  18. TFLGpuDelegateDelete((TfLiteDelegate *)delegate);
  19. }
  20. @end