Skip to content

Commit 442adbb

Browse files
authored
Merge pull request #137 from lkdvos/v4
Version 4 (WIP)
2 parents 20783f3 + 4df9b05 commit 442adbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4310
-3197
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
version:
13-
- '1.4' # minimal version
1413
- '1.6' # LTS version
1514
- '1' # automatically expands to the latest stable 1.x release of Julia
1615
os:

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
- uses: actions/checkout@v2
1313
- uses: julia-actions/setup-julia@latest
1414
with:
15-
version: '1.6'
15+
version: '1'
1616
- name: Install dependencies
1717
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
1818
- name: Build and deploy

.github/workflows/format_check.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: format-check
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- 'release-'
8+
tags: '*'
9+
pull_request:
10+
11+
jobs:
12+
build:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
julia-version: [1]
17+
julia-arch: [x86]
18+
os: [ubuntu-latest]
19+
steps:
20+
- uses: julia-actions/setup-julia@latest
21+
with:
22+
version: ${{ matrix.julia-version }}
23+
24+
- uses: actions/checkout@v1
25+
- name: Install JuliaFormatter and format
26+
# This will use the latest version by default but you can set the version like so:
27+
#
28+
# julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter", version="0.13.0"))'
29+
run: |
30+
julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))'
31+
julia -e 'using JuliaFormatter; format(".", verbose=true)'
32+
- name: Format check
33+
run: |
34+
julia -e '
35+
out = Cmd(`git diff --name-only`) |> read |> String
36+
if out == ""
37+
exit(0)
38+
else
39+
@error "Some files have not been formatted !!!"
40+
write(stdout, out)
41+
exit(1)
42+
end'

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.jl.cov
22
*.jl.*.cov
33
*.jl.mem
4+
Manifest.toml

LICENSE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
The TensorOperations.jl package is licensed under the MIT "Expat" License:
22

33
> Copyright (c) 2014: Jutho Haegeman.
4-
>
4+
>
55
> Permission is hereby granted, free of charge, to any person obtaining
66
> a copy of this software and associated documentation files (the
77
> "Software"), to deal in the Software without restriction, including
88
> without limitation the rights to use, copy, modify, merge, publish,
99
> distribute, sublicense, and/or sell copies of the Software, and to
1010
> permit persons to whom the Software is furnished to do so, subject to
1111
> the following conditions:
12-
>
12+
>
1313
> The above copyright notice and this permission notice shall be
1414
> included in all copies or substantial portions of the Software.
15-
>
15+
>
1616
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1717
> EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1818
> MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

Project.toml

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,49 @@
11
name = "TensorOperations"
22
uuid = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"
33
authors = ["Jutho Haegeman"]
4-
version = "3.2.5"
4+
version = "4.0.0"
55

66
[deps]
7+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
8+
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
79
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
10+
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
811
Strided = "5e0ebb24-38b0-5f93-81fe-25c709ecae67"
912
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
10-
LRUCache = "8ac3fa9e-de4c-5943-b1dc-09c6b5f20637"
13+
VectorInterface = "409d34a3-91d5-4945-b6ec-7529ddf182d8"
14+
cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1"
15+
16+
[weakdeps]
17+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
1118
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
12-
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
19+
cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1"
20+
21+
[extensions]
22+
TensorOperationsChainRulesCoreExt = "ChainRulesCore"
23+
TensorOperationscuTENSORExt = "cuTENSOR"
1324

1425
[compat]
15-
Strided = "1"
16-
TupleTools = "1.1"
26+
Aqua = "0.6"
27+
CUDA = "4"
28+
ChainRulesCore = "1"
29+
DynamicPolynomials = "0.5"
1730
LRUCache = "1"
18-
Requires = "0.5,1"
19-
CUDA = "1,2,3"
20-
julia = "1.4"
31+
Requires = "1"
32+
Strided = "2"
33+
TupleTools = "1.1"
34+
VectorInterface = "0.2"
35+
cuTENSOR = "1"
36+
julia = "1.6"
2137

2238
[extras]
39+
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
40+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
41+
DynamicPolynomials = "7c1d4256-1411-5781-91ec-d7bc3513ac07"
42+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
2343
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
2444
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
45+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
46+
cuTENSOR = "011b41b2-24ef-40a8-b3eb-fa098493e9e1"
2547

2648
[targets]
27-
test = ["Test", "Random"]
49+
test = ["Test", "Random", "DynamicPolynomials", "Zygote", "CUDA", "cuTENSOR", "Aqua", "Logging"]

README.md

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,75 @@
11
<img src="https://github.com/Jutho/TensorOperations.jl/blob/master/docs/src/assets/logo.svg" width="150">
2-
32
# TensorOperations.jl
4-
53
Fast tensor operations using a convenient Einstein index notation.
64

7-
| **Documentation** | **Build Status** |
8-
|:-----------------:|:----------------:|
9-
| [![][docs-stable-img]][docs-stable-url] [![][docs-dev-img]][docs-dev-url] | [![CI][ci-img]][ci-url] [![CI (Julia nightly)][ci-julia-nightly-img]][ci-julia-nightly-url] [![][codecov-img]][codecov-url] |
10-
11-
| **Digital Object Identifier** | **Downloads** |
12-
|:-----------------------------:|:-------------:|
13-
[![DOI][doi-img]][doi-url] | [![TensorOperations Downloads][genie-img]][genie-url]
14-
15-
[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg
16-
[docs-dev-url]: https://jutho.github.io/TensorOperations.jl/latest
17-
185
[docs-stable-img]: https://img.shields.io/badge/docs-stable-blue.svg
196
[docs-stable-url]: https://jutho.github.io/TensorOperations.jl/stable
7+
[docs-dev-img]: https://img.shields.io/badge/docs-dev-blue.svg
8+
[docs-dev-url]: https://jutho.github.io/TensorOperations.jl/latest
9+
[ci-img]: https://github.com/Jutho/TensorOperations.jl/workflows/CI/badge.svg
10+
[ci-url]:
11+
https://github.com/Jutho/TensorOperations.jl/actions?query=workflow%3ACI
12+
[ci-julia-nightly-img]:
13+
https://github.com/Jutho/TensorOperations.jl/workflows/CI%20(Julia%20nightly)/badge.svg
14+
[ci-julia-nightly-url]:
15+
https://github.com/Jutho/TensorOperations.jl/actions?query=workflow%3A%22CI+%28Julia+nightly%29%22
16+
[codecov-img]:
17+
https://codecov.io/gh/Jutho/TensorOperations.jl/branch/master/graph/badge.svg
18+
[codecov-url]: https://codecov.io/gh/Jutho/TensorOperations.jl
19+
[doi-img]: https://zenodo.org/badge/DOI/10.5281/zenodo.3245497.svg
20+
[doi-url]: https://doi.org/10.5281/zenodo.3245497
21+
[downloads-img]:
22+
https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/TensorOperations
23+
[downloads-url]: https://pkgs.genieframework.com?packages=TensorOperations
2024

21-
[github-img]: https://github.com/Jutho/TensorOperations.jl/workflows/CI/badge.svg
22-
[github-url]: https://github.com/Jutho/TensorOperations.jl/actions?query=workflow%3ACI
25+
| **Documentation** | **Build Status** |
26+
| :-----------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------: |
27+
| [![][docs-stable-img]][docs-stable-url] [![][docs-dev-img]][docs-dev-url] | [![CI][ci-img]][ci-url] [![CI (Julia nightly)][ci-julia-nightly-img]][ci-julia-nightly-url] [![][codecov-img]][codecov-url] |
2328

24-
[ci-img]: https://github.com/Jutho/TensorOperations.jl/workflows/CI/badge.svg
25-
[ci-url]: https://github.com/Jutho/TensorOperations.jl/actions?query=workflow%3ACI
29+
| **Digital Object Identifier** | **Downloads** |
30+
| :---------------------------: | :-----------------------------------------------------------: |
31+
| [![DOI][doi-img]][doi-url] | [![TensorOperations Downloads][downloads-img]][downloads-url] |
2632

27-
[ci-julia-nightly-img]: https://github.com/Jutho/TensorOperations.jl/workflows/CI%20(Julia%20nightly)/badge.svg
28-
[ci-julia-nightly-url]: https://github.com/Jutho/TensorOperations.jl/actions?query=workflow%3A%22CI+%28Julia+nightly%29%22
33+
## What's new in v4
2934

30-
[codecov-img]: https://codecov.io/gh/Jutho/TensorOperations.jl/branch/master/graph/badge.svg
31-
[codecov-url]: https://codecov.io/gh/Jutho/TensorOperations.jl
35+
- Moved CUDA to a package extension, to avoid unnecessary dependencies for Julia versions >= 1.9
3236

33-
[doi-img]: https://zenodo.org/badge/DOI/10.5281/zenodo.3245497.svg
34-
[doi-url]: https://doi.org/10.5281/zenodo.3245497
37+
- The cache for temporaries has been removed, but support for something similar is now provided through explicit allocating and freeing calls within the macro.
3538

36-
[genie-img]: https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/TensorOperations
37-
[genie-url]: https://pkgs.genieframework.com?packages=TensorOperations
39+
- The interface for custom types has been changed and thoroughly documented, making it easier to know what to implement. This has as a consequence that more general element types of tensors are now also possible.
3840

39-
## What's new in v3
41+
- There is a new interface to work with backends, to allow for dynamic switching between different implementations of the TensorOperations interface.
4042

41-
* Switched to CUDA.jl instead of CuArrays.jl, which effectively restricts support to
42-
Julia 1.4 and higher.
43-
* The default cache size for intermediate results is now the minimum of either 4GB or one
44-
quarter of your total memory (obtained via `Sys.total_memory()`). Furthermore, the
45-
structure (i.e. `size`) and `eltype` of the temporaries is now also used as lookup key
46-
in the LRU cache, such that you can run the same code on different objects with
47-
different sizes or element types, without constantly having to reallocate the
48-
temporaries. Finally, the task rather than `threadid` is used to make the cache
49-
compatible with concurrency at any level.
43+
- The `@tensor` macro now accepts keyword arguments to facilitate a variety of options that help with debugging, contraction cost and type wrapping.
5044

51-
As a consequence, different objects for the same temporary location can now be cached,
52-
such that the cache can grow out of size quickly. Once the cache is not able to hold all
53-
the temporary objects needed for your simulation, it might actually deteriorate
54-
perfomance, and you might be better off disabling the cache alltogether with
55-
`TensorOperations.disable_cache()`.
45+
- Some support for Automatic Differentiation has been added by adding reverse-mode chainrules.
5646

57-
> **WARNING:** TensorOperations 3.0 contains breaking changes if you did implement support
58-
for custom array / tensor types by overloading `checked_similar_from_indices` etc.
47+
> **WARNING:** TensorOperations 4.0 contains breaking changes and is in general incompatible with previous versions.
5948
6049
### Code example
61-
TensorOperations.jl is mostly used through the `@tensor` macro which allows one to express
62-
a given operation in terms of
63-
[index notation](https://en.wikipedia.org/wiki/Abstract_index_notation) format, a.k.a.
64-
[Einstein notation](https://en.wikipedia.org/wiki/Einstein_notation)
50+
51+
TensorOperations.jl is mostly used through the `@tensor` macro which allows one
52+
to express a given operation in terms of
53+
[index notation](https://en.wikipedia.org/wiki/Abstract_index_notation) format,
54+
a.k.a. [Einstein notation](https://en.wikipedia.org/wiki/Einstein_notation)
6555
(using Einstein's summation convention).
6656

6757
```julia
6858
using TensorOperations
69-
α=randn()
70-
A=randn(5,5,5,5,5,5)
71-
B=randn(5,5,5)
72-
C=randn(5,5,5)
73-
D=zeros(5,5,5)
59+
α = randn()
60+
A = randn(5, 5, 5, 5, 5, 5)
61+
B = randn(5, 5, 5)
62+
C = randn(5, 5, 5)
63+
D = zeros(5, 5, 5)
7464
@tensor begin
75-
D[a,b,c] = A[a,e,f,c,f,g]*B[g,b,e] + α*C[c,a,b]
76-
E[a,b,c] := A[a,e,f,c,f,g]*B[g,b,e] + α*C[c,a,b]
65+
D[a, b, c] = A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b]
66+
E[a, b, c] := A[a, e, f, c, f, g] * B[g, b, e] + α * C[c, a, b]
7767
end
7868
```
7969

80-
In the second to last line, the result of the operation will be stored in the preallocated
81-
array `D`, whereas the last line uses a different assignment operator `:=` in order to
82-
define and allocate a new array `E` of the correct size. The contents of `D` and `E` will
83-
be equal.
70+
In the second to last line, the result of the operation will be stored in the
71+
preallocated array `D`, whereas the last line uses a different assignment
72+
operator `:=` in order to define and allocate a new array `E` of the correct
73+
size. The contents of `D` and `E` will be equal.
8474

8575
For more information, please see the documentation.

docs/make.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ makedocs(; modules=[TensorOperations],
55
sitename="TensorOperations.jl",
66
authors="Jutho Haegeman",
77
format=Documenter.HTML(; prettyurls=get(ENV, "CI", nothing) == "true"),
8-
pages=["Home" => ["index.md",
9-
"indexnotation.md",
10-
"functions.md",
11-
"cache.md",
12-
"implementation.md"]])
8+
pages=["Home" => "index.md",
9+
"Manual" => ["man/indexnotation.md",
10+
"man/functions.md",
11+
"man/interface.md",
12+
"man/implementation.md",
13+
"man/autodiff.md"],
14+
"Index" => "index/index.md"])
1315

1416
# Documenter can also automatically deploy documentation to gh-pages.
1517
# See "Hosting Documentation" and deploydocs() in the Documenter manual

docs/src/cache.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

docs/src/functions.md

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)