using System; using System.Runtime.InteropServices; namespace LLama.Native; using clip_ctx = IntPtr; public static unsafe partial class NativeApi { /// /// Sanity check for clip <-> llava embed size match /// /// [DllImport(llavaLibraryName, EntryPoint = "llava_validate_embed_size", CallingConvention = CallingConvention.Cdecl)] public static extern bool llava_validate_embed_size( SafeLLamaContextHandle ctxLlama, SafeLlavaModelHandle ctxClip); /// /// Build an image embed from image file bytes /// /// /// /// /// /// [DllImport(llavaLibraryName, EntryPoint = "llava_image_embed_make_with_bytes", CallingConvention = CallingConvention.Cdecl)] public static extern SafeLlavaImageEmbedHandle llava_image_embed_make_with_bytes(SafeLlavaModelHandle ctx_clip, int n_threads, byte[] image_bytes, int image_bytes_length); /// /// Build an image embed from a path to an image filename /// /// /// /// /// [DllImport(llavaLibraryName, EntryPoint = "llava_image_embed_make_with_filename", CallingConvention = CallingConvention.Cdecl)] public static extern SafeLlavaImageEmbedHandle llava_image_embed_make_with_filename(SafeLlavaModelHandle ctx_clip, int n_threads, [MarshalAs(UnmanagedType.LPStr)] string image_path); /// /// Free an embedding made with llava_image_embed_make_* /// /// /// [DllImport(llavaLibraryName, EntryPoint = "llava_image_embed_free", CallingConvention = CallingConvention.Cdecl)] public static extern SafeLlavaImageEmbedHandle llava_image_embed_free(IntPtr embed); /// /// Write the image represented by embed into the llama context with batch size n_batch, starting at context /// pos n_past. on completion, n_past points to the next position in the context after the image embed. /// /// ctx_llama /// [DllImport(llavaLibraryName, EntryPoint = "llava_eval_image_embed", CallingConvention = CallingConvention.Cdecl)] public static extern bool llava_eval_image_embed(SafeLLamaContextHandle ctc_llama, SafeLlavaImageEmbedHandle embed, int n_batch, ref int n_past); }