Tensor Ops (mtb)
The elementwise math node for fixing a tensor that looks wrong
- tensor
- target_tensor
- IMAGE
Sometimes an image tensor coming out of a custom node isn't in the range or format anything else expects - a depth map that's 0–255 when everything downstream wants 0–1, a normal map baked for a different convention, a dtype mismatch between two packs that otherwise wire together fine. Rather than write a Python node to fix it, Tensor Ops gives you the common elementwise operations as a dropdown.
The operations
Twelve of them, selected via the operation field: multiply, divide, add, subtract, power, clamp, abs, log, exp, convert_dtype, normalize_range, normalize_per_channel. That's roughly two families - simple scalar arithmetic (multiply/divide/add/subtract/power/clamp/abs/log/exp, all using the value field as the operand) and range/format fixes (convert_dtype for changing the underlying numeric type, and the two normalize_* modes for remapping a tensor's value range).
Inputs and outputs
tensor- required, theIMAGEyou're operating on.operation- the dropdown above.value- the scalar for the arithmetic ops (default 1).source_min/source_maxandtarget_min/target_max- relevant fornormalize_range: tell it what range your data is actually in and what range you want it mapped to. Defaults are 0–1 source and 0–16 target, which tells you this node was built with things like depth or latent-adjacent debug data in mind, not ordinary 0–1 pixel images.dtype- forconvert_dtype:uint8,float32,float16, orbfloat16.use_mean- relevant tonormalize_per_channel, whether to center each channel on its own mean rather than a fixed range.target_tensor(optional) - a secondIMAGE, presumably for operations that compare or match against a reference tensor rather than a fixed scalar.
Output is a single IMAGE - your tensor, transformed.
When you'd reach for it
This is a debug/interop node, not a creative one. You'll want it when a tensor from some other node - often one that wasn't designed with ComfyUI's usual 0–1 float32 IMAGE convention in mind, like a depth or normal-map generator - needs reshaping before the rest of your graph will accept it cleanly. normalize_range in particular earns its keep here: instead of guessing at a fix, tell it the actual min/max you're seeing and where you want it mapped, and it does the linear remap for you.
Installing it
ComfyUI Manager: search "MTB Nodes," install, restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/melMass/comfy_mtb
then restart, and if it's missing, go into comfy_mtb and run pip install -r requirements.txt yourself.
Common issues
The node itself has no special dependencies beyond what the base pack needs (torch, which ComfyUI already requires) - if you don't see it in your node list, it's the standard base-install issue, not anything about tensor math specifically. The mistake people actually make with this node is picking the wrong operation for the symptom: if your image looks washed out or blown out, that's a range problem and you want normalize_range, not clamp (which just cuts off values outside a range rather than rescaling them). If it looks right but crashes downstream with a dtype error, that's convert_dtype, not a range operation at all. Match the tool to the actual symptom rather than trial-and-error through the dropdown.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| tensor | IMAGE | — | |
| operation | COMBO | multiply | 12 options: multiply, divide, add, subtract, power, clamp, +6 |
| value | FLOAT | 1.00-1000000–1000000 | — |
| source_min | FLOAT | 0.00-1000000–1000000 | — |
| source_max | FLOAT | 1.00-1000000–1000000 | — |
| target_min | FLOAT | 0.00-1000000–1000000 | — |
| target_max | FLOAT | 16.00-1000000–1000000 | — |
| dtype | COMBO | float32 | 4 options: uint8, float32, float16, bfloat16 |
| use_mean | BOOLEAN | false | — |
| target_tensoropt | IMAGE | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |