{"record":{"id":"719b583a9aab955d","repo":"tensorflow/models","slug":"rank-of-tensor-s-must-be-known","errorCode":null,"errorMessage":"Rank of Tensor %s must be known","messagePattern":"Rank of Tensor (.+?) must be known","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"official/projects/bigbird/recompute_grad.py","lineNumber":129,"sourceCode":"  \"\"\"Force all of `then_compute` to depend on all of `first_compute`.\n\n  Uses a dummy data dependency, which is useful when running on TPUs because\n  XLA ignores control dependencies. Only supports float arguments.\n\n  Args:\n    first_compute: Sequence of `Tensor`s to be executed before `then_compute`.\n    then_compute: Sequence of `Tensor`s to executed after `first_compute`.\n\n  Returns:\n    Sequence of `Tensor`s with same length of `then_compute`.\n\n  Raises:\n    ValueError: if ranks are unknown or types are not floating.\n  \"\"\"\n\n  def _first_element(x):\n    if x.shape.ndims is None:\n      raise ValueError('Rank of Tensor %s must be known' % x)\n    ndims = x.shape.ndims\n    begin = tf.zeros(ndims, dtype=tf.int32)\n    size = tf.ones(ndims, dtype=tf.int32)\n    return tf.reshape(tf.slice(x, begin, size), [])\n\n  first_compute_sum = tf.add_n(\n      [_first_element(x) for x in first_compute if x is not None])\n  dtype = first_compute_sum.dtype\n  if not dtype.is_floating:\n    raise ValueError('_force_data_dependency only supports floating dtypes.')\n  zero = np.finfo(dtype.as_numpy_dtype).tiny * first_compute_sum\n  return [  # pyrefly: ignore[bad-return]\n      x + tf.cast(zero, x.dtype) if x is not None else None\n      for x in then_compute\n  ]\n\n\ndef _make_seed_if_none(seed: Optional[tf.Tensor]) -> tf.Tensor:","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/bigbird/recompute_grad.py#L111-L147","documentation":"Error \"Rank of Tensor %s must be known\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/bigbird/recompute_grad.py:129 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"}