Tensor Switch
The A/B valve for images, masks and latents
- input_a
- input_b
- output
Every complex workflow ends up with the same question somewhere in the middle: "use this image, or that one?" The answer is usually a boolean switch, and this is one of the cleanest ones in WAS Node Suite for the picture-shaped answer.
What it is
Tensor Image Switch takes two pictures, input_a and input_b, plus a boolean - and passes through exactly one of them. boolean true hands you input_a; false hands you input_b. That's the entire job, but the way it's built is what makes it worth using over a grab-bag any-input switch.
The socket is typed to take an image, a mask or a latent - and only those three. "Tensor image" is the pack's umbrella name for the types that travel as tensors, and unlike a wildcard * switch, a wrong wire here is refused as you draw it. Once you plug an IMAGE into input_a, input_b and the output lock to IMAGE too, so you can't accidentally route a mask into a node expecting a photo.
The lazy detail that actually matters
Both inputs are lazy: the unselected branch is never evaluated. Choose input_b and whatever expensive work is feeding input_a simply doesn't run - no latent sampled, no model loaded, no VRAM spent. That's the difference between routing a value and paying for every path's computation every time. If you've ever built an A/B comparison where both branches ran regardless of your choice, this is the fix.
When you'd reach for it
The classic use is keeping two image sources in one workflow and flipping between them - a manual A/B, or an automated one driven by a condition from elsewhere. Wire a To Boolean or a Compare node into boolean and the choice stops being manual:
- Two reference images, pick by whichever an earlier measurement says is sharper.
- Two latents (an img2img input vs. a freshly denoised one), choose based on a result computed mid-graph.
- A mask or no mask for an inpainting pass, chosen by whether detection found anything.
The boolean is a true widget on the node, so you can also just click it to flip between two setups without deleting and re-wiring - handy for side-by-side testing where the rest of the graph is identical.
When your choice is "one of many pictures by number" rather than "one of two by boolean," step up to the sibling Tensor Image Index Switch, which takes up to 26 inputs and an index. And if the values aren't pictures at all - models, text, numbers - the pack's untyped switches are the place to look instead.
Installing it
Part of WAS Node Suite v3 (WASasquatch's was-node-suite-comfyui, MIT). Search "WAS Node Suite v3" in ComfyUI Manager, or:
cd ComfyUI/custom_nodes
git clone https://github.com/WASasquatch/was-node-suite-comfyui.git
Restart ComfyUI after installing. You need ComfyUI 0.14.0+ and Python 3.10+; the node needs no extra packages.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| input_a | COMFY_MATCHTYPE_V3 | Passed on when boolean is true. Takes IMAGE, MASK or LATENT. The first connection fixes the type; input_b and output then take that type only. | |
| input_b | COMFY_MATCHTYPE_V3 | Passed on when boolean is false. Must match input_a's type. | |
| boolean | BOOLEAN | true | Selects the input. true = input_a, false = input_b. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| output | COMFY_MATCHTYPE_V3 | The selected input, typed to whatever was connected. |