Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
91 lines
2.5 KiB
Python
91 lines
2.5 KiB
Python
from typing import Tuple, Union
|
|
|
|
import torch
|
|
|
|
from models.autoencoders.dual_conv3d import DualConv3d
|
|
from models.autoencoders.causal_conv3d import CausalConv3d
|
|
|
|
|
|
def make_conv_nd(
|
|
dims: Union[int, Tuple[int, int]],
|
|
in_channels: int,
|
|
out_channels: int,
|
|
kernel_size: int,
|
|
stride=1,
|
|
padding=0,
|
|
dilation=1,
|
|
groups=1,
|
|
bias=True,
|
|
causal=False,
|
|
spatial_padding_mode="zeros",
|
|
temporal_padding_mode="zeros",
|
|
):
|
|
if not (spatial_padding_mode == temporal_padding_mode or causal):
|
|
raise NotImplementedError("spatial and temporal padding modes must be equal")
|
|
if dims == 2:
|
|
return torch.nn.Conv2d(
|
|
in_channels=in_channels,
|
|
out_channels=out_channels,
|
|
kernel_size=kernel_size,
|
|
stride=stride,
|
|
padding=padding,
|
|
dilation=dilation,
|
|
groups=groups,
|
|
bias=bias,
|
|
padding_mode=spatial_padding_mode,
|
|
)
|
|
elif dims == 3:
|
|
if causal:
|
|
return CausalConv3d(
|
|
in_channels=in_channels,
|
|
out_channels=out_channels,
|
|
kernel_size=kernel_size,
|
|
stride=stride,
|
|
padding=padding,
|
|
dilation=dilation,
|
|
groups=groups,
|
|
bias=bias,
|
|
spatial_padding_mode=spatial_padding_mode,
|
|
)
|
|
return torch.nn.Conv3d(
|
|
in_channels=in_channels,
|
|
out_channels=out_channels,
|
|
kernel_size=kernel_size,
|
|
stride=stride,
|
|
padding=padding,
|
|
dilation=dilation,
|
|
groups=groups,
|
|
bias=bias,
|
|
padding_mode=spatial_padding_mode,
|
|
)
|
|
elif dims == (2, 1):
|
|
return DualConv3d(
|
|
in_channels=in_channels,
|
|
out_channels=out_channels,
|
|
kernel_size=kernel_size,
|
|
stride=stride,
|
|
padding=padding,
|
|
bias=bias,
|
|
padding_mode=spatial_padding_mode,
|
|
)
|
|
else:
|
|
raise ValueError(f"unsupported dimensions: {dims}")
|
|
|
|
|
|
def make_linear_nd(
|
|
dims: int,
|
|
in_channels: int,
|
|
out_channels: int,
|
|
bias=True,
|
|
):
|
|
if dims == 2:
|
|
return torch.nn.Conv2d(
|
|
in_channels=in_channels, out_channels=out_channels, kernel_size=1, bias=bias
|
|
)
|
|
elif dims == 3 or dims == (2, 1):
|
|
return torch.nn.Conv3d(
|
|
in_channels=in_channels, out_channels=out_channels, kernel_size=1, bias=bias
|
|
)
|
|
else:
|
|
raise ValueError(f"unsupported dimensions: {dims}")
|