{"record":{"id":"2caa7624299c7a60","repo":"hpcaitech/Open-Sora","slug":"resize-mode-mode-not-implemented","errorCode":null,"errorMessage":"resize(mode={mode}) not implemented.","messagePattern":"resize\\(mode=(.+?)\\) not implemented\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"opensora/models/dc_ae/models/nn/vo_ops.py","lineNumber":231,"sourceCode":"def resize(\n    x: torch.Tensor,\n    size: Optional[Any] = None,\n    scale_factor: Optional[list[float]] = None,\n    mode: str = \"bicubic\",\n    align_corners: Optional[bool] = False,\n) -> torch.Tensor:\n    if mode in {\"bilinear\", \"bicubic\"}:\n        return F.interpolate(\n            x,\n            size=size,\n            scale_factor=scale_factor,\n            mode=mode,\n            align_corners=align_corners,\n        )\n    elif mode in {\"nearest\", \"area\"}:\n        return F.interpolate(x, size=size, scale_factor=scale_factor, mode=mode)\n    else:\n        raise NotImplementedError(f\"resize(mode={mode}) not implemented.\")\n\n\ndef build_kwargs_from_config(config: dict, target_func: Callable) -> dict[str, Any]:\n    valid_keys = list(signature(target_func).parameters)\n    kwargs = {}\n    for key in config:\n        if key in valid_keys:\n            kwargs[key] = config[key]\n    return kwargs\n\n\nif __name__ == \"__main__\":\n    test_chunked_interpolate()\n","sourceCodeStart":213,"sourceCodeEnd":245,"githubUrl":"https://github.com/hpcaitech/Open-Sora/blob/7ad6a96a135feb81f755c84fb391818718f6beb2/opensora/models/dc_ae/models/nn/vo_ops.py#L213-L245","documentation":"The resize() helper in dc_ae's vo_ops only supports the bilinear/bicubic family (via antialiased interpolate) and 'nearest'/'area' modes. Any other mode string (e.g. 'linear', 'trilinear', 'nearest-exact', or a typo like 'neareast') reaches the else branch and raises NotImplementedError.","triggerScenarios":"Calling resize(x, mode=...) with a mode not in {bilinear, bicubic, nearest, area} (and whatever antialias variants the earlier branches accept), typically from a model forward pass where the resample mode comes from a config.","commonSituations":"Copying a resample mode string from another library (e.g. torch.nn.Upsample's 'linear'/'trilinear' or diffusers' 'nearest-exact') into an opensora dc_ae config; typos in YAML configs.","solutions":["Change mode to one of the supported values: 'nearest', 'area', 'bilinear', or 'bicubic'","Check the config/dict that supplies the mode string for typos","If you truly need another mode, call F.interpolate directly instead of this wrapper"],"exampleFix":"// before\ny = resize(x, scale_factor=2.0, mode=\"trilinear\")\n// after\ny = resize(x, scale_factor=2.0, mode=\"nearest\")","handlingStrategy":"validation","validationCode":"SUPPORTED = {\"bilinear\", \"bicubic\", \"nearest\", \"area\"}\nassert mode in SUPPORTED, f\"unsupported resize mode {mode!r}; choose from {SUPPORTED}\"","typeGuard":"def is_supported_resize_mode(mode: str) -> bool:\n    return mode in {\"bilinear\", \"bicubic\", \"nearest\", \"area\"}","tryCatchPattern":"try:\n    y = resize(x, mode=mode, ...)\nexcept NotImplementedError:\n    y = F.interpolate(x, mode=\"nearest\", ...)  # explicit fallback","preventionTips":["Centralize resample mode strings in one constants module","Reject unknown mode strings at config-load time","Keep mode names lowercase and short-form"],"tags":["pytorch","interpolation","not-implemented","config"],"backgroundTag":"unsupported-enum-value","analyzedSha":"7ad6a96a135feb81f755c84fb391818718f6beb2","analyzedAt":"2026-08-28T16:58:37.171Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}