Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Core Modules
dune-common
Commits
d26b7b6a
Commit
d26b7b6a
authored
6 months ago
by
Simon Praetorius
Browse files
Options
Downloads
Patches
Plain Diff
Extend the tensordot testsuite
parent
d6b4d8fb
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/common/test/tensordottest.cc
+29
-4
29 additions, 4 deletions
dune/common/test/tensordottest.cc
with
29 additions
and
4 deletions
dune/common/test/tensordottest.cc
+
29
−
4
View file @
d26b7b6a
...
...
@@ -26,8 +26,7 @@ int main(int argc, char** argv)
auto
fTensor2
=
Dune
::
Tensor
<
double
,
2
,
2
>
{};
auto
fTensor3
=
Dune
::
Tensor
<
double
,
2
,
2
,
2
>
{};
// dynamic tensors
// test dynamic tensors
{
auto
dScalar
=
tensordot
<
0
>
(
dTensor0
,
dTensor0
);
testSuite
.
check
(
dScalar
.
rank
()
==
0
);
...
...
@@ -98,8 +97,7 @@ int main(int argc, char** argv)
testSuite
.
check
(
dTen2
.
extent
(
3
)
==
2
);
}
// mixed static/dynamic tensors
// test mixed static/dynamic tensors
{
auto
dScalar
=
tensordot
<
0
>
(
fTensor0
,
dTensor0
);
testSuite
.
check
(
dScalar
.
rank
()
==
0
);
...
...
@@ -170,6 +168,33 @@ int main(int argc, char** argv)
testSuite
.
check
(
dTen2
.
extent
(
3
)
==
2
);
}
// test interaction with TensorSpan
{
auto
dMat0
=
tensordot
<
1
>
(
fTensor2
,
dTensor2
.
toTensorSpan
());
auto
dMat1
=
tensordot
<
1
>
(
fTensor2
.
toTensorSpan
(),
dTensor2
);
auto
dMat2
=
tensordot
<
1
>
(
fTensor2
.
toTensorSpan
(),
dTensor2
.
toTensorSpan
());
}
// test output-tensor
{
tensordotOut
<
1
>
(
dTensor2
,
dTensor2
,
fTensor2
);
tensordotOut
<
1
>
(
fTensor2
,
fTensor2
,
dTensor2
);
}
// test arbitrary index contractions
{
auto
dScalar
=
tensordot
(
fTensor2
,
std
::
index_sequence
<
0
,
1
>
{},
dTensor2
,
std
::
index_sequence
<
1
,
0
>
{});
testSuite
.
check
(
dScalar
.
rank
()
==
0
);
tensordotOut
(
fTensor2
,
std
::
index_sequence
<
0
,
1
>
{},
dTensor2
,
std
::
index_sequence
<
1
,
0
>
{},
dScalar
);
auto
dMat
=
tensordot
(
fTensor2
,
std
::
index_sequence
<
0
>
{},
dTensor2
,
std
::
index_sequence
<
0
>
{});
testSuite
.
check
(
dMat
.
rank
()
==
2
);
tensordotOut
(
fTensor2
,
std
::
index_sequence
<
0
>
{},
dTensor2
,
std
::
index_sequence
<
0
>
{},
dMat
);
auto
dTen
=
tensordot
(
fTensor2
,
std
::
index_sequence
<>
{},
dTensor2
,
std
::
index_sequence
<>
{});
testSuite
.
check
(
dTen
.
rank
()
==
4
);
tensordotOut
(
fTensor2
,
std
::
index_sequence
<>
{},
dTensor2
,
std
::
index_sequence
<>
{},
dTen
);
}
return
testSuite
.
exit
();
}
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
register
or
sign in
to comment