Allow string for `device` argument of AccuracyCalculator

Author: KevinMusgraveCreated Dec 21, 2024Updated Dec 21, 2024
Labelsenhancement

Calling AccuracyCalculator(device="cpu") instead of AccuracyCalculator(device=torch.device("cpu")) crashes with an unclear exception (AttributeError: 'str' object has no attribute 'type').

It'd be better to check if isinstance(device, str), and then do device=torch.device(device)

Source: KevinMusgrave/pytorch-metric-learning