Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
faust
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
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
Admin message
GitLab upgrade completed. Current version is 17.11.4.
Show more breadcrumbs
faust group
faust
Commits
7642d3c8
Commit
7642d3c8
authored
3 years ago
by
hhakim
Browse files
Options
Downloads
Patches
Plain Diff
Add a first test of a Faust containing a MatBSR.
parent
476e00ff
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
misc/test/src/C++/test_MatBSR.cpp.in
+52
-1
52 additions, 1 deletion
misc/test/src/C++/test_MatBSR.cpp.in
with
52 additions
and
1 deletion
misc/test/src/C++/test_MatBSR.cpp.in
+
52
−
1
View file @
7642d3c8
#include "faust_TransformHelper.h"
#include "faust_constant.h"
#include "faust_MatDense.h"
#include "faust_MatSparse.h"
...
...
@@ -566,6 +567,55 @@ void test_tosparse(const MatBSR<FPP, Cpu>& bmat)
cout << "OK" << endl;
}
void test_faust()
{
int faust_nrows = 1024;
int faust_ncols = 1024;
RandFaustType t = SPARSE;
unsigned int min_num_factors = 5;
unsigned int max_num_factors = 10;
unsigned int min_dim_size = 1024;
unsigned int max_dim_size = 1024;
float density=.001f;
bool per_row=true;
auto F = TransformHelper<FPP, Cpu>::randFaust(faust_nrows, faust_ncols, t, min_num_factors, max_num_factors, min_dim_size, max_dim_size, density, per_row);
auto rep_id = F->size()-3;
auto f_nrows = F->get_fact_nb_rows(rep_id);
auto f_ncols = F->get_fact_nb_cols(rep_id);
auto rand_bmat = MatBSR<FPP, Cpu>::randMat(f_nrows, f_ncols, 64, 64, 20);
// F->display();
cout << "replace factor of index: " << F->size()-3 << " by a rand BSRMat:" << std::endl;
F->replace(rand_bmat, rep_id);
F->display();
auto start = std::chrono::steady_clock::now();
auto toarray = F->get_product();
auto end = std::chrono::steady_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
std::cout << "Faust with BSR matrix time: " << elapsed_seconds.count() << "s\n";
cout << endl;
auto rand_dmat = new MatDense<FPP, Cpu>(rand_bmat->to_dense());
F->replace(rand_dmat, rep_id);
F->display();
start = std::chrono::steady_clock::now();
auto toarray_ref = F->get_product();
end = std::chrono::steady_clock::now();
elapsed_seconds = end-start;
std::cout << "Faust with dense matrix time: " << elapsed_seconds.count() << "s\n";
cout << endl;
toarray_ref -= toarray;
assert(toarray_ref.norm() < 1e-6);
MatSparse<FPP, Cpu> *rand_smat = new MatSparse<FPP, Cpu>(*rand_dmat);
F->replace(rand_smat, rep_id);
F->display();
start = std::chrono::steady_clock::now();
auto toarray_sp = F->get_product();
end = std::chrono::steady_clock::now();
elapsed_seconds = end-start;
std::cout << "Faust with sparse matrix time: " << elapsed_seconds.count() << "s\n";
cout << endl;
}
int main(int argc, char** argv)
{
int m, n, bm, bn, bnnz;
...
...
@@ -608,8 +658,9 @@ int main(int argc, char** argv)
test_nonzero_indices(*bmat);
test_set_zeros(*bmat);
// test_has_nan(*bmat);
test_getitem(*bmat);
//
test_getitem(*bmat);
test_tosparse(*bmat);
test_faust();
delete bmat;
return EXIT_SUCCESS;
}
...
...
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