{"record":{"id":"09632f2ef9c24285","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-s-s-speci","errorCode":null,"errorMessage":"[cimg_appname_math_parser] CImg<%s>::%s: %s: Specified input size (%ux%ux%ux%u = %u) does not match size of input variable (%u), in expression '%s'.","messagePattern":"\\[cimg_appname_math_parser\\] CImg<(.+?)>::(.+?): (.+?): Specified input size \\(%ux%ux%ux%u = %u\\) does not match size of input variable \\(%u\\), in expression '(.+?)'\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":20966,"sourceCode":"                wI = (unsigned int)mem[opcode[3]],\n                hI = (unsigned int)mem[opcode[4]],\n                dI = (unsigned int)mem[opcode[5]],\n                sI = (unsigned int)mem[opcode[6]],\n                wK = (unsigned int)mem[opcode[8]],\n                hK = (unsigned int)mem[opcode[9]],\n                dK = (unsigned int)mem[opcode[10]],\n                sK = (unsigned int)mem[opcode[11]],\n                channel_mode = (unsigned int)mem[opcode[14]],\n                xstride = (int)mem[opcode[18]],\n                ystride = (int)mem[opcode[19]],\n                zstride = (int)mem[opcode[20]],\n                xsize = opcode[27]==~0U?wI/xstride:(unsigned int)mem[opcode[27]],\n                ysize = opcode[28]==~0U?hI/ystride:(unsigned int)mem[opcode[28]],\n                zsize = opcode[29]==~0U?dI/zstride:(unsigned int)mem[opcode[29]];\n\n              if (wI*hI*dI*sI!=size(opcode[2])) {\n                _cimg_mp_strerr;\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: %s: Specified input size (%ux%ux%ux%u = %u) does \"\n                                            \"not match size of input variable (%u), in expression '%s'.\",\n                                            pixel_type(),_cimg_mp_calling_function,s_op,\n                                            wI,hI,dI,sI,wI*hI*dI*sI,size(opcode[2]),\n                                            s0);\n              }\n              if (wK*hK*dK*sK!=size(opcode[7])) {\n                _cimg_mp_strerr;\n                throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] \"\n                                            \"CImg<%s>::%s: %s: Specified kernel size (%ux%ux%ux%u = %u) does \"\n                                            \"not match size of kernel variable (%u), in expression '%s'.\",\n                                            pixel_type(),_cimg_mp_calling_function,s_op,\n                                            wK,hK,dK,sK,wK*hK*dK*sK,size(opcode[7]),\n                                            s0);\n              }\n\n              arg2 = !channel_mode?sI*sK:channel_mode==1?std::max(sI,sK):\n                channel_mode==2?std::max(sI,sK)/std::min(sI,sK):1U;","sourceCodeStart":20948,"sourceCodeEnd":20984,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L20948-L20984","documentation":"Thrown by the convolution-type opcode in the math parser: the input image variable (opcode[2], a vector) has an element count that disagrees with the computed input extent wI*hI*dI*sI derived from the specified sizes and strides. If a dimension size is unspecified (~0U) it is derived as the image dimension divided by the stride; otherwise it is read from the expression memory. The parser validates the product against size(opcode[2]) before running the operation.","triggerScenarios":"Evaluating an expression-level convolution/pooling where the input variable holds N values but the declared (or stride-derived) input geometry multiplies to M != N; explicitly passing xsize/ysize/zsize arguments inconsistent with the actual input vector; wrong stride values changing the derived defaults.","commonSituations":"Hand-computing input sizes for a sliding-window op in an expression; changing stride parameters without recomputing sizes; reshaping input data (e.g. after a channel change from RGB to RGBA) without updating the size arguments.","solutions":["Make the input vector length exactly wI*hI*dI*sI (verify counts before the call).","Leave the size arguments unspecified (~0U / omit them) so they are derived from the image dimensions and strides instead of hard-coding.","Recompute explicit sizes after any stride change.","Pad or trim the input variable to the declared geometry."],"exampleFix":"// before\nconvolve(in, k, 16,16,1,3, 1,1) // in has 768 values but 16*16*1*3=768? mismatch -> fix sizes\n// after\nconvolve(in, k, wI,hI,dI,sI, 1,1) // derive sizes, or pass 32,8,1,3 for 768 values","handlingStrategy":"validation","validationCode":"size_t inLen = inVec.size();\nunsigned long expect = (unsigned long)wI*hI*dI*sI;\nif (inLen != expect) throw std::runtime_error(\"input size \" + std::to_string(expect) + \" != variable size \" + std::to_string(inLen));","typeGuard":"bool input_fits(const CImg<float>& in, unsigned wI, unsigned hI, unsigned dI, unsigned sI) {\n  return (unsigned long)in.size() == (unsigned long)wI*hI*dI*sI;\n}","tryCatchPattern":"try {\n  img.fill(expr.c_str());\n} catch (const CImgArgumentException& e) {\n  // recompute sizes/strides or pad input before retrying\n}","preventionTips":["Derive input sizes from image dimensions and strides instead of hard-coding","Recompute sizes whenever strides change","Verify the input vector length before convolution-style ops"],"tags":["cimg","math-parser","convolution","size-mismatch"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}