Skip to content

Commit

Permalink
[test] Add a disabled test for executorch-llama
Browse files Browse the repository at this point in the history
- Add a simple test to show how to use executorch-llama with single api

Signed-off-by: Yongjoo Ahn <[email protected]>
  • Loading branch information
anyj0527 committed Oct 29, 2024
1 parent 7485a33 commit 83c9879
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/capi/unittest_capi_inference_single.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3180,6 +3180,52 @@ TEST (nnstreamer_capi_singleshot, invoke_ncnn)
}
#endif /* ENABLE_NCNN */

/**
* @brief DISABLED Test to show executorch_llama filter usage
*/
TEST (nnstreamer_capi_singleshot, executorch_llama)
{
int status;
ml_single_h single;

status = ml_single_open (&single, "/path/to/pte,/path/to/tokienizer", NULL,
NULL, ML_NNFW_TYPE_EXECUTORCH_LLAMA, ML_NNFW_HW_ANY);
ASSERT_EQ (status, ML_ERROR_NONE);

/* prepare input data */
std::string prompt ("Once upon a time");
ml_tensors_info_h in_info;
ml_tensors_data_h in_data;
ml_tensor_dimension dim = { (unsigned int) prompt.size () + 1, 0 };

ml_tensors_info_create (&in_info);
ml_tensors_info_set_count (in_info, 1);
ml_tensors_info_set_tensor_type (in_info, 0, ML_TENSOR_TYPE_UINT8);
ml_tensors_info_set_tensor_dimension (in_info, 0, dim);

ml_tensors_data_create (in_info, &in_data);
ml_tensors_data_set_tensor_data (in_data, 0, prompt.c_str (), prompt.size () + 1);

/* invoke */
ml_tensors_data_h out_data;
status = ml_single_invoke (single, in_data, &out_data);
EXPECT_EQ (ML_ERROR_NONE, status);

char *result;
size_t result_size;
status = ml_tensors_data_get_tensor_data (out_data, 0U, (void **) &result, &result_size);
EXPECT_EQ (ML_ERROR_NONE, status);

g_info ("result: %s", result);
EXPECT_EQ (0, strncmp (result, prompt.c_str (), prompt.size ()));

/* free data */
ml_tensors_data_destroy (out_data);
ml_tensors_data_destroy (in_data);
ml_tensors_info_destroy (in_info);
ml_single_close (single);
}

/**
* @brief Test NNStreamer single shot (custom filter)
* @detail Run pipeline with custom filter with allocate in invoke, handle multi tensors.
Expand Down

0 comments on commit 83c9879

Please sign in to comment.