mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-08 14:43:57 -05:00
readme and .ane()
This commit is contained in:
12
README.md
12
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
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user