{"record":{"id":"86b8742ebf275654","repo":"jax-ml/jax","slug":"reduce-window-got-inconsistent-base-dilation-and-w","errorCode":null,"errorMessage":"reduce_window got inconsistent base_dilation and window_dimensions: got base_dilation {} and window_dimensions {}.","messagePattern":"reduce_window got inconsistent base_dilation and window_dimensions: got base_dilation (.+?) and window_dimensions (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/lax/windowed_reductions.py","lineNumber":617,"sourceCode":"                       non_zero_shape=True)\n  lax._check_shapelike(\"reduce_window\", \"window_strides\", window_strides,\n                       non_zero_shape=True)\n  lax._check_shapelike(\"reduce_window\", \"base_dilation\", base_dilation)\n  lax._check_shapelike(\"reduce_window\", \"window_dilation\", window_dilation)\n  if operand.ndim != len(window_dimensions):\n    msg = (\n        \"reduce_window got the wrong number of window_dimensions for \"\n        \"operand: got operand shape {} with window_dimensions {}.\"\n    )\n    raise TypeError(msg.format(operand.shape, window_dimensions))\n  if len(window_strides) != len(window_dimensions):\n    msg = (\"reduce_window got inconsistent window_strides and \"\n           \"window_dimensions: got window_strides {} and window_dimensions {}.\")\n    raise TypeError(msg.format(window_strides, window_dimensions))\n  if len(base_dilation) != len(window_dimensions):\n    msg = (\"reduce_window got inconsistent base_dilation and \"\n           \"window_dimensions: got base_dilation {} and window_dimensions {}.\")\n    raise TypeError(msg.format(base_dilation, window_dimensions))\n  if len(window_dilation) != len(window_dimensions):\n    msg = (\"reduce_window got inconsistent window_dilation and \"\n           \"window_dimensions: got window_dilation {} and window_dimensions \"\n           \"{}.\")\n    raise TypeError(msg.format(window_dilation, window_dimensions))\n\n  return reduce_window_shape_tuple(operand.shape, window_dimensions,\n                                   window_strides, padding, base_dilation,\n                                   window_dilation)\n\ndef reduce_window_shape_tuple(operand_shape, window_dimensions, window_strides,\n                              padding, base_dilation=None,\n                              window_dilation=None):\n  if base_dilation is not None:\n    operand_shape = lax._dilate_shape(operand_shape, base_dilation)\n  if window_dilation is not None:\n    window_dimensions = lax._dilate_shape(window_dimensions, window_dilation)\n  operand_padded = tuple(d + pl + ph for d, (pl, ph) in zip(operand_shape, padding))","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/lax/windowed_reductions.py#L599-L635","documentation":"lax.reduce_window's base_dilation must have the same length as window_dimensions. Raised by the common shape rule when len(base_dilation) mismatches.","triggerScenarios":"Supplying base_dilation=(1,1) with a 4-element window_dimensions; or relying on the default while passing mis-sized lists.","commonSituations":"Using dilated pooling (e.g. mixed-conv downsampling) with incomplete dilation specs.","solutions":["Provide base_dilation of the same rank as the operand, e.g. (1,dh,dw,1) in NHWC"],"exampleFix":"# before\nlax.reduce_window_max(x, dims, strides, padding, base_dilation=(2,2))\n# after\nlax.reduce_window_max(x, dims, strides, padding, base_dilation=(1,2,2,1))","handlingStrategy":"validation","validationCode":"assert len(base_dilation) == len(window_dimensions)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass full-rank dilation tuples in NHWC order"],"tags":["jax","shape-validation","reduce-window","dilation"],"backgroundTag":"jax-reduce-window-invalid-arguments","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}