Pt Eq
Pt Eq — element-wise equality, the node behind masks, matches, and one-hots
- tens_a
- tens_b
- TENSOR
PtEq compares two tensors element by element and tells you where they're equal. Sounds trivial. It's actually one of those quiet workhorse nodes you reach for constantly once you're doing real tensor work in ComfyUI: build a mask where values match a target, count how many predictions were correct, or turn class indices into a one-hot-ish boolean tensor. Comparison is how tensors become decisions.
It's part of ComfyUI-Pt-Wrapper, HowToSD's no-code PyTorch toolkit. In the pack's comparison drawer (PtGt, PtLt, PtGe, PtLe, PtNe, and this one), equality is the one you'll actually use - it's the building block for accuracy checks and data filtering in the graph.
How it works
Under the hood it's torch.eq(tens_a, tens_b), returned as a boolean tensor - every element is True or False, and the output shape mirrors the input. Because it's torch, broadcasting applies: compare a matrix against a single scalar or row and the comparison expands. The bool dtype is the thing to remember, because it means the output isn't arithmetic - though you can cast it with the pack's PtToFloat32 and sum it to count matches, which is a genuinely useful trick.
Inputs that matter
- tens_a - first tensor.
- tens_b - second tensor; same shape or broadcastable.
Output is a boolean TENSOR. Feed it into a PtWhere-style selection, use it as a mask, or sum the cast version to count exact matches.
Installing it
ComfyUI Manager → Install Custom Nodes → search "Pt Wrapper" → install → restart, or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart ComfyUI after. First install is heavy (matplotlib, pandas, scipy, scikit-learn, transformers, datasets, pinned gensim), but this node is pure torch.
Common issues
The subtle one is dtype. Comparing a float tensor like 1.0 against an integer 1 usually works because torch promotes, but comparing two float tensors for exact equality is fragile - floating-point representation means 0.1 + 0.2 is not 0.3 to a computer. If you're trying to match computed values, compare against a rounded or integer version first. And remember the output is boolean: if your downstream nodes expect floats, add a cast or the math will silently do nothing useful.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| tens_a | TENSOR | — | |
| tens_b | TENSOR | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |