|
- #include <stdio.h>
- #include "rknn_api.h"
- #include <pthread.h>
- #include <fstream>
- int main()
- {
- rknn_context ctx = 0;
- const char *model_path = "/home/toybrick/rknn_api/mobilenet_ssd.rknn";
- FILE *fp = fopen(model_path, "rb");
- if(fp == NULL) {
- printf("fopen %s fail!\n", model_path);
- return -1;
- }
- fseek(fp, 0, SEEK_END);
- int model_len = ftell(fp);
- void *model = malloc(model_len);
- fseek(fp, 0, SEEK_SET);
- if(model_len != fread(model, 1, model_len, fp)) {
- printf("fread %s fail!\n", model_path);
- free(model);
- return -1;
- }
- rknn_init(&ctx, model, model_len, RKNN_FLAG_PRIOR_MEDIUM);
- rknn_sdk_version version;
- rknn_query(ctx, RKNN_QUERY_SDK_VERSION, &version, sizeof(rknn_sdk_version));
- printf("api version: %s\n", version.api_version);
- printf("driver version: %s\n", version.drv_version);
- rknn_devices_id devids;
- rknn_find_devices(&devids);
- printf("n_devices = %d\n", devids.n_devices);
- for (int i = 0; i < devids.n_devices; i++)
- {
- printf("%d: type=%s, id=%s\n", i, devids.types[i], devids.ids[i]);
- }
- return 0;
- }
输出:
E RKNNAPI: rknn_init, driver open fail! ret = -9(ERROR_PIPE)!
E RKNNAPI: rknn_query, context = nullptr!
api version:
driver version: �m��
E RKNNAPI: rknn_find_devices fail!
n_devices = 0
|
|