Fix add tensor

This commit is contained in:
lucasdelimanogueira 2024-04-29 10:12:01 -03:00
parent acd8b1dba3
commit b5172b5bdb
3 changed files with 3 additions and 1 deletions

View file

@ -209,7 +209,7 @@ extern "C" {
}
if (strcmp(tensor1->device, tensor2->device) != 0) {
fprintf(stderr, "Tensors must be on the same device\n");
fprintf(stderr, "Tensors must be on the same device: %s and %s\n", &tensor1->device, &tensor2->device);
exit(1);
}

View file

@ -84,6 +84,8 @@ class Tensor:
Tensor._C.to_device.restype = None
Tensor._C.to_device(self.tensor, self.device_ctype)
return self
def __getitem__(self, indices):
if len(indices) != self.ndim:
raise ValueError("Number of indices must match the number of dimensions")