Download c_engine/parvulus_c_api.cpp from aasivas/Parvulus: direct link, hf CLI and curl.
- Browser
- Download file 3.26 kB
-
https://huggingface.co/aasivas/Parvulus/resolve/main/c_engine/parvulus_c_api.cpp
- Command line
-
hf download hf://aasivas/Parvulus/c_engine/parvulus_c_api.cpp
-
curl -L -o parvulus_c_api.cpp https://huggingface.co/aasivas/Parvulus/resolve/main/c_engine/parvulus_c_api.cpp
3.26 kB
| 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<ParvulusEngine*>(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<ParvulusEngine*>(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<ParvulusEngine*>(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<ParvulusEngine*>(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<ParvulusEngine*>(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<ParvulusEngine*>(handle); | |
| return engine->register_task_embedding(task_description, text_embedding); | |
| } | |
| void parvulus_destroy(ParvulusHandle handle) { | |
| if (handle) { | |
| delete static_cast<ParvulusEngine*>(handle); | |
| } | |
| } | |
| } | |