Skip to content

add no_grad_mode context manager with decorator support - #3281

Closed
MaxWolf-01 wants to merge 1 commit into
tinygrad:masterfrom
MaxWolf-01:master
Closed

MaxWolf-01 wants to merge 1 commit into
tinygrad:masterfrom
MaxWolf-01:master

Conversation

@MaxWolf-01

Copy link
Copy Markdown
Contributor

Introduces no_grad_mode context manager which can be called like torch.no_grad:

with Tensor.no_grad_mode(): ...
# OR
@Tensor.no_grad_mode()
def f(): ...

Also adds ability to use Tensor.train() as a decorator:

@Tensor.train():
def f(): ...

@github-actions

Copy link
Copy Markdown
Contributor

Changes

Name                  Lines    Diff    Tokens/Line    Diff
------------------  -------  ------  -------------  ------
tinygrad/tensor.py      691      +5           22.3    -0.1


total lines changes: +5

@geohot

geohot commented Feb 9, 2024

Copy link
Copy Markdown
Collaborator

Does it need the _mode?

@geohot

geohot commented Feb 14, 2024

Copy link
Copy Markdown
Collaborator

No updates in a bit, going to close. I'm supportive of this if it has the right API

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.

2 participants