Skip to content
diku-dkPublic

About

Utilities for automatic differentiation in Futhark

Topics

Resources

Stars

3 stars

Watchers

8 watching

Forks

Latest commit

 

History

32 Commits

Folders and files

Repository files navigation

AD utilities for Futhark CI Documentation

This is a collection of small utilities for working with AD in Futhark.

See examples here.

Installation

$ futhark pkg add github.com/diku-dk/autodiff
$ futhark pkg sync

Usage example

> import "lib/github.com/diku-dk/autodiff/onehot"
> import "lib/github.com/diku-dk/autodiff/autodiff"
> grad64 f64.tanh 2.0
7.065082485316443e-2
> grad64 (grad64 f64.tanh) 2.0
-0.13621868742711296
> onehots onehot.(arr (pair f64 f32)) : [][3](f64,f32)
[[(1.0, 0.0), (0.0, 0.0), (0.0, 0.0)],
 [(0.0, 1.0), (0.0, 0.0), (0.0, 0.0)],
 [(0.0, 0.0), (1.0, 0.0), (0.0, 0.0)],
 [(0.0, 0.0), (0.0, 1.0), (0.0, 0.0)],
 [(0.0, 0.0), (0.0, 0.0), (1.0, 0.0)],
 [(0.0, 0.0), (0.0, 0.0), (0.0, 1.0)]]
> grad onehot.(arr f64) (map f64.sin) [0, 1, 2]
[[1.0, 0.0, -0.0],
 [0.0, 0.5403023058681398, -0.0],
 [0.0, 0.0, -0.4161468365471424]]

About

Utilities for automatic differentiation in Futhark

Topics

Resources

Stars

3 stars

Watchers

8 watching

Forks

Releases

Used by

Contributors

Languages