Pt Ones
Pt Ones makes the ones() utility a node
- TENSOR
PtOnes creates a PyTorch tensor filled with 1s, sized however you ask. It's the node form of torch.ones() - one of those small utilities that looks pointless until you're mid-workflow and need a constant tensor to add to, multiply with, or use as a placeholder while you debug something bigger. In ComfyUI-Pt-Wrapper's "PyTorch in the graph" world, it's part of the tensor-creation family alongside Pt Rand (random values) and Pt Randn, and it outputs the pack's TENSOR type that the arithmetic and model nodes consume.
How it works
Give it a shape and a dtype, get back a tensor of all 1s. The shape is typed as text - [2,3,96,32] means batch 2, channel 3, height 96, width 32 - and the node parses it with Python's literal-eval, so brackets are required. Two inputs:
- size - a string like
[2,3,96,32]. Any number of dimensions works. This is the field you'll actually touch. - data_type - the tensor dtype:
float32(default),float16,bfloat16,float64,uint8,int8,int16,int32,int64, orbool. Useful for matching the dtype of whatever you're about to combine this with.
Output is a single TENSOR that wires into any Pt* arithmetic node (add, multiply, pow...) or anywhere a constant tensor is handy.
When you'd actually use this
The honest answer: for scaffolding, mostly. Want to sanity-check an addition or broadcast without building a whole data pipeline? All-ones tensor is a clean test input. Need a mask or bias of a particular shape for a quick experiment? This is the fastest way to fabricate one. It's also a good way to learn the pack's shape conventions - feed [2,3,96,32] and wire the output into a node that shows or inspects the tensor, and you've verified how dimensions flow through the graph.
The gotcha
The size field is strict text: it has to parse as a Python list, so 2,3,96,32 or (2,3,96,32)... actually parens work too since it's literal_eval, but keep it consistent and bracketed. A typo like a trailing comma or a letter produces a parse error at run time, not a friendly hint. And since a huge all-ones tensor is real memory, don't get carried away - [512,512,512] in float32 is half a gigabyte of 1s.
Installing it
Part of ComfyUI-Pt-Wrapper (HowToSD's no-code PyTorch pack, a spin-off of ComfyUI-Data-Analysis). ComfyUI Manager → search "ComfyUI-Pt-Wrapper", or:
cd ComfyUI/custom_nodes
git clone https://github.com/HowToSD/ComfyUI-Pt-Wrapper
Restart after; the first boot is slow while pandas, scikit-learn, transformers, sentencepiece, peft and friends install. No model downloads needed.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| size | STRING | — | |
| data_type | COMBO | 10 options: float32, float16, bfloat16, float64, uint8, int8, +4 |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| TENSOR | TENSOR | — |