@@ -37,7 +37,7 @@ void classify_images(JNIEnv* env, jintArray inputTensor) {
3737
3838
3939 // Add the input operand
40- const uint32_t inputDimensions[] = {1 , NUM_CHANNELS , IMAGE_SIZE, IMAGE_SIZE };
40+ const uint32_t inputDimensions[] = {1 , IMAGE_SIZE , IMAGE_SIZE, NUM_CHANNELS };
4141 ANeuralNetworksOperandType inputType = {
4242 .type = ANEURALNETWORKS_TENSOR_FLOAT32,
4343 .dimensionCount = 4 ,
@@ -136,8 +136,7 @@ void classify_images(JNIEnv* env, jintArray inputTensor) {
136136 status = ANeuralNetworksModel_setOperandValue (model, activationIndex, &activation, sizeof (activation));
137137
138138
139- const uint32_t convOutputDimensions[] = {1 , IMAGE_SIZE, IMAGE_SIZE, CONV_FILTERS};
140- // const uint32_t convOutputDimensions[] = {1, IMAGE_SIZE - CONV_KERNEL_SIZE + 1, IMAGE_SIZE - CONV_KERNEL_SIZE + 1, CONV_FILTERS};
139+ const uint32_t convOutputDimensions[] = {1 , IMAGE_SIZE - CONV_KERNEL_SIZE + 1 , IMAGE_SIZE - CONV_KERNEL_SIZE + 1 , CONV_FILTERS};
141140 ANeuralNetworksOperandType convOutputType = {
142141 .type = ANEURALNETWORKS_TENSOR_FLOAT32,
143142 .dimensionCount = 4 ,
@@ -205,8 +204,7 @@ void classify_images(JNIEnv* env, jintArray inputTensor) {
205204
206205
207206 // Add the max pooling layer operand
208- const uint32_t poolOutputDimensions[] = {1 , IMAGE_SIZE / POOL_SIZE, IMAGE_SIZE / POOL_SIZE, CONV_FILTERS};
209- // const uint32_t poolOutputDimensions[] = {1, (IMAGE_SIZE - CONV_KERNEL_SIZE + 1) / POOL_SIZE, (IMAGE_SIZE - CONV_KERNEL_SIZE + 1) / POOL_SIZE, CONV_FILTERS};
207+ const uint32_t poolOutputDimensions[] = {1 , (IMAGE_SIZE - CONV_KERNEL_SIZE + 1 ) / POOL_SIZE, (IMAGE_SIZE - CONV_KERNEL_SIZE + 1 ) / POOL_SIZE, CONV_FILTERS};
210208 ANeuralNetworksOperandType poolOutputType = {
211209 .type = ANEURALNETWORKS_TENSOR_FLOAT32,
212210 .dimensionCount = 4 ,
@@ -226,10 +224,10 @@ void classify_images(JNIEnv* env, jintArray inputTensor) {
226224
227225 // Add the max pooling operation
228226 std::vector<uint32_t > poolInputIndexes = {reluOutputIndex, // Assuming this is the input tensor from previous layers
229- paddingLeftIndex, paddingRightIndex, paddingTopIndex, paddingBottomIndex, // Reused or newly defined
230- strideWidthIndex, strideHeightIndex, // Reused or newly defined
231- poolFilterWidthIndex, poolFilterHeightIndex, // Newly defined above
232- activationIndex};
227+ paddingLeftIndex, paddingRightIndex, paddingTopIndex, paddingBottomIndex, // Reused or newly defined
228+ strideWidthIndex, strideHeightIndex, // Reused or newly defined
229+ poolFilterWidthIndex, poolFilterHeightIndex, // Newly defined above
230+ activationIndex};
233231 uint32_t poolOutputIndexes[] = {poolOutputIndex};
234232 status = ANeuralNetworksModel_addOperation (model, ANEURALNETWORKS_MAX_POOL_2D, poolInputIndexes.size (), poolInputIndexes.data (), 1 , poolOutputIndexes);
235233 if (status != ANEURALNETWORKS_NO_ERROR) {
0 commit comments