Skip to content

compat: torchvision MNIST loaders require torch.frombuffer #325

Description

@lvyufeng

Description

Several PyTorch beginner tutorials that use torchvision.datasets.FashionMNIST now fail after the torchvision import chain has been fixed, because Candle does not expose torch.frombuffer.

Repro

import candle as torch
import torchvision.datasets.mnist as mnist

# Simplest API-level repro
buf = bytearray(range(16))
t = torch.frombuffer(buf, dtype=torch.uint8, offset=4)

Current result:

AttributeError: module 'candle' has no attribute 'frombuffer'

Real-world failure site

torchvision.datasets.mnist.read_sn3_pascalvincent_tensor() uses:

parsed = torch.frombuffer(bytearray(data), dtype=torch_type, offset=(4 * (nd + 1)))

This currently blocks these tutorials under Candle's torch compat mode:

  • quickstart_tutorial.py
  • data_tutorial.py
  • transforms_tutorial.py
  • optimization_tutorial.py

Root cause

Candle uses np.frombuffer(...) internally in several places, but does not expose a public torch.frombuffer-compatible API at the top level. Once torchvision import succeeds, MNIST dataset loading reaches this missing API and fails immediately.

Notes

This appears to be a general PyTorch compatibility gap, not a tutorial-specific issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions