{"record":{"id":"d96a3d7ad0acf9f8","repo":"tensorflow/models","slug":"padded-decoding-on-cpu-gpus-is-not-supported","errorCode":null,"errorMessage":"Padded decoding on CPU/GPUs is not supported.","messagePattern":"Padded decoding on CPU/GPUs is not supported\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"official/legacy/transformer/transformer.py","lineNumber":128,"sourceCode":"      sequence. float tensor with shape [batch_size, target_length, vocab_size]\n      If target is none, then generate output sequence one token at a time.\n        returns a dictionary {\n          outputs: int tensor with shape [batch_size, decoded_length]\n          scores: float tensor with shape [batch_size]}\n      Even when float16 is used, the output tensor(s) are always float32.\n\n    Raises:\n      NotImplementedError: If try to use padded decode method on CPU/GPUs.\n    \"\"\"\n    inputs = inputs if isinstance(inputs, list) else [inputs]\n    if len(inputs) == 2:\n      inputs, targets = inputs[0], inputs[1]\n    else:\n      # Decoding path.\n      inputs, targets = inputs[0], None\n      if self.params[\"padded_decode\"]:\n        if not self.params[\"num_replicas\"]:\n          raise NotImplementedError(\n              \"Padded decoding on CPU/GPUs is not supported.\")\n        decode_batch_size = int(self.params[\"decode_batch_size\"] /\n                                self.params[\"num_replicas\"])\n        inputs.set_shape([decode_batch_size, self.params[\"decode_max_length\"]])\n\n    # Variance scaling is used here because it seems to work in many problems.\n    # Other reasonable initializers may also work just as well.\n    with tf.name_scope(\"Transformer\"):\n      # Calculate attention bias for encoder self-attention and decoder\n      # multi-headed attention layers.\n      attention_bias = model_utils.get_padding_bias(inputs)\n\n      # Run the inputs through the encoder layer to map the symbol\n      # representations to continuous representations.\n      encoder_outputs = self.encode(inputs, attention_bias, training)\n      # Generate output sequence if targets is None, or return logits if target\n      # sequence is known.\n      if targets is None:","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/transformer/transformer.py#L110-L146","documentation":"Error \"Padded decoding on CPU/GPUs is not supported.\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/legacy/transformer/transformer.py:128 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"}