Skip to content

Commit 12b78bd

Browse files
committed
reached back to graph error
1 parent d1017f1 commit 12b78bd

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

Assignment3/nativenn/app/src/main/cpp/src/cnn_model.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)