Skip to main content

Torch support of potc.

Project description

potc-torch

PyPI PyPI - Python Version Loc Comments

Code Test Badge Creation Package Release codecov

GitHub stars GitHub forks GitHub commit activity GitHub issues GitHub pulls Contributors GitHub license

Potc support for torch module.

Installation

You can simply install it with pip command line from the official PyPI site.

pip install potc-torch

Quick Start

After potc-torch is installed, you can convert the torch objects into executable source code without any additional operations.

We can create a python script which is named test_simple.py

import torch
from potc import transvars

a = torch.randn(2, 3)
b = torch.randint(-5, 10, (3, 4))
bs = b.size()
bd = b.device
if __name__ == '__main__':
    _code = transvars(
        {'a': a, 'b': b, 'bs': bs, 'bd': bd},
        reformat='pep8',
    )
    print(_code)

The output result should be like this (may be slightly different because of the usage of torch.randn and torch.randint)

import torch

__all__ = ['a', 'b', 'bd', 'bs']
a = torch.as_tensor(
    [[0.6224261522293091, 0.4725508689880371, 0.45328783988952637],
     [-0.5855962634086609, 0.4898407459259033, 0.4769541621208191]],
    dtype=torch.float32)
b = torch.as_tensor([[2, 7, 4, -3], [-2, 4, 8, 1], [7, -5, 3, 6]],
                    dtype=torch.long)
bd = torch.device('cpu')
bs = torch.Size([3, 4])

And, you can use the following CLI command to get the same output results as above.

potc export -v 'test_simple.a' -v 'test_simple.b*'

Contributing

We appreciate all contributions to improve potc and potc-torch, both logic and system designs. Please refer to CONTRIBUTING.md for more guides.

License

potc-torch released under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

potc-torch-0.0.1.tar.gz (8.2 kB view hashes)

Uploaded Source

Built Distribution

potc_torch-0.0.1-py3-none-any.whl (9.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page