Beispiel #1
0
        public void GpuDelegateCreate()
        {
            var glCompileOptions = new TfLiteGlCompileOptions();

            glCompileOptions.precision_loss_allowed   = 0;
            glCompileOptions.preferred_gl_object_type = (Int32)TfLiteGlObjectType.TFLITE_GL_OBJECT_TYPE_FASTEST;
            glCompileOptions.dynamic_batch_enabled    = 0;
            glCompileOptions.inline_parameters        = 1;

            var gpuDelegateOptions = new TfLiteGpuDelegateOptions();

            gpuDelegateOptions.metadata        = IntPtr.Zero;
            gpuDelegateOptions.compile_options = glCompileOptions;

            gpuDelegate = TfLiteGpuDelegateCreate(gpuDelegateOptions);
            if (gpuDelegate == IntPtr.Zero)
            {
                throw new Exception("TensorFlowLite GPU create failed.");
            }
            TfLiteInterpreterOptionsAddDelegate(interpreterOptions, gpuDelegate);
        }
Beispiel #2
0
 private static extern unsafe TfLiteDelegate TfLiteGpuDelegateCreate(TfLiteGpuDelegateOptions delegateOptions);