{"record":{"id":"d974c8b805992e7c","repo":"jax-ml/jax","slug":"tensordot-axes-argument-must-be-an-int-a-pair-of","errorCode":null,"errorMessage":"tensordot axes argument must be an int, a pair of ints, or a pair of lists/tuples of ints.","messagePattern":"tensordot axes argument must be an int, a pair of ints, or a pair of lists/tuples of ints\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"jax/_src/numpy/tensor_contractions.py","lineNumber":586,"sourceCode":"  elif isinstance(axes, (tuple, list)) and len(axes) == 2:\n    ax1, ax2 = axes\n    if isinstance(ax1, int) and isinstance(ax2, int):\n      contracting_dims = ((canonicalize_axis(ax1, a_ndim),),\n                          (canonicalize_axis(ax2, b_ndim),))\n    elif isinstance(ax1, (tuple, list)) and isinstance(ax2, (tuple, list)):\n      if len(ax1) != len(ax2):\n        msg = \"tensordot requires axes lists to have equal length, got {} and {}.\"\n        raise TypeError(msg.format(ax1, ax2))\n      contracting_dims = (tuple(canonicalize_axis(i, a_ndim) for i in ax1),\n                          tuple(canonicalize_axis(i, b_ndim) for i in ax2))\n    else:\n      msg = (\"tensordot requires both axes lists to be either ints, tuples or \"\n             \"lists, got {} and {}\")\n      raise TypeError(msg.format(ax1, ax2))\n  else:\n    msg = (\"tensordot axes argument must be an int, a pair of ints, or a pair \"\n           \"of lists/tuples of ints.\")\n    raise TypeError(msg)\n  result = lax.dot_general(\n      a, b, (contracting_dims, ((), ())), precision=precision,\n      preferred_element_type=preferred_element_type,\n      out_sharding=out_sharding)\n  return lax._convert_element_type(result, preferred_element_type, output_weak_type)\n\n\n\n@export\n@api.jit(static_argnames=('precision', 'preferred_element_type'), inline=True)\ndef inner(\n    a: ArrayLike, b: ArrayLike, *, precision: lax.PrecisionLike = None,\n    preferred_element_type: DTypeLike | None = None,\n) -> Array:\n  \"\"\"Compute the inner product of two arrays.\n\n  JAX implementation of :func:`numpy.inner`.\n","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/jax-ml/jax/blob/1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb/jax/_src/numpy/tensor_contractions.py#L568-L604","documentation":"tensordot accepts only three axes forms: a single int, a pair of ints, or a pair of lists/tuples of ints. Anything else (a bare list, a string, a 3-element tuple, etc.) hits the final else branch and raises this TypeError.","triggerScenarios":"jnp.tensordot(a, b, axes=[1,2]) (a single list, not a pair), or axes=((1,2),(0,1),(3,4)), or a non-integer value.","commonSituations":"Confusion with numpy semantics or other libraries; passing a single sequence where a pair-of-sequences is required; passing None.","solutions":["Pass an integer N, or a (int,int) pair, or a (list,list) pair","Wrap a single axis list as ([...],[...])"],"exampleFix":"// before\njnp.tensordot(a, b, axes=[1, 0])\n// after\njnp.tensordot(a, b, axes=([1],[0]))","handlingStrategy":"validation","validationCode":"ok = type(axes) is int or (isinstance(axes,(tuple,list)) and len(axes)==2)\nassert ok, 'axes must be int, (int,int), or (list,list)'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass a bare list of axes; always wrap as a pair"],"tags":["jax","tensordot","invalid-argument","numpy"],"backgroundTag":"invalid-axes-argument","analyzedSha":"1e1c6a8fc06dfcd1247076ec5cae4640cea5d7bb","analyzedAt":"2026-08-27T09:53:25.647Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}