Nodes/ComfyDL/Reshape (DEPRECATED)
ComfyUI Node

Reshape (DEPRECATED)

The node that fixes 90% of your shape errors in ComfyDL

By Cynthia-lxx·Created 2 months ago·Updated 2 days ago· 6
Reshape (DEPRECATED)
  • tensor
  • output
target_shape3,2

"Shape mismatch" is the error message that will dominate your life in ComfyDL. The pack's nodes are picky about tensor dimensions, and half the time the fix isn't a rethink - it's a reshape. CdlReshape does exactly one thing: takes a tensor and gives it a new shape, wrapping torch.reshape with a comma-separated string widget. Boring, essential, and probably the node you'll wire more than any other while you're learning.

ComfyDL is the Dive into Deep Learning textbook as nodes, and the textbook reshapes constantly - flattening image tensors into feature vectors, batching sequences, matching feature maps to labels. This node is how you do that without leaving the graph.

The inputs

  • tensor - any cdlTensor.
  • target_shape - a comma-separated shape string, e.g. "2,8". The -1 wildcard is supported and is the feature you'll use most: "4,-1" means "4 rows, and figure out the other dimension automatically." That single wildcard resolves the most common shape headaches on its own.

Output: output, the reshaped tensor. Total element count must match - you can't reshape 12 elements into [3, 5] - but with -1 you rarely have to count.

A shape primer for this pack

A few shapes you'll encounter constantly and what they usually mean in ComfyDL:

  • Images as [H, W] or batches as [B, H, W] / [B, H, W, C]
  • Sequences as [batch, seq_len]
  • Per-anchor data as [N, 4]

When a node complains, look at what shape the docs say it expects, then reshape your tensor to match. It's usually a flatten (collapse to [B, -1]) or a squeeze-equivalent (drop a stray size-1 batch dim via a reshape to the 2-D form).

Installing ComfyDL

Same light install as the rest of the pack:

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

Restart ComfyUI; it's under ComfyDL → Tensor Basic, or search "ComfyDL" in ComfyUI Manager. Only extra dependency is matplotlib; no model files.

The honest gotchas

First, -1 only works once per shape string - two wildcards and torch can't disambiguate, and you'll get an error. Second, note the node's error handling: on a parse failure (garbage string) it quietly returns the original tensor unchanged. That's a nice safety valve, but it's also a silent-failure trap - a mistyped shape won't error, it'll just pass your data through, and you'll chase a "bug" that's actually a typo in a widget. If a reshape seems to do nothing, look at the string.

Finally, the caveat that applies to everything in this pack: the input and output are cdlTensors, so this node lives inside the ComfyDL sandbox. It reshapes the pack's own tensors for the pack's own nodes - it won't hand a tensor to a stock ComfyUI node, and it won't fix shapes between ComfyDL and the rest of ComfyUI. Inside the sandbox, though, it's the single most forgiving shape tool you've got.

Categoryd2l/_Legacy/Tensor Basic

Inputs (2)

NameTypeDefaultDescription
tensorTENSOR
target_shapeSTRING3,2

Outputs (1)

NameTypeDescription
outputTENSOR