Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensor init refactor #175

Closed
wants to merge 6 commits into from
Closed

Tensor init refactor #175

wants to merge 6 commits into from

Conversation

Liamdoult
Copy link
Contributor

No description provided.

Not sure what the reason for this attribute is? I have removed it for
now.
Instead of our code checking supported data types, let numpy check if
the value can be converted to an ndarray. We only care if it is an
ndarray or not anyway.
Can't have GPUBuffer without GPU=True
Reduce a line as data will always have a dtype at this point.
data = np.array(data, dtype=np.float32)
elif GPU and isinstance(data, GPUBuffer):
self.gpu = True
self.gpu = False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_gpu gone?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default_gpu is never set True unless the user at runtime sets Tensor.default_gpu = True. Perhaps this was supposed to read from the system environment(export GPU=true)?

But that being said, setting default_gpu=True fails the tests anyway. This is due to the way .cuda_ handles conversions.

For this reason, I removed it and if support needs to be added again, we should refactor .cuda_ and .cuda().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also believe that it would be better in the future to add default GPU support in the kwargs of the __init__.

I.e.

def __init__(self, data, gpu=GPU, requires_grad=True):

Or something like that.

tinygrad/tensor.py Outdated Show resolved Hide resolved
@geohot
Copy link
Collaborator

geohot commented Dec 13, 2020

Did parts of this, removed default. Want to rebase and I'll merge?

@Liamdoult
Copy link
Contributor Author

Not required. See #196 for even better init.

@Liamdoult Liamdoult closed this Dec 14, 2020
@Liamdoult Liamdoult deleted the tensor-init-refactor branch December 16, 2020 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants