readme and .ane()
MODIFY
README.md
README.md
@@ -89,7 +89,17 @@ from tinygrad.tensor import Tensor
### ANE Support?!?!
-So it doesn't work yet, but see the `ane` directory for code to use the Apple Neural Engine at a low level.
+If you all want to do is ReLU, you are in luck! You can do very fast ReLU (fastness not confirmed)
+
+Requires your Python to be signed with `ane/lib/sign_python.sh` to add the `com.apple.ane.iokit-user-access` entitlement.
+
+```python
+from tinygrad.tensor import Tensor
+
+a = Tensor([-2,-1,0,1,2]).ane()
+b = a.relu()
+print(b.cpu())
+```
### ImageNet inference

MODIFY
examples/use_ane.py
examples/use_ane.py
import numpy as np
from tinygrad.tensor import Tensor
-a = Tensor([-2,-1,0,1,2]).ane_()
+a = Tensor([-2,-1,0,1,2]).ane()
print(a.cpu())
b = a.relu()
print(b.cpu())

MODIFY
tinygrad/tensor.py
tinygrad/tensor.py
@@ -200,14 +200,12 @@ class Tensor:
else:
return self
- def ane_(self):
+ def ane(self):
assert(not self.gpu)
require_init_ane()
- self.device = Tensor.ANE
ndata = ane.tensor(self.shape)
ndata.data()[:] = self.data
- self.data = ndata
- return self
+ return Tensor(ndata)
def detach(self):
return Tensor(self.data, self.gpu)

readme and .ane()