one-fx
A toolkit for developers to simplify the transformation of nn.Module instances. It is modified from Pytorch.fx.
install
pip install onefx
Oneflow has now add one-fx as default dependency. You can also install oneflow and use it as oneflow.fx.
usage
The following code shows the basic usage. For more examples, please refer to https://github.com/Oneflow-Inc/one-fx/tree/main/onefx/exmaples.
import oneflow
import onefx as fx
class MyModule(oneflow.nn.Module):
def __init__(self, do_activation : bool = False):
super().__init__()
self.do_activation = do_activation
self.linear = oneflow.nn.Linear(512, 512)
def forward(self, x):
x = self.linear(x)
x = oneflow.relu(x)
y = oneflow.ones([2, 3])
if self.do_activation:
x = oneflow.relu(x)
return y
without_activation = MyModule(do_activation=False)
with_activation = MyModule(do_activation=True)
traced_without_activation = onefx.symbolic_trace(without_activation)
print(traced_without_activation.code)
"""
def forward(self, x):
linear = self.linear(x); x = None
return linear
"""
traced_with_activation = onefx.symbolic_trace(with_activation)
print(traced_with_activation.code)
"""
wrap("oneflow._oneflow_internal._C.relu")
def forward(self, x):
linear = self.linear(x); x = None
relu = oneflow._oneflow_internal._C.relu(linear); linear = None
return relu
"""
version map
| oneflow | one-fx |
|---|---|
| 0.9.0 | 0.0.2 |
Metadata
Release files for onefx 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| onefx-0.0.3.tar.gz | 147.3 kB | Without provenance | Details for onefx-0.0.3.tar.gz |
Release files / onefx-0.0.3.tar.gz
| Download URL | onefx-0.0.3.tar.gz |
|---|---|
| Size | 147.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d3f3f816891cdfdb6d69e4a78b72d5cafd7d40e165ce419f89f855f47a3dbe34
|
|
BLAKE2b-256 checksum How to use checksums |
3cc42dc5fd8ab613d32e24d54204b4d448b315fa50e5f1ce3197938f2219fa09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Security for onefx 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.