| 947 | } |
| 948 | |
| 949 | static bool |
| 950 | ml_inference_validation(struct ml_test *test, struct ml_request *req) |
| 951 | { |
| 952 | struct test_inference *t = ml_test_priv((struct ml_test *)test); |
| 953 | struct ml_model *model; |
| 954 | float *reference; |
| 955 | float *output; |
| 956 | float deviation; |
| 957 | bool match; |
| 958 | uint32_t i; |
| 959 | uint32_t j; |
| 960 | |
| 961 | model = &t->model[req->fid]; |
| 962 | |
| 963 | /* compare crc when tolerance is 0 */ |
| 964 | if (t->cmn.opt->tolerance == 0.0) { |
| 965 | match = (rte_hash_crc(model->output, model->out_dsize, 0) == |
| 966 | rte_hash_crc(model->reference, model->out_dsize, 0)); |
| 967 | } else { |
| 968 | output = (float *)model->output; |
| 969 | reference = (float *)model->reference; |
| 970 | |
| 971 | i = 0; |
| 972 | next_output: |
| 973 | j = 0; |
| 974 | next_element: |
| 975 | match = false; |
| 976 | if ((*reference == 0) && (*output == 0)) |
| 977 | deviation = 0; |
| 978 | else |
| 979 | deviation = 100 * fabs(*output - *reference) / fabs(*reference); |
| 980 | if (deviation <= t->cmn.opt->tolerance) |
| 981 | match = true; |
| 982 | else |
| 983 | ml_err("id = %d, element = %d, output = %f, reference = %f, deviation = %f %%\n", |
| 984 | i, j, *output, *reference, deviation); |
| 985 | |
| 986 | output++; |
| 987 | reference++; |
| 988 | |
| 989 | if (!match) |
| 990 | goto done; |
| 991 | |
| 992 | j++; |
| 993 | if (j < model->info.output_info[i].nb_elements) |
| 994 | goto next_element; |
| 995 | |
| 996 | i++; |
| 997 | if (i < model->info.nb_outputs) |
| 998 | goto next_output; |
| 999 | } |
| 1000 | done: |
| 1001 | return match; |
| 1002 | } |
| 1003 | |
| 1004 | /* Callback for mempool object iteration. This call would dequantize output data. */ |
| 1005 | static void |
no test coverage detected