{"record":{"id":"12765fd776cbfdcf","repo":"tensorflow/models","slug":"does-not-support-relative-attention-for-query-shap","errorCode":null,"errorMessage":"Does not support relative attention for query shape: %s.","messagePattern":"Does not support relative attention for query shape: (.+?)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/maxvit/modeling/layers.py","lineNumber":212,"sourceCode":"    self.a_expr = create_expr(symbols, suffix='NST')\n\n    ##### Relative attention\n    if self.rel_attn_type in ['2d_multi_head', '2d_single_head']:\n      query_shape_list = query_shape.as_list()\n      if query_shape.rank == 4:\n        height, width = query_shape_list[1:3]\n      elif query_shape.rank == 3:\n        seq_len = query_shape_list[1]\n        height, width = common_ops.get_shape_from_length(\n            seq_len, self.input_origin_height, self.input_origin_width\n        )\n        if height * width != seq_len:\n          raise ValueError(\n              'Sequence length: %s violates input size: (%s, %s).'\n              % (seq_len, height, width)\n          )\n      else:\n        raise ValueError(\n            'Does not support relative attention for query shape: %s.'\n            % query_shape_list\n        )\n\n      if self.scale_ratio is not None:\n        scale_ratio = eval(self.scale_ratio)  # pylint:disable=eval-used  # pyrefly: ignore[bad-argument-type]\n        vocab_height = 2 * int(height / scale_ratio) - 1\n        vocab_width = 2 * int(width / scale_ratio) - 1\n      else:\n        vocab_height = 2 * height - 1\n        vocab_width = 2 * width - 1\n\n      if self.rel_attn_type == '2d_multi_head':\n        rel_bias_shape = [self.num_heads, vocab_height, vocab_width]\n      elif self.rel_attn_type == '2d_single_head':\n        rel_bias_shape = [vocab_height, vocab_width]\n      else:\n        raise NotImplementedError(","sourceCodeStart":194,"sourceCodeEnd":230,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/maxvit/modeling/layers.py#L194-L230","documentation":"Error \"Does not support relative attention for query shape: %s.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/maxvit/modeling/layers.py:212 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"}