Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .JuliaFormatter.toml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/CompatHelper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "CompatHelper"

on:
schedule:
- cron: 0 0 * * *
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
Expand Down
13 changes: 8 additions & 5 deletions .github/workflows/FormatCheck.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
name: "Format Check"

on:
push:
branches:
- 'main'
tags: '*'
pull_request:
pull_request_target:
paths: ['**/*.jl']
types: [opened, synchronize, reopened, ready_for_review]

permissions:
contents: read
actions: write
pull-requests: write

jobs:
format-check:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
.vscode/
Manifest.toml
benchmark/*.json
dev/
docs/LocalPreferences.toml
docs/Manifest.toml
docs/build/
docs/src/index.md
examples/LocalPreferences.toml
test/LocalPreferences.toml
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ci:
skip: [julia-formatter]
skip: [runic]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -11,7 +11,7 @@ repos:
- id: end-of-file-fixer
exclude_types: [markdown] # incompatible with Literate.jl

- repo: "https://github.com/domluna/JuliaFormatter.jl"
rev: v2.1.6
- repo: https://github.com/fredrikekre/runic-pre-commit
rev: v2.0.1
hooks:
- id: "julia-formatter"
- id: runic
16 changes: 8 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TensorAlgebra"
uuid = "68bd88dc-f39d-4e12-b2ca-f046b68fcc6a"
authors = ["ITensor developers <[email protected]> and contributors"]
version = "0.4.3"
version = "0.4.4"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand All @@ -13,20 +13,20 @@ TensorProducts = "decf83d6-1968-43f4-96dc-fdb3fe15fc6d"
TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
TypeParameterAccessors = "7e5a90cf-f82e-492e-a09b-e3e26432c138"

[weakdeps]
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"

[extensions]
TensorAlgebraTensorOperationsExt = "TensorOperations"

[compat]
ArrayLayouts = "1.10.4"
BlockArrays = "1.7.2"
EllipsisNotation = "1.8.0"
LinearAlgebra = "1.10"
MatrixAlgebraKit = "0.2, 0.3, 0.4"
TensorProducts = "0.1.5"
TensorOperations = "5"
TensorProducts = "0.1.5"
TupleTools = "1.6.0"
TypeParameterAccessors = "0.2.1, 0.3, 0.4"
julia = "1.10"

[weakdeps]
TensorOperations = "6aa20fa7-93e2-5fca-9bc0-fbd0db3c71a2"

[extensions]
TensorAlgebraTensorOperationsExt = "TensorOperations"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ This step is only required once.
```julia
julia> using Pkg: Pkg

julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")
```
or:
```julia
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
julia> Pkg.Registry.add(url = "[email protected]:ITensor/ITensorRegistry.git")
```
if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.

Expand Down
12 changes: 6 additions & 6 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Ts = (Float64, ComplexF64)
algs = (TensorAlgebra.Matricize(),)

for alg in algs
alg_suite = contraction_suite[alg] = BenchmarkGroup()
for T in Ts
alg_suite[T] = BenchmarkGroup()
alg_suite = contraction_suite[alg] = BenchmarkGroup()
for T in Ts
alg_suite[T] = BenchmarkGroup()

for (i, line) in enumerate(eachline(CONTRACTIONS_PATH))
alg_suite[T][i] = generate_contract_benchmark(line; T, alg)
for (i, line) in enumerate(eachline(CONTRACTIONS_PATH))
alg_suite[T][i] = generate_contract_benchmark(line; T, alg)
end
end
end
end
126 changes: 63 additions & 63 deletions benchmark/contractions.jl
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
function extract_contract_labels(contraction::AbstractString)
symbolsC = match(r"C\[([^\]]*)\]", contraction)
labelsC = split(symbolsC.captures[1], ","; keepempty=false)
symbolsA = match(r"A\[([^\]]*)\]", contraction)
labelsA = split(symbolsA.captures[1], ","; keepempty=false)
symbolsB = match(r"B\[([^\]]*)\]", contraction)
labelsB = split(symbolsB.captures[1], ","; keepempty=false)
return labelsC, labelsA, labelsB
symbolsC = match(r"C\[([^\]]*)\]", contraction)
labelsC = split(symbolsC.captures[1], ","; keepempty = false)
symbolsA = match(r"A\[([^\]]*)\]", contraction)
labelsA = split(symbolsA.captures[1], ","; keepempty = false)
symbolsB = match(r"B\[([^\]]*)\]", contraction)
labelsB = split(symbolsB.captures[1], ","; keepempty = false)
return labelsC, labelsA, labelsB
end

function generate_contract_benchmark(
line::AbstractString; elt=Float64, alg=default_contract_alg(), do_alpha=true, do_beta=true
)
line_split = split(line, " & ")
@assert length(line_split) == 2 "Invalid line format:\n$line"
contraction, sizes = line_split
line::AbstractString; elt = Float64, alg = default_contract_alg(), do_alpha = true, do_beta = true
)
line_split = split(line, " & ")
@assert length(line_split) == 2 "Invalid line format:\n$line"
contraction, sizes = line_split

# extract labels
labelsC, labelsA, labelsB = map(Tuple, extract_contract_labels(contraction))
# pA, pB, pC = TensorOperations.contract_indices(
# tuple(labelsA...), tuple(labelsB...), tuple(labelsC...)
# )
# extract labels
labelsC, labelsA, labelsB = map(Tuple, extract_contract_labels(contraction))
# pA, pB, pC = TensorOperations.contract_indices(
# tuple(labelsA...), tuple(labelsB...), tuple(labelsC...)
# )

# extract sizes
subsizes = Dict{String,Int}()
for (label, sz) in split.(split(sizes, "; "; keepempty=false), Ref(":"))
subsizes[label] = parse(Int, sz)
end
szA = getindex.(Ref(subsizes), labelsA)
szB = getindex.(Ref(subsizes), labelsB)
szC = getindex.(Ref(subsizes), labelsC)
setup_tensors() = (rand(elt, szA...), rand(elt, szB...), rand(elt, szC...))
# extract sizes
subsizes = Dict{String, Int}()
for (label, sz) in split.(split(sizes, "; "; keepempty = false), Ref(":"))
subsizes[label] = parse(Int, sz)
end
szA = getindex.(Ref(subsizes), labelsA)
szB = getindex.(Ref(subsizes), labelsB)
szC = getindex.(Ref(subsizes), labelsC)
setup_tensors() = (rand(elt, szA...), rand(elt, szB...), rand(elt, szC...))

if do_alpha && do_beta
α, β = rand(elt, 2)
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB, $α, $β),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
elseif do_alpha
α = rand(elt)
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB, $α),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
elseif do_beta
β = rand(elt)
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB, true, $β),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
else
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
end
if do_alpha && do_beta
α, β = rand(elt, 2)
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB, $α, $β),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
elseif do_alpha
α = rand(elt)
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB, $α),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
elseif do_beta
β = rand(elt)
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB, true, $β),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
else
return @benchmarkable(
contract!($alg, C, $labelsC, A, $labelsA, B, $labelsB),
setup = ((A, B, C) = $setup_tensors()),
evals = 1
)
end
end

function compute_contract_ops(line::AbstractString)
line_split = split(line, " & ")
@assert length(line_split) == 2 "Invalid line format:\n$line"
_, sizes = line_split
line_split = split(line, " & ")
@assert length(line_split) == 2 "Invalid line format:\n$line"
_, sizes = line_split

# extract sizes
subsizes = Dict{String,Int}()
for (label, sz) in split.(split(sizes, "; "; keepempty=false), Ref("="))
subsizes[label] = parse(Int, sz)
end
return prod(collect(values(subsizes)))
# extract sizes
subsizes = Dict{String, Int}()
for (label, sz) in split.(split(sizes, "; "; keepempty = false), Ref("="))
subsizes[label] = parse(Int, sz)
end
return prod(collect(values(subsizes)))
end
24 changes: 13 additions & 11 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
using TensorAlgebra: TensorAlgebra
using Documenter: Documenter, DocMeta, deploydocs, makedocs

DocMeta.setdocmeta!(TensorAlgebra, :DocTestSetup, :(using TensorAlgebra); recursive=true)
DocMeta.setdocmeta!(
TensorAlgebra, :DocTestSetup, :(using TensorAlgebra); recursive = true
)

include("make_index.jl")

makedocs(;
modules=[TensorAlgebra],
authors="ITensor developers <[email protected]> and contributors",
sitename="TensorAlgebra.jl",
format=Documenter.HTML(;
canonical="https://itensor.github.io/TensorAlgebra.jl",
edit_link="main",
assets=["assets/favicon.ico", "assets/extras.css"],
),
pages=["Home" => "index.md", "Reference" => "reference.md"],
modules = [TensorAlgebra],
authors = "ITensor developers <[email protected]> and contributors",
sitename = "TensorAlgebra.jl",
format = Documenter.HTML(;
canonical = "https://itensor.github.io/TensorAlgebra.jl",
edit_link = "main",
assets = ["assets/favicon.ico", "assets/extras.css"],
),
pages = ["Home" => "index.md", "Reference" => "reference.md"],
)

deploydocs(;
repo="github.com/ITensor/TensorAlgebra.jl", devbranch="main", push_preview=true
repo = "github.com/ITensor/TensorAlgebra.jl", devbranch = "main", push_preview = true
)
16 changes: 8 additions & 8 deletions docs/make_index.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using TensorAlgebra: TensorAlgebra

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
```@raw html
<img class="display-light-only" src="assets/CCQ.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
<img class="display-dark-only" src="assets/CCQ-dark.png" width="20%" alt="Flatiron Center for Computational Quantum Physics logo."/>
```
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(TensorAlgebra), "examples", "README.jl"),
joinpath(pkgdir(TensorAlgebra), "docs", "src");
flavor=Literate.DocumenterFlavor(),
name="index",
postprocess=ccq_logo,
joinpath(pkgdir(TensorAlgebra), "examples", "README.jl"),
joinpath(pkgdir(TensorAlgebra), "docs", "src");
flavor = Literate.DocumenterFlavor(),
name = "index",
postprocess = ccq_logo,
)
16 changes: 8 additions & 8 deletions docs/make_readme.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@ using Literate: Literate
using TensorAlgebra: TensorAlgebra

function ccq_logo(content)
include_ccq_logo = """
include_ccq_logo = """
<picture>
<source media="(prefers-color-scheme: dark)" width="20%" srcset="docs/src/assets/CCQ-dark.png">
<img alt="Flatiron Center for Computational Quantum Physics logo." width="20%" src="docs/src/assets/CCQ.png">
</picture>
"""
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
content = replace(content, "{CCQ_LOGO}" => include_ccq_logo)
return content
end

Literate.markdown(
joinpath(pkgdir(TensorAlgebra), "examples", "README.jl"),
joinpath(pkgdir(TensorAlgebra));
flavor=Literate.CommonMarkFlavor(),
name="README",
postprocess=ccq_logo,
joinpath(pkgdir(TensorAlgebra), "examples", "README.jl"),
joinpath(pkgdir(TensorAlgebra));
flavor = Literate.CommonMarkFlavor(),
name = "README",
postprocess = ccq_logo,
)
6 changes: 3 additions & 3 deletions examples/README.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# # TensorAlgebra.jl
#
#
# [![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://itensor.github.io/TensorAlgebra.jl/stable/)
# [![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://itensor.github.io/TensorAlgebra.jl/dev/)
# [![Build Status](https://github.com/ITensor/TensorAlgebra.jl/actions/workflows/Tests.yml/badge.svg?branch=main)](https://github.com/ITensor/TensorAlgebra.jl/actions/workflows/Tests.yml?query=branch%3Amain)
Expand All @@ -22,13 +22,13 @@
```julia
julia> using Pkg: Pkg

julia> Pkg.Registry.add(url="https://github.com/ITensor/ITensorRegistry")
julia> Pkg.Registry.add(url = "https://github.com/ITensor/ITensorRegistry")
```
=#
# or:
#=
```julia
julia> Pkg.Registry.add(url="[email protected]:ITensor/ITensorRegistry.git")
julia> Pkg.Registry.add(url = "[email protected]:ITensor/ITensorRegistry.git")
```
=#
# if you want to use SSH credentials, which can make it so you don't have to enter your Github ursername and password when registering packages.
Expand Down
Loading
Loading