You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the code introduced in #43, we explicitly prevent boundary attacks from being performed on MPS accelerators. This is because of foolbox's dependencies, which at some point create a numpy array (numpy has a default dtype of float64) which is then passed to eagerpy. eagerpy then passes this numpy array to torch.torch.as_tensor(a, device=self.raw.device), where self.raw.device will be "mps" if the input tensor to foolbox was on MPS. torch.as_tensor will inherit the float64 dtype from numpy (and numpy's default cannot be changed), causing an error when it attempts to create a float64 dtype tensor on MPS.
Any of the following could act as solutions:
finding an alternative to foolbox that does not depend on eagerpy
numpy allowing the default dtype to be easily altered in a script
MPS becoming float64-friendly
foolbox allowing arguments to the numpy array's creation (possibly we could wrap our own class around foolbox)
In the code introduced in #43, we explicitly prevent boundary attacks from being performed on MPS accelerators. This is because of foolbox's dependencies, which at some point create a numpy array (numpy has a default dtype of float64) which is then passed to eagerpy. eagerpy then passes this numpy array to
torch.torch.as_tensor(a, device=self.raw.device)
, whereself.raw.device
will be"mps"
if the input tensor to foolbox was on MPS.torch.as_tensor
will inherit the float64 dtype from numpy (and numpy's default cannot be changed), causing an error when it attempts to create a float64 dtype tensor on MPS.Any of the following could act as solutions:
Links to the various steps to the final error:
ArrayQueue
class (class declaration is on the same page) being created in BoundaryAttack: https://github.com/bethgelab/foolbox/blob/12abe74e2f1ec79edb759454458ad8dd9ce84939/foolbox/attacks/boundary_attack.py#L152ArrayQueue.mean()
method which creates the numpy array in question then passes it to eagerpy: https://github.com/bethgelab/foolbox/blob/12abe74e2f1ec79edb759454458ad8dd9ce84939/foolbox/attacks/boundary_attack.py#L317from_numpy()
function: https://github.com/jonasrauber/eagerpy/blob/5b3b37a1e8c49aa3d34b3ed87a5075a20fd50f2f/eagerpy/framework.py#L205PyTorchTensor.from_numpy()
method which callstorch.as_tensor()
where the error occurs: https://github.com/jonasrauber/eagerpy/blob/master/eagerpy/tensor/pytorch.py#L288The text was updated successfully, but these errors were encountered: