Files
Ewald a4154ccf05 Fix P0 bugs, remove Append V2/Lens Artifacts, and fix crop reload reset
- Fix batch bypass tuple handling, memory budget device-awareness, grain
  RNG device, roto payload limits, preview temp-file cleanup, and route
  double-registration.
- Add native VIDEO output (fps/audio) to effect nodes that previously
  only returned IMAGE/MASK when fed a VIDEO input.
- Split the oversized src/preview/ops/geometry.ts and add a starting
  golden-fixture test harness (spherize, transform) comparing backend
  and frontend math.
- Remove ImageOpsAppendV2 (Autogrow) and ImageOpsLensArtifacts; inline
  Append's helper back into its single caller.
- Collapse the Color Correct curve widget behind a toggle so the node
  no longer grows too tall.
- Fix Crop/generic-node video preview playback running at the RAF rate
  instead of the source video's real fps.
- Fix Crop losing its saved output size after a workflow reload:
  syncCropWidgets recomputed height from width and a preset aspect
  ratio on every resync (including onConfigure on load), discarding
  the restored value. It now only refreshes aspect-ratio bookkeeping
  on a resync.
2026-09-30 12:49:42 +02:00

40 lines
1.3 KiB
Python

"""Grain RNG must generate on the tensor's own device for CUDA/MPS instead of
always paying a CPU round-trip, while staying on CPU for backends torch.Generator
doesn't support directly (DirectML, XPU, NPU)."""
from __future__ import annotations
import torch
from nodes.grain import _grain_generator_device, _grain_noise_like
class _DeviceStub:
def __init__(self, type_name):
self.type = type_name
class _TensorStub:
def __init__(self, type_name):
self.device = _DeviceStub(type_name)
def test_generator_device_matches_supported_backends():
assert _grain_generator_device(_TensorStub("cuda")).type == "cuda"
assert _grain_generator_device(_TensorStub("mps")).type == "mps"
assert _grain_generator_device(_TensorStub("cpu")).type == "cpu"
def test_generator_device_falls_back_to_cpu_for_unsupported_backends():
# torch.Generator has no native support for DirectML/XPU/NPU backends.
assert _grain_generator_device(_TensorStub("privateuseone")).type == "cpu"
assert _grain_generator_device(_TensorStub("xpu")).type == "cpu"
def test_grain_noise_like_still_produces_correct_shape_and_device_on_cpu():
source = torch.zeros(2, 8, 8, 3)
noise = _grain_noise_like(source, seed=1, monochrome=False, animated=True)
assert noise.shape == source.shape
assert noise.device == source.device