void AI_Init(ai_handle w_addr, ai_handle act_addr) { ai_error err; //ai_handle cnn = AI_HANDLE_NULL; /* Create a local array with the addresses of the activations buffers */ //const ai_handle act_addr[] = { activations }; /* Create an instance of the model */ err = ai_cnn_create(&cnn, AI_CNN_DATA_CONFIG); if (err.type != AI_ERROR_NONE) { printf("ai_cnn_create error - type=%d code=%d\r\n", err.type, err.code); return -1; } else{ printf("Network created!\r\n");} ai_network_params params = { AI_CNN_DATA_WEIGHTS(w_addr), AI_CNN_DATA_ACTIVATIONS(act_addr) }; if (!ai_cnn_init(cnn, ¶ms)) { err = ai_cnn_get_error(cnn); printf("ai_cnn_init error - type=%d code=%d\r\n", err.type, err.code); return -1; } else{ printf("Network Initialized!\r\n"); } // Verify the weights and activations ai_u64* weights_ptr = (ai_u64*)w_addr; ai_u8* activations_ptr = (ai_u8*)act_addr; // Print the first few values of weights for verification //printf("First few weight values:\r\n"); for (int i = 0; i < 10; ++i) { // Adjust the number of printed values as needed //printf("weights[%d] = 0x%lx\r\n", i, weights_ptr[i]); //printf("w_addr weights[%d] = 0x%lx\r\n", i,weights_ptr[i]>>32); //printf("w_addr weights[%d] = 0x%lx\r\n", i,weights_ptr[i]); } //print_weights_from_params(¶ms); //if () // Print the first few values of activations for verification //printf("First few activation values:\r\n"); //for (int i = 0; i < 30; ++i) { // Adjust the number of printed values as needed //printf("activations[%d] = %d\r\n", i, activations_ptr[i]); //} //ai_input = ai_network_inputs_get(network, NULL); //ai_output = ai_network_outputs_get(network, NULL); } void AI_Run (ai_float *pIN, ai_float *pOut) { ai_i32 batch; ai_error err; //ai_buffer ai_input[AI_CNN_IN_NUM] = AI_CNN_IN; //ai_buffer ai_output[AI_CNN_OUT_NUM] = AI_CNN_OUT; // Ensure the model handle is initialized if (cnn == AI_HANDLE_NULL) { printf("AI model handle is null. Not properly initialized\r\n"); return -1; } else{printf("AI model handle is not null. Properly initialized.\r\n");} ai_buffer* ai_input = ai_cnn_inputs_get(cnn, NULL); ai_buffer* ai_output = ai_cnn_outputs_get(cnn, NULL); // Initialize ai_buffer structures for input and output //ai_buffer ai_input[AI_CNN_IN_NUM]; //ai_buffer ai_output[AI_CNN_OUT_NUM]; // Get input and output buffer if (!ai_input || !ai_output) { printf("Failed to get input/output buffers.\r\n"); return -1; } else{printf("Successfully got input/output buffers.\r\n");} //ai_input[0].n_batches = 1; ai_input[0].data = AI_HANDLE_PTR(pIN); ai_output[0].data = AI_HANDLE_PTR(pOut); // Verify that ai_input has received the data ai_float* input_data_ptr = (ai_float*)ai_input[0].data; printf("First few input values:\r\n"); for (int i = 0; i < 10; ++i) { // Print the first 10 values for verification printf("input_data[%d] = %.9f\r\n", i, input_data_ptr[i]); } uint32_t start_time = HAL_GetTick(); batch = ai_cnn_run(cnn, ai_input, ai_output); uint32_t end_time = HAL_GetTick(); if(batch != 1) { err = ai_cnn_get_error(cnn); printf("ai_cnn_run error - type=%d code=%d\r\n", err.type, err.code); return -1; } else { printf("The model inferences successfully as the batch return value is: %lu \r\n", (unsigned long)batch); uint32_t inference_time = end_time - start_time; //printf("Output: %.9f\r\n", ai_output[0]); printf("Output: %.9f\r\n", ai_output[1]); printf("Inference time: %lu ms\r\n", (unsigned long)inference_time); } Part of Main code /* USER CODE BEGIN 2 */ AI_ALIGNED(4) ai_u8 activations[AI_CNN_DATA_ACTIVATIONS_SIZE]; AI_ALIGNED(4) ai_float output[AI_CNN_OUT_1_SIZE]; // Output: 1 float value // Print the weights directly from the weights table //print_weights_directly(); // Initialize the input data array for (int i = 0; i < ROWS; i++) { for (int j = 0; j < COLUMNS; j++) { input_data_3d[0][i][j] = input_data[i][j]; } } ai_handle weights_data = ai_cnn_data_weights_get(); if (!weights_data) { printf("Error: Failed to get weights data.\n"); return -1; } else{printf("Got weights data.\r\n");} // Verify the weights data directly after obtaining them ai_u64* weights_ptr_data = (ai_u64*)weights_data; //printf("First few weight values directly from ai_cnn_data_weights_get() (hex):\r\n"); for (int i = 0; i < 10; ++i) { //printf("weights[%d] = 0x%016llx\r\n", i, weights_ptr[i]); //printf("weights[%d] = 0x%lx\r\n", i,weights_ptr_data[i]>>32); //printf("weights[%d] = 0x%lx\r\n", i,weights_ptr_data[i]); } AI_Init(weights_data, activations); while (1) { /* USER CODE END WHILE */ //MX_X_CUBE_AI_Process(); /* USER CODE BEGIN 3 */ printf("Running inference \r\n"); AI_Run((ai_float*) input_data_3d, output); break; } /* USER CODE END 3 */ It runs on the board without any error but doesnot give output other than 0. What is the problem my input is in the given form and its output should be close to 1. AI_ALIGNED(4) ai_float input_data[ROWS][COLUMNS] = {{-0.036259543f, 0.040229887f, -0.003202005f, 0.176684886f, -0.062742062f, -0.392500013f, 0.557492912f, 0.554216862f, 0.210526317f, 0.038819026f, -0.669999242f, 0.557351649f}, {-0.059432935f, 0.016967706f, 0.036057357f, 0.114754096f, -0.095274977f, -0.414999992f, 0.557931364f, 0.554216862f, 0.210526317f, 0.063422635f, -0.439999759f, 0.557777524f}, {-0.028625954f, -0.033935413f, 0.056661561f, 0.114754096f, -0.095274977f, -0.437500000f, 0.558431208f, 0.554216862f, 0.210526317f, 0.063149258f, -0.166665882f, 0.558295965f}, {0.009814613f, -0.054187194f, 0.047194764f, 0.194899812f, -0.062742062f, -0.414999992f, 0.558863342f, 0.554216862f, 0.210526317f, 0.061509021f, 0.063333616f, 0.558721781f}, {0.053162485f, -0.060481664f, 0.015731588f, 0.194899812f, -0.062742062f, -0.392500013f, 0.559301615f, 0.554740608f, 0.214912280f, 0.066429742f, 0.306668073f, 0.559160054f}, {0.085605234f, -0.038587850f, -0.044131979f, 0.300546438f, -0.062742062f, -0.437500000f, 0.559783101f, 0.554740608f, 0.214912280f, 0.086112633f, 0.566666961f, 0.559641540f}, {0.046892039f, 0.032567050f, -0.083669774f, 0.136612028f, -0.062742062f, -0.437500000f, 0.560270607f, 0.554740608f, 0.210526317f, 0.083378896f, 0.830000222f, 0.560129046f}, {-0.013086150f, 0.079091407f, -0.071140192f, 0.114754096f, -0.095274977f, -0.392500013f, 0.560684264f, 0.554740608f, 0.210526317f, 0.083925642f, -0.946666837f, 0.560542583f}, {-0.070338055f, 0.090038314f, -0.018794376f, 0.158469945f, -0.062742062f, -0.414999992f, 0.561122656f, 0.554740608f, 0.208333328f, 0.095954075f, -0.709998667f, 0.560980856f}, {-0.118320614f, 0.054187194f, 0.066128358f, 0.194899812f, -0.095274977f, -0.414999992f, 0.561591804f, 0.554740608f, 0.208333328f, 0.110989615f, -0.463332266f, 0.561437607f}, {-0.084242091f, -0.046524357f, 0.131003752f, 0.136612028f, -0.062742062f, -0.414999992f, 0.562054515f, 0.555264473f, 0.208333328f, 0.131492615f, -0.213333994f, 0.561900318f}, {0.014449291f, -0.117952928f, 0.110399552f, 0.216757745f, -0.062742062f, -0.437500000f, 0.562548459f, 0.555264473f, 0.206140354f, 0.130672500f, 0.053333610f, 0.562394202f}, {0.102780804f, -0.133278593f, 0.028261172f, 0.136612028f, -0.095274977f, -0.414999992f, 0.562949598f, 0.555264473f, 0.208333328f, 0.140787318f, 0.276666850f, 0.562807739f}, {0.164667398f, -0.088396281f, -0.075873591f, 0.158469945f, -0.095274977f, -0.414999992f, 0.563381612f, 0.555264473f, 0.206140354f, 0.156642973f, 0.503334403f, 0.563227296f}, {0.121319517f, 0.035577450f, -0.161074758f, 0.278688520f, -0.095274977f, -0.437500000f, 0.563838601f, 0.555264473f, 0.206140354f, 0.168124661f, 0.750000775f, 0.563696384f}, {0.011450382f, 0.150519982f, -0.154670745f, 0.216757745f, -0.095274977f, -0.392500013f, 0.564258277f, 0.555264473f, 0.206140354f, 0.177145988f, 0.983334661f, 0.564116299f}, {-0.119683750f, 0.192391902f, -0.075873591f, 0.136612028f, -0.095274977f, -0.437500000f, 0.564721048f, 0.555264473f, 0.201754391f, 0.187807545f, -0.773333609f, 0.564579010f}, {-0.197110146f, 0.120963328f, 0.074202977f, 0.136612028f, -0.095274977f, -0.414999992f, 0.565153182f, 0.555788398f, 0.201754391f, 0.199835971f, -0.539999783f, 0.564998746f}, {-0.190839693f, -0.012315270f, 0.198941946f, 0.034608379f, -0.127807900f, -0.437500000f, 0.565591455f, 0.555788398f, 0.201754391f, 0.217331871f, -0.303334028f, 0.565436900f}, {-0.057797164f, -0.170771763f, 0.214812756f, 0.136612028f, -0.095274977f, -0.437500000f, 0.566042185f, 0.555788398f, 0.201754391f, 0.223072723f, -0.053333309f, 0.565899968f}, {0.118047982f, -0.228243023f, 0.116803564f, 0.238615662f, -0.095274977f, -0.414999992f, 0.566498816f, 0.555788398f, 0.199561402f, 0.225259706f, 0.186666802f, 0.566344321f}, {0.252726287f, -0.200054735f, -0.048865378f, 0.238615662f, -0.095274977f, -0.414999992f, 0.566906333f, 0.555788398f, 0.199561402f, 0.264625490f, 0.406668127f, 0.566751659f}, {0.251090527f, -0.030925013f, -0.210079357f, 0.340619296f, -0.127807900f, -0.414999992f, 0.567332149f, 0.555788398f, 0.199561402f, 0.262165129f, 0.636667609f, 0.567177415f}, {0.115049072f, 0.159824848f, -0.273284137f, 0.256830603f, -0.095274977f, -0.414999992f, 0.567764342f, 0.555788398f, 0.199561402f, 0.272279948f, 0.870001435f, 0.567621768f}, {-0.091875680f, 0.274767369f, -0.181678966f, 0.176684886f, -0.127807900f, -0.414999992f, 0.568220973f, 0.555788398f, 0.199561402f, 0.278020769f, -0.869999349f, 0.568090856f}, {-0.258996725f, 0.274767369f, -0.020464987f, 0.158469945f, -0.127807900f, -0.437500000f, 0.568616033f, 0.555788398f, 0.197368428f, 0.309185356f, -0.669999242f, 0.568473577f}, {-0.313249737f, 0.096059114f, 0.217875540f, 0.136612028f, -0.127807900f, -0.414999992f, 0.569066763f, 0.556312144f, 0.197368428f, 0.318480045f, -0.423332870f, 0.568917930f}, {-0.211014181f, -0.111658454f, 0.322010309f, -0.009107468f, -0.127807900f, -0.414999992f, 0.569468021f, 0.556312144f, 0.197368428f, 0.323400766f, -0.210000247f, 0.569313049f}, {0.002181025f, -0.324302137f, 0.326743692f, 0.158469945f, -0.160340816f, -0.414999992f, 0.569887578f, 0.556312144f, 0.192982450f, 0.369054139f, 0.023333596f, 0.569745004f}, {0.257360965f, -0.350848377f, 0.096199356f, 0.194899812f, -0.160340816f, -0.437500000f, 0.570338309f, 0.556312144f, 0.192982450f, 0.363586664f, 0.260001779f, 0.570183337f}, {0.374863684f, -0.229611382f, -0.135737151f, 0.340619296f, -0.127807900f, -0.437500000f, 0.570727110f, 0.556312144f, 0.192982450f, 0.371241122f, 0.473334402f, 0.570578158f}, {0.330152661f, 0.035577450f, -0.360155910f, 0.442622960f, -0.160340816f, -0.437500000f, 0.571153045f, 0.556312144f, 0.190789476f, 0.400765449f, 0.703333914f, 0.571004093f}, {0.105779715f, 0.304324031f, -0.401085883f, 0.380692154f, -0.192873746f, -0.437500000f, 0.571585119f, 0.556312144f, 0.190789476f, 0.416074365f, 0.933333397f, 0.571442366f}, {-0.173936754f, 0.425287366f, -0.252679944f, 0.194899812f, -0.160340816f, -0.437500000f, 0.571980119f, 0.556312144f, 0.188596487f, 0.424822301f, -0.853332460f, 0.571824968f}, {-0.392039269f, 0.366447717f, 0.018794376f, -0.027322404f, -0.160340816f, -0.414999992f, 0.572381258f, 0.556312144f, 0.188596487f, 0.427829415f, -0.636667907f, 0.572226167f}, {-0.429116696f, 0.090038314f, 0.331477106f, -0.027322404f, -0.160340816f, -0.414999992f, 0.572831869f, 0.556312144f, 0.190789476f, 0.445598692f, -0.386667192f, 0.572689056f}, {-0.296074152f, -0.181444988f, 0.462620080f, -0.234972671f, -0.192873746f, -0.437500000f, 0.573189974f, 0.556836009f, 0.188596487f, 0.467195183f, -0.196667716f, 0.573040903f}, {0.019083969f, -0.428571433f, 0.407489896f, 0.052823316f, -0.160340816f, -0.437500000f, 0.573615909f, 0.556312144f, 0.184210524f, 0.483870953f, 0.029999861f, 0.573460579f}, {0.356324971f, -0.471811712f, 0.121536963f, 0.300546438f, -0.192873746f, -0.460000008f, 0.574047923f, 0.556312144f, 0.184210524f, 0.489065051f, 0.269999981f, 0.573904932f}, {0.494002193f, -0.313628912f, -0.170541555f, 0.362477243f, -0.192873746f, -0.460000008f, 0.574405968f, 0.556836009f, 0.184210524f, 0.500546753f, 0.463333786f, 0.574262977f}, {0.433751374f, 0.015325670f, -0.440623701f, 0.486338794f, -0.192873746f, -0.437500000f, 0.574825525f, 0.556836009f, 0.184210524f, 0.501366854f, 0.683332682f, 0.574670136f}, {0.175299898f, 0.325944185f, -0.496032298f, 0.486338794f, -0.226955846f, -0.437500000f, 0.575214505f, 0.556836009f, 0.182017550f, 0.498906493f, 0.896666527f, 0.575065315f}, {-0.158396944f, 0.501368344f, -0.341222316f, 0.256830603f, -0.192873746f, -0.460000008f, 0.575622022f, 0.556836009f, 0.179824561f, 0.506014228f, -0.879998744f, 0.575478852f}, {-0.413576871f, 0.453201979f, -0.047194764f, 0.052823316f, -0.192873746f, -0.460000008f, 0.575992465f, 0.556836009f, 0.179824561f, 0.498086393f, -0.679998398f, 0.575849235f}, {-0.504907310f, 0.242200330f, 0.262146741f, -0.009107468f, -0.160340816f, -0.437500000f, 0.576356471f, 0.556836009f, 0.179824561f, 0.502460361f, -0.483332664f, 0.576213241f}, {-0.405943304f, -0.074438974f, 0.469024092f, -0.049180329f, -0.192873746f, -0.437500000f, 0.576745272f, 0.556836009f, 0.173245609f, 0.504100621f, -0.279999435f, 0.576589704f}, {-0.133587793f, -0.369458139f, 0.489628285f, -0.132969037f, -0.192873746f, -0.460000008f, 0.577128172f, 0.556836009f, 0.173245609f, 0.506834328f, -0.073331878f, 0.576984823f}, {0.195474371f, -0.504652441f, 0.304747313f, 0.136612028f, -0.192873746f, -0.437500000f, 0.577535510f, 0.556836009f, 0.171052635f, 0.506014228f, 0.146668226f, 0.577379763f}, {0.430752456f, -0.450191557f, 0.028261172f, 0.300546438f, -0.192873746f, -0.460000008f, 0.577856481f, 0.557359755f, 0.168859646f, 0.504373968f, 0.323334038f, 0.577706873f}, {0.504907310f, -0.231253415f, -0.265209526f, 0.340619296f, -0.192873746f, -0.437500000f, 0.578233004f, 0.557359755f, 0.168859646f, 0.498906493f, 0.523334146f, 0.578077257f} }; AI_ALIGNED(4) ai_float input_data_3d[BATCH_SIZE][ROWS][COLUMNS];