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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
38 changes: 23 additions & 15 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
name: CI
on:
- push
- pull_request
push:
branches:
- master
tags: ['*']
pull_request:
workflow_dispatch:
concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
permissions: # needed to allow julia-actions/cache to proactively delete old caches that it has created
actions: write
contents: read
strategy:
fail-fast: false
matrix:
Expand All @@ -17,22 +30,17 @@ jobs:
arch:
- x64
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v5
with:
coverage: false
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
slug: TensorBFS/TropicalGEMM.jl
16 changes: 16 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ on:
types:
- created
workflow_dispatch:
inputs:
lookback:
default: 3
permissions:
actions: read
checks: read
contents: write
deployments: read
issues: read
discussions: read
packages: read
pages: read
pull-requests: read
repository-projects: read
security-events: read
statuses: read
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
Expand Down
13 changes: 9 additions & 4 deletions src/gemm.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const BlasSemiringTypes{T} = Union{Tropical{T}, TropicalMinPlus{T}, TropicalMaxMul{T}}
const BlasSemiringTypes{T} = Union{Tropical{T}, TropicalMinPlus{T}, TropicalMaxMul{T}, TropicalMaxMin{T}, TropicalBitwise{T}}
basetype(::Type{<:Tropical}) = Tropical
basetype(::Type{<:TropicalMinPlus}) = TropicalMinPlus
basetype(::Type{<:TropicalMaxMul}) = TropicalMaxMul
basetype(::Type{<:TropicalMaxMin}) = TropicalMaxMin
basetype(::Type{<:TropicalBitwise}) = TropicalBitwise

# implement neginf for Vec and VecUnroll
TropicalNumbers.neginf(::Type{Vec{N, T}}) where {N,T} = Vec(ntuple(i->neginf(T), N)...)
Expand All @@ -10,7 +12,7 @@ TropicalNumbers.neginf(::Type{VecUnroll{N,W,T,V}}) where {N,W,T,V} = VecUnroll(n
LoopVectorization.check_args(::Type{T}, ::Type{T}) where T<:BlasSemiringTypes = true
LoopVectorization.check_type(::Type{<:BlasSemiringTypes{T}}) where {T} = LoopVectorization.check_type(T)

for TT in [:Tropical, :TropicalMaxMul, :TropicalMinPlus]
for TT in [:Tropical, :TropicalMinPlus, :TropicalMaxMul, :TropicalMaxMin, :TropicalBitwise]
@eval @inline function VectorizationBase._vstore!(
ptr::AbstractStridedPointer, vu::$TT{<:VecUnroll{Nm1,W}}, u::Unroll{AU,F,N,AV,W}, a::A, s::S, nt::NT, si::StaticInt{RS}
) where {A<:StaticBool,S<:StaticBool,NT<:StaticBool,RS,AU,F,N,AV,W,Nm1}
Expand Down Expand Up @@ -101,7 +103,8 @@ for TP in [:NativeTypes, :AbstractSIMD]
for (TT, F0, F1) in [
(:Tropical, :max_fast, :add_fast),
(:TropicalMinPlus, :min_fast, :add_fast),
(:TropicalMaxMul, :max_fast, :mul_fast)
(:TropicalMaxMul, :max_fast, :mul_fast),
(:TropicalMaxMin, :max_fast, :min_fast),
]
@eval @inline function Base.fma(x::$TT{V}, y::$TT{V}, z::$TT{V}) where {V<:$TP}
$TT(Base.FastMath.$F0(content(z), Base.FastMath.$F1(content(x), content(y))))
Expand Down Expand Up @@ -136,7 +139,9 @@ end
for (TT, F0, F1, F2, F3, F4) in [
(:Tropical, :max_fast, :collapse_max, :contract_max, :reduced_max, :vmaximum),
(:TropicalMinPlus, :min_fast, :collapse_min, :contract_min, :reduced_min, :vminimum),
(:TropicalMaxMul, :max_fast, :collapse_max, :contract_max, :reduced_max, :vmaximum)
(:TropicalMaxMul, :max_fast, :collapse_max, :contract_max, :reduced_max, :vmaximum),
(:TropicalMaxMin, :max_fast, :collapse_max, :contract_max, :reduced_max, :vmaximum),
(:TropicalBitwise, :|, :collape_or, :contract_or, :reduced_any, :vany),
]
@eval @inline Base.FastMath.add_fast(a::$TT, b::$TT) = $TT(Base.FastMath.$F0(content(a), content(b)))

Expand Down
10 changes: 7 additions & 3 deletions test/gemm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,15 @@ end
@test !any(isnan, res)
end

@testset "MinPlus and MaxMul" begin
@testset "MinPlus, MaxMul, MaxMin, and Bitwise" begin
for (T1,T2) in [
[TropicalMinPlusF64, TropicalMinPlusF64],
[TropicalMinPlus{Int64}, TropicalMinPlus{Int64}],
[TropicalMaxMulF64, TropicalMaxMulF64], [TropicalMaxMul{Int64}, TropicalMaxMul{Int64}]
[TropicalMaxMulF64, TropicalMaxMulF64],
[TropicalMaxMul{Int64}, TropicalMaxMul{Int64}],
[TropicalMaxMinF64, TropicalMaxMinF64],
[TropicalMaxMinI64, TropicalMaxMinI64],
[TropicalBitwiseI64, TropicalBitwiseI64],
]
for n in [0, 1, 4, 40]
A = _rand(T1, n, n)
Expand All @@ -124,4 +128,4 @@ end
end
end
end
end
end