Tensor Create
Tensor Create — turning plain numbers into actual PyTorch tensors
- input
- *
Tensor Create is the gateway node of the pack's tensor section: it takes a plain Python value - a number, a list of numbers, or an existing tensor - and makes sure you have an actual PyTorch tensor on the other end. In a graph where half the nodes speak tensor and the other half speak ints and strings, this is the translator that gets both sides talking.
It's part of Basic data handling by StableLlama, the dependency-free utility pack that wraps everyday Python and PyTorch into ComfyUI nodes. If the pack is "Python API as nodes," Tensor Create is the torch.tensor() constructor wearing a ComfyUI costume.
How it works
The logic is short and honest: if the input is already a torch.Tensor, it just passes it through untouched. Otherwise it calls torch.tensor(input) and returns the result. That means it's two tools in one - a passthrough that guarantees "you have a tensor now," and a converter that turns raw values into one.
What you get depends on what you feed it:
- A single float like
0.5→ a 0-dimensional scalar tensor (dtype float32). - A list like
[1, 2, 3]→ a 1-dimensional tensor (dtype int64, because plain Python ints default to integer tensors). - A nested list like
[[0.1, 0.2], [0.3, 0.4]]→ a 2-dimensional tensor.
The inputs that matter
There's exactly one required input, which keeps the learning curve to zero:
input(wildcard*) - a number, a list, or any existing tensor.
And a single wildcard output that plugs into anything expecting tensor data.
Where you'd actually use it
The realistic use is scaffolding: creating a constant tensor to feed into the pack's Tensor Binary Op for a blend weight, making a small tensor to test a math operation before wiring it into your real graph, or just guaranteeing that whatever a custom node gave you is really a tensor before it reaches a math step. It's rarely the star of a workflow - it's the node you use so the other nodes have something to chew on.
Installing it
# ComfyUI Manager (recommended): search "Basic data handling", install, restart.
# or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
# restart ComfyUI
The pack declares no dependencies - torch is already in your ComfyUI environment - so there's no requirements.txt step and no models to fetch.
Where people get burned
The integer default is the classic trap. [1, 2, 3] becomes an int64 tensor, and int tensors behave differently than float ones: dividing ints truncates or errors, and mixing an int tensor with float32 image data can produce surprising results downstream. If you're building toward image math, prefer lists with decimals (1.0, 2.0) so you get float tensors from the start.
Also worth knowing: because the input is a wildcard, ComfyUI won't warn you if you wire something non-convertible (a dict, say) into it. You'll find out at runtime with a "Failed to create tensor" error. Not a bug - that's the node being honest about what it can't do. And don't expect magic: it doesn't invent shapes or infer intent from a single number. A scalar is a scalar; if you wanted a [1, 1] matrix, feed it a nested list.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| input | * | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | — |