ComfyUI Node

tensor new

Spawn a fresh tensor of any shape, filled or random, when you need a blank canvas

By 807502278·Created 2 years ago·Updated 2 years ago· 23
tensor new
  • tensor_shape
  • Tensor
Value0.500
randomfalse

Sometimes you don't have data yet - you need a tensor to exist so you can test a workflow, drive a camera, or fill in a slot. tensor new (from ComfyUI-3D-MeshTool) creates a fresh tensor of whatever shape you ask for, either filled with a constant value or filled with random floats. It's the "blank sheet of paper" node of the pack's tensor side.

You'll reach for it when prototyping camera paths (spawn a [N, 3] tensor and feed it into RT-to-camposes), when you need placeholder data to test a downstream math chain, or when you want a deterministic starting point before running data through it.

How it works

Three inputs:

  • tensor_shape (TUPLE) - the dimensions. There's no built-in shape box on this node; the pack's tensor-shape node builds a TUPLE from five dimension integers and feeds it in. (10, 3) gives you a [10, 3] tensor.
  • Value (FLOAT, default 0.5) - the fill value, used when random is off.
  • random (BOOLEAN, default false) - when toggled on, the node ignores Value and fills the tensor with torch.rand(...) uniform floats in [0, 1) instead.

Under the hood it's two one-liners: torch.full(tensor_shape, Value) or torch.rand(tensor_shape). Output is a float32 Tensor.

Output

  • Tensor - your new tensor.

Install

It's part of the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/807502278/ComfyUI-3D-MeshTool
cd ComfyUI-3D-MeshTool
pip install -r requirements.txt

Restart ComfyUI, or install via ComfyUI Manager (search "ComfyUI-3D-MeshTool").

Notes

Two practical things. First, torch.rand re-rolls every time the graph runs - there's no seed input, so "random" workflows aren't reproducible through this node. If you need a fixed random tensor, generate it once, pass it through Tensor to List, and reuse the frozen values. Second, all-zero or all-0.5 tensors are genuinely useful for testing (a camera path of constant value still exercises the downstream math), but they're not real data - don't ship a render on a placeholder and wonder why every view looks identical.

Category3D_MeshTool/Array/Tensor

Inputs (3)

NameTypeDefaultDescription
tensor_shapeTUPLE
ValueFLOAT0.500-999999–999999
randomBOOLEANfalse

Outputs (1)

NameTypeDescription
TensorTensor