TaichIMODule, a pytorch module wrapper for differentiable Taichi kernels.
Project description
timod
TaichIMODule, a tiny pytorch module wrapper for differentiable Taichi kernels.
Install
pip install timod
Usage
Given a taichi kernel my_kernel with input and output tensors typed ti.types.ndarray():
from timod import TaichiKernelModule
# Output tensors specifications (since they will be created on the fly)
output_specs = {
'out1':(<shape>, <dtype>, <needs gradients ?>),
'out2':(<shape>, <dtype>, <needs gradients ?>)
...}
# Module creation
taichi_module = TaichiKernelModule(my_kernel, output_specs)
# Kernel input args (torch tensors and scalars)
in1 = ...
in2 = ...
...
# Module call
out1, out2, ... = taichi_module(in1, in2, ...) # kwargs of the taichi kernel inputs are supported
# Loss function
loss = my_loss(out1, out2, ...)
# Gradient computation
loss.backward()
# Gradient descent
lr = 1e-3
in1 -= lr * in1.grad
in2 -= lr * in2.grad
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
timod-0.0.1.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
timod-0.0.1-py3-none-any.whl
(4.6 kB
view details)
File details
Details for the file timod-0.0.1.tar.gz.
File metadata
- Download URL: timod-0.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3de3ca26d65c52f6fea866d056fac46550e53a707eb53a360b7b340540993b3
|
|
| MD5 |
e056b9a1e2e3e7328fb3ba6668a20fe6
|
|
| BLAKE2b-256 |
d25bfe4b026ea8968eb5a80228082fbb7832feb68021495ccf9ebf63d9b77283
|
File details
Details for the file timod-0.0.1-py3-none-any.whl.
File metadata
- Download URL: timod-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
608e7f8a015104afecc3f352c573a1759582d65265153e1cf37a491eedca4a7a
|
|
| MD5 |
2a61669a20a5af6361a1795dbd8f2bf2
|
|
| BLAKE2b-256 |
702cf64821d192f1f1fb54116422df054958b6794b6981fa042de328d1abd892
|