| 48 | } |
| 49 | |
| 50 | int batch_process(void* model_buf, const void* input_data[], int* input_size, |
| 51 | void* output_data[], int* output_size) { |
| 52 | auto model = static_cast<tensorflow::processor::Model*>(model_buf); |
| 53 | if (input_size == 0) { |
| 54 | auto model_str = model->DebugString(); |
| 55 | *output_data = strndup(model_str.c_str(), model_str.length()); |
| 56 | *output_size = model_str.length(); |
| 57 | return 200; |
| 58 | } |
| 59 | |
| 60 | auto status = model->BatchPredict(input_data, input_size, |
| 61 | output_data, output_size); |
| 62 | if (!status.ok()) { |
| 63 | std::string errmsg = tensorflow::strings::StrCat( |
| 64 | "[TensorFlow] Processor predict failed: ", |
| 65 | status.error_message()); |
| 66 | *output_data = strndup(errmsg.c_str(), strlen(errmsg.c_str())); |
| 67 | *output_size = strlen(errmsg.c_str()); |
| 68 | LOG(ERROR) << errmsg; |
| 69 | return 500; |
| 70 | } |
| 71 | return 200; |
| 72 | } |
| 73 | |
| 74 | // TODO: EAS has a higher priority to call async interface. |
| 75 | // Now we have no implementation of this async interface, |
nothing calls this directly
no test coverage detected