#include "parvulus_c_api.h" #include "parvulus_engine.h" #include extern "C" { ParvulusHandle parvulus_create(int device_id) { return new ParvulusEngine(device_id); } bool parvulus_load( ParvulusHandle handle, const char* weights_path, const char* embeddings_path, const char* scale_path ) { if (!handle) return false; ParvulusEngine* engine = static_cast(handle); bool ok = engine->load_weights(weights_path); if (embeddings_path != nullptr && std::strlen(embeddings_path) > 0) { ok = ok && engine->load_task_embeddings(embeddings_path); } if (scale_path != nullptr && std::strlen(scale_path) > 0) { ok = ok && engine->load_action_scale(scale_path); } return ok; } bool parvulus_set_task_vector(ParvulusHandle handle, const float* task_vector) { if (!handle || !task_vector) return false; ParvulusEngine* engine = static_cast(handle); return engine->set_task_vector(task_vector); } bool parvulus_set_task_string(ParvulusHandle handle, const char* task_description) { if (!handle || !task_description) return false; ParvulusEngine* engine = static_cast(handle); return engine->set_task_string(task_description); } bool parvulus_predict_chunk( ParvulusHandle handle, const uint8_t* agent_img, const uint8_t* wrist_img, const char* task_description, float* out_actions, int num_euler_steps, const float* custom_z0 ) { if (!handle) return false; ParvulusEngine* engine = static_cast(handle); if (task_description != nullptr && std::strlen(task_description) > 0) { return engine->predict_action_chunk(agent_img, wrist_img, task_description, out_actions, num_euler_steps, custom_z0); } else { return engine->predict_action_chunk(agent_img, wrist_img, out_actions, num_euler_steps, custom_z0); } } bool parvulus_predict_chunk_with_vector( ParvulusHandle handle, const uint8_t* agent_img, const uint8_t* wrist_img, const float* task_vector, float* out_actions, int num_euler_steps, const float* custom_z0 ) { if (!handle) return false; ParvulusEngine* engine = static_cast(handle); return engine->predict_action_chunk_with_vector(agent_img, wrist_img, task_vector, out_actions, num_euler_steps, custom_z0); } bool parvulus_predict_chunk_with_emb( ParvulusHandle handle, const uint8_t* agent_img, const uint8_t* wrist_img, const float* text_embedding, float* out_actions, int num_euler_steps, const float* custom_z0 ) { return parvulus_predict_chunk_with_vector(handle, agent_img, wrist_img, text_embedding, out_actions, num_euler_steps, custom_z0); } bool parvulus_register_task_embedding( ParvulusHandle handle, const char* task_description, const float* text_embedding ) { if (!handle || !task_description || !text_embedding) return false; ParvulusEngine* engine = static_cast(handle); return engine->register_task_embedding(task_description, text_embedding); } void parvulus_destroy(ParvulusHandle handle) { if (handle) { delete static_cast(handle); } } }