Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TensorFSTs.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FAST
FST
TensorFSTs.jl
Commits
817fe900
Verified
Commit
817fe900
authored
Jul 16, 2023
by
Lucas Ondel Yang
Browse files
Options
Downloads
Patches
Plain Diff
fixed test tensor sum
parent
239c93f9
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/semirings/semiringimpl.jl
+2
-4
2 additions, 4 deletions
src/semirings/semiringimpl.jl
test/runtests.jl
+1
-1
1 addition, 1 deletion
test/runtests.jl
test/sparsearrays.jl
+4
-7
4 additions, 7 deletions
test/sparsearrays.jl
with
7 additions
and
12 deletions
src/semirings/semiringimpl.jl
+
2
−
4
View file @
817fe900
...
...
@@ -19,9 +19,6 @@ end
Base
.
zero
(
::
Type
{
BoolSemiring
})
=
BoolSemiring
(
false
)
Base
.
one
(
::
Type
{
BoolSemiring
})
=
BoolSemiring
(
true
)
"""
struct LogSemiring{T,a} <: Semiring
val::T
...
...
@@ -42,7 +39,7 @@ end
⊗
(
x
::
LogSemiring
{
T
,
a
},
y
::
LogSemiring
{
T
,
a
})
where
{
T
,
a
}
=
LogSemiring
{
T
,
a
}(
x
.
val
+
y
.
val
)
⊘
(
x
::
LogSemiring
{
T
,
a
},
y
::
LogSemiring
{
T
,
a
})
where
{
T
,
a
}
=
LogSemiring
{
T
,
a
}(
x
.
val
-
y
.
val
)
Base
.
inv
(
x
::
LogSemiring
{
T
,
a
})
where
{
T
,
a
}
=
LogSemiring
{
T
,
a
}(
-
x
.
val
)
Base
.
zero
(
K
::
Type
{
<:
LogSemiring
{
T
,
a
}})
where
{
T
,
a
}
=
K
(
a
>
0
?
T
(
-
Inf
)
:
T
(
Inf
))
Base
.
zero
(
K
::
Type
{
<:
LogSemiring
{
T
,
a
}})
where
{
T
,
a
}
=
K
(
ifelse
(
a
>
0
,
T
(
-
Inf
)
,
T
(
Inf
))
)
Base
.
one
(
K
::
Type
{
<:
LogSemiring
{
T
}})
where
T
=
K
(
T
(
0
))
"""
...
...
@@ -97,3 +94,4 @@ Base.zero(K::Type{<:ProductSemiring{A,B}}) where A where B = K(zero(A), zero(B))
Base
.
one
(
K
::
Type
{
<:
ProductSemiring
{
A
,
B
}})
where
A
where
B
=
K
(
one
(
A
),
one
(
B
))
val
(
x
::
ProductSemiring
)
=
(
x
.
val1
,
x
.
val2
)
This diff is collapsed.
Click to expand it.
test/runtests.jl
+
1
−
1
View file @
817fe900
...
...
@@ -10,7 +10,7 @@ using Test
end
@testset
"Linear Algebra"
begin
include
(
"sparse
tensor
.jl"
)
include
(
"sparse
arrays
.jl"
)
end
@testset
"FST"
begin
...
...
This diff is collapsed.
Click to expand it.
test/sparse
tensor
.jl
→
test/sparse
arrays
.jl
+
4
−
7
View file @
817fe900
...
...
@@ -33,7 +33,7 @@ end
end
@testset
"sparse tensor"
begin
for
S
in
[
BoolSemiring
,
LogSemiring
{
Float32
,
1
},
ArcticSemiring
{
Float64
}]
for
S
in
[
BoolSemiring
,
LogSemiring
{
Float32
,
-
1
},
ArcticSemiring
{
Float64
}]
Y
=
[
zero
(
S
)
zero
(
S
)
zero
(
S
)
one
(
S
)
zero
(
S
)
one
(
S
)
⊕
one
(
S
)
...
...
@@ -57,12 +57,9 @@ end
@test
all
(
X
.==
Y
)
@test
all
(
sum
(
X
,
dims
=
(
1
,
2
))
.==
sum
(
Y
,
dims
=
(
1
,
2
)))
@test
all
(
sum
(
X
,
dims
=
(
2
,
3
))
.==
sum
(
Y
,
dims
=
(
2
,
3
)))
display
(
sum
(
X
,
dims
=
(
2
,
3
)))
display
(
sum
(
Y
,
dims
=
(
2
,
3
)))
display
(
all
(
sum
(
X
,
dims
=
(
2
,
3
))
.==
sum
(
Y
,
dims
=
(
2
,
3
))))
@test
all
(
sum
(
X
,
dims
=
(
3
,
4
))
.==
sum
(
Y
,
dims
=
(
3
,
4
)))
@test
all
(
val
.
(
sum
(
X
,
dims
=
(
1
,
2
)))
.
≈
val
.
(
sum
(
Y
,
dims
=
(
1
,
2
))))
@test
all
(
val
.
(
sum
(
X
,
dims
=
(
2
,
3
)))
.
≈
val
.
(
sum
(
Y
,
dims
=
(
2
,
3
))))
@test
all
(
val
.
(
sum
(
X
,
dims
=
(
3
,
4
)))
.
≈
val
.
(
sum
(
Y
,
dims
=
(
3
,
4
))))
XI
,
XJ
,
XK
,
XL
,
XV
=
findnz
(
X
)
@test
Set
(
XI
)
==
Set
(
I
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment