readme and .ane()

This commit is contained in:
George Hotz
2020-12-12 16:15:38 -08:00
parent da873cd556
commit bc5df477de
3 changed files with 14 additions and 6 deletions

View File

@@ -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

View File

@@ -2,7 +2,7 @@
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())

View File

@@ -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)