#include #include #include // for clock_t, clock(), CLOCKS_PER_SEC #include // for sleep() int main() { printf("Hello from TensorFlow C library version %s\n", TfLiteVersion()); double time_spent = 0.0; clock_t begin = clock(); float output[7] = {0}; TfLiteTensor* input_tensor; //TfLiteModel* model = TfLiteModelCreateFromFile("/home/rajassub/TensorFlow/Scripts/SampleModel/latestmodel.tflite"); TfLiteModel* model = TfLiteModelCreateFromFile("boosted_model.tflite"); clock_t end = clock(); time_spent += (double)(end - begin) / CLOCKS_PER_SEC; printf("The elapsed time is %f seconds\n", time_spent); time_spent = 0.0; begin = clock(); //float input[17] = {0.6872213216106932, 0.686907703969044, 0.3191347291717744, 0.19830822467149978, 1.4929820043134858, -0.8515381261788096, 0.2838287351116457, -0.7315530409633982, 0.2738250413719948, 0.16383145029975532, -0.5556533793434196, 1.2052447149468006, -0.4344623602459357, 0.23250781654771518, -0.20081128500236314, -0.16892116311304395, -0.1592654804565579}; //float input[17] = {0.6872213216106932, 0.686907703969044, -3.747688742665013, -3.767063194474668, 0.9099326834471514, 1.2400939008282752, 0.014147991187736257, -0.7637465772412503, -3.716792099979955, -3.7120364612399537, -0.008502959682545138, 0.7969802464922446, -1.690613539131262, -3.0088229977908507, -0.20097234504731665, -0.16898875971037067, -0.15956835761253133}; //float input[18] = {0.687221, 0.686908, -0.050576, 0.198308, 0.002967, 1.139356, -0.190809, -0.731553, 0.273825, 0.163831, -0.149700, -0.551917, -0.504981, -0.000976, -0.193702, -0.164027, -0.149965, -0.154486}; float input[26] = {0.687221, 0.686908, -0.050576, 0.198308, 0.002967, 1.139356, -0.190809, -0.731553, 0.273825, 0.163831, -0.149700, -0.551917, -0.504981, -0.000976, -0.193702, -0.164027, -0.149965, -0.154486,0,0,0,0,0,0,0,0}; int index = 1; TfLiteInterpreterOptions* options; TfLiteInterpreter* interpreter; const TfLiteTensor* output_tensor; for(index=1; index<=10; index++) { options = TfLiteInterpreterOptionsCreate(); TfLiteInterpreterOptionsSetNumThreads(options, 10); interpreter = TfLiteInterpreterCreate(model, options); TfLiteInterpreterAllocateTensors(interpreter); input_tensor = TfLiteInterpreterGetInputTensor(interpreter, 0); TfLiteTensorCopyFromBuffer(input_tensor, &input, 26 * sizeof(float)); TfLiteInterpreterInvoke(interpreter); output_tensor = TfLiteInterpreterGetOutputTensor(interpreter, 0); TfLiteTensorCopyToBuffer(output_tensor, &output, 7 * sizeof(float)); TfLiteInterpreterDelete(interpreter); TfLiteInterpreterOptionsDelete(options); } TfLiteModelDelete(model); printf("The prediction index 0 is : <%.6f>\n", output[0]); printf("The prediction index 1 is : <%.6f>\n", output[1]); printf("The prediction index 2 is : <%.6f>\n", output[2]); printf("The prediction index 3 is : <%.6f>\n", output[3]); printf("The prediction index 4 is : <%.6f>\n", output[4]); printf("The prediction index 5 is : <%.6f>\n", output[5]); printf("The prediction index 6 is : <%.6f>\n", output[6]); end = clock(); time_spent += (double)(end - begin) / CLOCKS_PER_SEC; time_spent /= 100000; printf("The elapsed time is %f seconds\n", time_spent); return 0; }