Nodes/ComfyDL/Tensor → String
ComfyUI Node

Tensor → String

The node that lets you actually see what a tensor is doing

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Tensor → String
  • tensor
  • text
max_elems100
precision6

Every ComfyDL workflow ends in a wall at some point: you've built a chain of tensor operations, the numbers are flying through custom sockets, and you have no idea what any of them look like. Tensor → String is the debug window that fixes that. Feed it any cdlTensor and it hands you back a formatted string with the shape, dtype, device, and the actual values - which you then read in a String/Text output node or just by looking at the node's preview. In a pack full of nodes that transform tensors, this is the one that tells you what's true.

It does the thing a good debug print should do. The header line gives you shape, dtype, and device - the three facts you're usually actually missing. Then it prints the values using torch's own pretty-printer, capped by max_elems. If the tensor is bigger than that cap, it flattens and shows the first half and last half of the elements, with an explicit (truncated; total elements: N) line. That's a small but thoughtful touch: it doesn't dump 40,000 numbers on you, and it tells you it didn't.

Inputs

  • tensor - the cdlTensor you want to inspect. This is the one you'll wire from everywhere.
  • max_elems - the truncation budget, default 100 (range 10–10,000). Turn it up if you actually want a big dump.
  • precision - decimal places, default 6 (range 1–16). For loss values you might want more; for matrix eyeballing, fewer is less noise.

Output

A single text output of type STRING. Since ComfyUI has a native string display, you can usually read this directly on the node; wire it into any text passthrough or display node if you want it on canvas permanently. This is also the natural last stop for String → Tensor round-trips - parse something in, print it back, confirm nothing got mangled.

Installing it

Part of ComfyDL. ComfyUI Manager, search "ComfyDL". Or manually:

cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL
pip install -r ./ComfyDL/requirements.txt

Restart ComfyUI, look under the Tensor Basic category. Whole pack needs only matplotlib; nothing else to fetch.

Gotchas

The one real trap: this only accepts the pack's custom cdlTensor type, so you can't use it as a generic tensor inspector for native ComfyUI tensors - those live in a different type namespace. Within ComfyDL, though, this is the single most useful node in the pack. If a workflow "doesn't do anything," stringing a Tensor → String at each stage is the fastest way to find which node silently produced an empty or NaN tensor. One caveat for a young pack with no community history: if max_elems is set higher than a huge tensor, the print can stall your queue - don't inspect a million-element tensor at 10,000 precision unless you're prepared to wait.

Categoryd2l/Tensor Basic

Inputs (3)

NameTypeDefaultDescription
tensorTENSOR
max_elemsINT10010–10000
precisionINT61–16

Outputs (1)

NameTypeDescription
textSTRING