Skip to content

Commit 197e923

Browse files
tianbohweimingzha0
authored andcommitted
ODLA: Synchronize vODLA.cpp odla_LoadExecutable with aone master.
1 parent 4c1c7c8 commit 197e923

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

ODLA/platforms/vodla/vODLA.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -1164,4 +1164,41 @@ odla_status odla_ExecuteComputation(odla_computation comp, odla_context context,
11641164
return ret;
11651165
}
11661166

1167+
odla_status ODLA_API_CALL odla_LoadExecutable(odla_resource_location location,
1168+
odla_device device,
1169+
odla_executable* executable) {
1170+
// init vODLA device failed
1171+
if (location.location_type != ODLA_LOCATION_PATH) {
1172+
std::cout << "[vODLA] ERROR: unsupported location type.\n";
1173+
return ODLA_FAILURE;
1174+
}
1175+
const char* file_name = static_cast<const char*>(location.location);
1176+
if (file_name == NULL) {
1177+
std::cout << "[vODLA] ERROR: Cache file name is NULL.\n";
1178+
return ODLA_FAILURE;
1179+
}
1180+
if (device == NULL) {
1181+
std::cout << "[vODLA] ERROR: odla device is NULL.\n";
1182+
return ODLA_FAILURE;
1183+
}
1184+
if (device->vodh_dev_list == NULL) {
1185+
std::cout
1186+
<< "[vODLA] ERROR: allocation of device failed, skip loading cache.\n";
1187+
return ODLA_FAILURE;
1188+
}
1189+
1190+
struct vodh_model_options moptions;
1191+
struct vodh_model_op_result mresult;
1192+
moptions.opcode = TYPE_LOAD;
1193+
strcpy(moptions.modelname, file_name);
1194+
vodh_ret ret = vodh_model(device->vodh_hd, &(device->vodh_dev_list[0]),
1195+
&moptions, &mresult);
1196+
if (ret) {
1197+
std::cout << "[vODLA] ERROR: load model cache failed, ret=" << ret << "\n";
1198+
return ODLA_FAILURE;
1199+
}
1200+
1201+
return ODLA_SUCCESS;
1202+
}
1203+
11671204
} // extern "C"

0 commit comments

Comments
 (0)