{"record":{"id":"6e993737659eb075","repo":"tensorflow/models","slug":"feature-map-sizes-h-w-not-divisible-by-window","errorCode":null,"errorMessage":"Feature map sizes {(h, w)} not divisible by window size ({window_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":277,"sourceCode":"    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\n    _, h, w, c = features.shape\n    window_size = self._window_size\n\n    if h % window_size != 0 or w % window_size != 0:\n      raise ValueError(\n          f'Feature map sizes {(h, w)} '\n          f'not divisible by window size ({window_size}).'\n      )\n\n    features = tf.reshape(\n        features,\n        (-1, h // window_size, window_size, w // window_size, window_size, c),\n    )\n    features = tf.transpose(features, (0, 1, 3, 2, 4, 5))\n    features = tf.reshape(features, (-1, window_size, window_size, c))\n    return features\n\n  def window_stitch_back(\n      self, features: tf.Tensor, window_size: int, h: int, w: int\n  ) -> tf.Tensor:\n    \"\"\"Reverse window_partition.\"\"\"\n    features = tf.reshape(\n        features,","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/maxvit/modeling/maxvit.py#L259-L295","documentation":"Error \"Feature map sizes {(h, w)} not divisible by window size ({window_size}).\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/maxvit/modeling/maxvit.py:277 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"}