Nodes/ComfyUI-3D-MeshTool/get tensor shape
ComfyUI Node

get tensor shape

The honest sibling that actually reads a tensor

By 807502278·Created 2 years ago·Updated 2 years ago· 23
get tensor shape
  • Tensor
  • tensor_shape
  • dim_number
  • dim_1
  • dim_2
  • dim_3
  • dim_4
  • dim_5

Unlike the confusingly-named tensor shape from the same pack (which builds a shape from numbers you type), get tensor shape does what you'd hope: you feed it an actual tensor and it tells you what that tensor looks like. It's the debugging and plumbing node of the pair - the one you wire in when a 3D or batch workflow hands you a tensor and you have no idea whether it's [1, 512, 512, 3], [8, 4], or something you don't want to think about.

Mechanically it's dead simple. It reads Tensor.shape and Tensor.dim() and spills them out across seven outputs so you can grab whatever granularity you need:

  • tensor_shape - the shape as a TUPLE (e.g. (1, 512, 512, 3)), for passing straight into a node that wants a shape.
  • dim_number - how many dimensions the tensor has, as an INT.
  • dim_1 through dim_5 - each individual dimension as its own INT, padded with zeros if the tensor has fewer than five.

That per-dimension breakout is the killer feature. It means you can route dim_1 into a batch count, dim_2/dim_3 into a resolution math chain, or dim_4 into a channel check - all as plain integers that any ComfyUI math node understands. It turns a black-box tensor into values your workflow can react to, which is how you build graphs that adapt instead of graphs that hardcode everything.

The one quirk worth knowing: if a tensor has more than five dimensions, the code only reports the first five and silently ignores the rest. That's rare in practice - nearly everything in this pack's world is 1D to 4D - but don't use this node to audit a six-dimensional monster and expect full fidelity.

This is part of 807502278/ComfyUI-3D-MeshTool, a one-author utility pack for 3D mesh/point-cloud work that freely borrows conventions from ComfyUI-3D-Pack (including the Tensor and TUPLE types). It's a pure-Python inspection node - no models, no heavy deps beyond what the pack already pulls in - so if you see an error here, it's almost always that the tensor input isn't a torch tensor at all.

Install via ComfyUI Manager (search "ComfyUI-3D-MeshTool") and restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-3D-MeshTool
cd ComfyUI-3D-MeshTool
pip install -r requirements.txt

If you only touch images, get tensor shape is a nice-to-have for sanity checks. If you're neck-deep in tensor-based 3D workflows, it's the node that stops you from guessing. When in doubt about any tensor, wire it here and read the answer.

Category3D_MeshTool/Array/Tensor

Inputs (1)

NameTypeDefaultDescription
TensorTensor

Outputs (7)

NameTypeDescription
tensor_shapeTUPLE
dim_numberINT
dim_1INT
dim_2INT
dim_3INT
dim_4INT
dim_5INT