Files
tinygrad/examples/benchmark.py
iainwo 56d44637f3 fixed pylint, formatted python files iwth cblack on localhost (#204)
* fixed pylint, formatted python files iwth cblack on localhost

* Revert "fixed pylint, formatted python files iwth cblack on localhost"

This reverts commit 07e2b88466.

* dedented 4-spaces added linter

Co-authored-by: Iain Wong <iainwong@outlook.com>
2020-12-17 14:37:31 -08:00

23 lines
571 B
Python

#!/usr/bin/env python3
import numpy as np
from tinygrad.tensor import Tensor
import time
# Tensor has max size of 0x4000 for now
ba = Tensor(np.random.normal(size=(0x4000,)))
for dev in ["CPU", "GPU", "ANE"]:
if dev == "GPU":
baa = ba.cuda()
elif dev == "ANE":
baa = ba.ane()
else:
baa = ba
for i in range(3):
st = time.time()
boaa = baa.relu()
et = time.time()
if i == 2:
print("%s can do at least %.2f MEGAReLUs/sec" % (dev, (np.prod(boaa.shape)/1e6)/(et-st)))
# decently reliable
assert(np.all(boaa.cpu().data >= 0))