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

dev(hansug): add support for torch integration #79

Merged
merged 3 commits into from
Feb 27, 2023
Merged

dev(hansug): add support for torch integration #79

merged 3 commits into from
Feb 27, 2023

Conversation

HansBug
Copy link
Member

@HansBug HansBug commented Feb 27, 2023

Description

import numpy as np
import torch

from treevalue import FastTreeValue, register_treevalue_class


class MyTreeValue(FastTreeValue):
    pass


register_treevalue_class(MyTreeValue)

data = {
    'a': np.random.randint(0, 10, (2, 3)),
    'b': {
        'x': 233,
        'y': np.random.randn(2, 3)
    }
}
t = MyTreeValue(data)

if __name__ == '__main__':
    print(t)

    v1, spec = torch.utils._pytree.tree_flatten(t)
    print(v1)
    print(spec)

    tt = torch.utils._pytree.tree_unflatten(v1, spec)
    print(tt)

Check List

  • merge the latest version source branch/repo, and resolve all the conflicts
  • pass style check
  • pass all the tests

@HansBug HansBug requested a review from PaParaZz1 February 27, 2023 07:20
@HansBug HansBug self-assigned this Feb 27, 2023
@codecov
Copy link

codecov bot commented Feb 27, 2023

Codecov Report

Merging #79 (adc645e) into main (ac90658) will increase coverage by 0.09%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main      #79      +/-   ##
==========================================
+ Coverage   98.95%   99.04%   +0.09%     
==========================================
  Files          39       42       +3     
  Lines        2587     2624      +37     
==========================================
+ Hits         2560     2599      +39     
+ Misses         27       25       -2     
Flag Coverage Δ
unittests 99.04% <100.00%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
treevalue/tree/integration/__init__.py 100.00% <100.00%> (ø)
treevalue/tree/integration/base.pyx 100.00% <100.00%> (ø)
treevalue/tree/integration/cjax.pyx 100.00% <100.00%> (+5.55%) ⬆️
treevalue/tree/integration/ctorch.pyx 100.00% <100.00%> (ø)
treevalue/tree/integration/torch.py 100.00% <100.00%> (ø)
treevalue/tree/integration/jax.py 100.00% <0.00%> (+7.14%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@HansBug HansBug merged commit 704a830 into main Feb 27, 2023
@HansBug HansBug deleted the dev/torch branch February 27, 2023 10:31
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