Skip to main content

A PyTorch module wrapper for 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


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.17.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timod-0.0.17-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file timod-0.0.17.tar.gz.

File metadata

  • Download URL: timod-0.0.17.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for timod-0.0.17.tar.gz
Algorithm Hash digest
SHA256 6209fcefea9bbb4004f44a861bbdce7f600bcca31ce934c852e472b136796125
MD5 c85509b72c77d3224221900f6847b7c1
BLAKE2b-256 9e0d42937cdd523b5f75b91020687e6a810248e2ced7a384731420ea490aeddd

See more details on using hashes here.

File details

Details for the file timod-0.0.17-py3-none-any.whl.

File metadata

  • Download URL: timod-0.0.17-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.12.7

File hashes

Hashes for timod-0.0.17-py3-none-any.whl
Algorithm Hash digest
SHA256 099800374a85a1b6a87646857e1b2652dfe9b816b20f25f6d74f0d2c18abe8ab
MD5 140145f115b9378a7ca5f530f40d1d83
BLAKE2b-256 9a225077566ebf9991669f7ab815f5dbccd18ab4f1e49ec6b19cfe06722463f8

See more details on using hashes here.

Supported by

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