{"record":{"id":"2b7b0dc318dbf3c5","repo":"tensorflow/models","slug":"feature-map-sizes-h-w-not-divisible-by-window-2b7b0d","errorCode":null,"errorMessage":"Feature map sizes {(h, w)} not divisible by window size ({grid_size}).","messagePattern":"Feature map sizes (.+?) not divisible by window size \\((.+?)\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/maxvit/modeling/maxvit.py","lineNumber":329,"sourceCode":"    \"\"\"Partition the input feature maps into non-overlapping windows.\n\n    Note that unsuitable feature or window sizes may be costly on TPU due to\n    padding sizes:\n    https://docs.google.com/document/d/1GojE1Q7hR2qyi0mIfnTHgERfl7Dmsj6xPQ31MQo3xUk/edit#\n\n    Args:\n      features: [B, H, W, C] feature maps.\n\n    Returns:\n      Partitioned features: [B, nH, nW, wSize, wSize, c].\n\n    Raises:\n      ValueError: If the feature map sizes are not divisible by window sizes.\n    \"\"\"\n    _, h, w, c = features.shape\n    grid_size = self._grid_size\n    if h % grid_size != 0 or w % grid_size != 0:\n      raise ValueError(\n          f'Feature map sizes {(h, w)} '\n          f'not divisible by window size ({grid_size}).'\n      )\n    features = tf.reshape(\n        features, (-1, grid_size, h // grid_size, grid_size, w // grid_size, c)\n    )\n    features = tf.transpose(features, (0, 2, 4, 1, 3, 5))\n    features = tf.reshape(features, (-1, grid_size, grid_size, c))\n    return features\n\n  def grid_stitch_back(\n      self, features: tf.Tensor, grid_size: int, h: int, w: int\n  ) -> tf.Tensor:\n    \"\"\"Reverse window_partition.\"\"\"\n    features = tf.reshape(\n        features,\n        [\n            -1,","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/maxvit/modeling/maxvit.py#L311-L347","documentation":"Error \"Feature map sizes {(h, w)} not divisible by window size ({grid_size}).\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/maxvit/modeling/maxvit.py:329 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}