public void Dispose()
        {
            if (interpreter != IntPtr.Zero)
            {
                TfLiteInterpreterDelete(interpreter);
                interpreter = IntPtr.Zero;
            }

            if (model != IntPtr.Zero)
            {
                TfLiteModelDelete(model);
                model = IntPtr.Zero;
            }

            options?.Dispose();

            foreach (var handle in inputDataHandles.Values)
            {
                handle.Free();
            }
            foreach (var handle in outputDataHandles.Values)
            {
                handle.Free();
            }
            modelDataHandle.Free();
        }
Example #2
0
        public void Dispose()
        {
            if (interpreter != IntPtr.Zero)
            {
                TfLiteInterpreterDelete(interpreter);
            }
            interpreter = IntPtr.Zero;

            if (model != IntPtr.Zero)
            {
                TfLiteModelDelete(model);
            }
            model = IntPtr.Zero;

            if (options != null)
            {
                options.Dispose();
            }
        }