Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 72815a6d authored by hhakim's avatar hhakim
Browse files

Change the way the pyfaust ConstraintMat is passed to C++ core when there is...

Change the way the pyfaust ConstraintMat is passed to C++ core when there is no matrix to copy (eg. proj_id), it will be simpler for potential new ConstraintMat in this case.
parent 86bc266a
No related branches found
No related tags found
No related merge requests found
...@@ -287,19 +287,13 @@ void prepare_fact(const FPP* mat, const unsigned int num_rows, const unsigned in ...@@ -287,19 +287,13 @@ void prepare_fact(const FPP* mat, const unsigned int num_rows, const unsigned in
cons_mat = static_cast<PyxConstraintMat<FPP>*>(p->constraints[i]); cons_mat = static_cast<PyxConstraintMat<FPP>*>(p->constraints[i]);
// if(p->is_verbose) // if(p->is_verbose)
// cout << "constraint[" << i << "]->parameter: " << cons_mat->parameter[0] << endl; // cout << "constraint[" << i << "]->parameter: " << cons_mat->parameter[0] << endl;
if(p->constraints[i]->name == CONSTRAINT_NAME_ID) Faust::MatDense<FPP, Cpu> P;
{ if(cons_mat->parameter_sz > 0) // Identity Constraint has not cons_mat->parameter matrix
tmp_cons = new Faust::ConstraintMat<FPP, Cpu>(CONSTRAINT_NAME_ID, p->constraints[i]->num_rows, p->constraints[i]->num_cols);
}
else
{
Faust::MatDense<FPP, Cpu> P;
if(p->constraints[i]->num_rows * p->constraints[i]->num_cols == cons_mat->parameter_sz) if(p->constraints[i]->num_rows * p->constraints[i]->num_cols == cons_mat->parameter_sz)
P = Faust::MatDense<FPP, Cpu>(cons_mat->parameter, p->constraints[i]->num_rows, p->constraints[i]->num_cols); P = Faust::MatDense<FPP, Cpu>(cons_mat->parameter, p->constraints[i]->num_rows, p->constraints[i]->num_cols);
else else
P = Faust::MatDense<FPP, Cpu>(cons_mat->parameter, cons_mat->parameter_sz/2, 2); P = Faust::MatDense<FPP, Cpu>(cons_mat->parameter, cons_mat->parameter_sz/2, 2);
tmp_cons = new Faust::ConstraintMat<FPP,Cpu>(static_cast<faust_constraint_name>(p->constraints[i]->name), P, p->constraints[i]->num_rows, p->constraints[i]->num_cols); tmp_cons = new Faust::ConstraintMat<FPP,Cpu>(static_cast<faust_constraint_name>(p->constraints[i]->name), P, p->constraints[i]->num_rows, p->constraints[i]->num_cols);
}
cons.push_back(tmp_cons); cons.push_back(tmp_cons);
} }
else else
...@@ -621,7 +615,8 @@ TransformHelper<FPP, DEV>* palm4msa2020_gen(FPP* mat, unsigned int num_rows, uns ...@@ -621,7 +615,8 @@ TransformHelper<FPP, DEV>* palm4msa2020_gen(FPP* mat, unsigned int num_rows, uns
nrows = cons_mat->parameter_sz/2; nrows = cons_mat->parameter_sz/2;
ncols = 2; ncols = 2;
} }
P = Faust::MatDense<FPP, DEV>(nrows, ncols, cons_mat->parameter); if(cons_mat->parameter_sz > 0) // Identity Constraint has not cons_mat->parameter matrix
P = Faust::MatDense<FPP, DEV>(nrows, ncols, cons_mat->parameter);
tmp_cons = new Faust::ConstraintMat<FPP,DEV>(static_cast<faust_constraint_name>(constraints[i]->name), P, constraints[i]->num_rows, constraints[i]->num_cols); tmp_cons = new Faust::ConstraintMat<FPP,DEV>(static_cast<faust_constraint_name>(constraints[i]->name), P, constraints[i]->num_rows, constraints[i]->num_cols);
fact_cons.push_back(tmp_cons); fact_cons.push_back(tmp_cons);
} }
...@@ -772,26 +767,20 @@ Faust::TransformHelper<FPP,DEV>* hierarchical2020_gen(FPP* mat, unsigned int num ...@@ -772,26 +767,20 @@ Faust::TransformHelper<FPP,DEV>* hierarchical2020_gen(FPP* mat, unsigned int num
faust_unsigned_int nrows, ncols; faust_unsigned_int nrows, ncols;
// if(is_verbose) // if(is_verbose)
// cout << "constraint[" << i << "]->parameter: " << cons_mat->parameter[0] << endl; // cout << "constraint[" << i << "]->parameter: " << cons_mat->parameter[0] << endl;
if(constraints[i]->name == CONSTRAINT_NAME_ID) Faust::MatDense<FPP, DEV> P;
if(constraints[i]->num_rows * constraints[i]->num_cols == cons_mat->parameter_sz)
{ {
tmp_cons = new Faust::ConstraintMat<FPP, Cpu>(CONSTRAINT_NAME_ID, constraints[i]->num_rows, constraints[i]->num_cols); nrows = constraints[i]->num_rows;
ncols = constraints[i]->num_cols;
} }
else else
{ {
Faust::MatDense<FPP, DEV> P; nrows = cons_mat->parameter_sz/2;
if(constraints[i]->num_rows * constraints[i]->num_cols == cons_mat->parameter_sz) ncols = 2;
{
nrows = constraints[i]->num_rows;
ncols = constraints[i]->num_cols;
}
else
{
nrows = cons_mat->parameter_sz/2;
ncols = 2;
}
P = Faust::MatDense<FPP, DEV>(nrows, ncols, cons_mat->parameter);
tmp_cons = new Faust::ConstraintMat<FPP, DEV>(static_cast<faust_constraint_name>(constraints[i]->name), P, constraints[i]->num_rows, constraints[i]->num_cols);
} }
if(cons_mat->parameter_sz > 0) // Identity Constraint has not cons_mat->parameter matrix
P = Faust::MatDense<FPP, DEV>(nrows, ncols, cons_mat->parameter);
tmp_cons = new Faust::ConstraintMat<FPP, DEV>(static_cast<faust_constraint_name>(constraints[i]->name), P, constraints[i]->num_rows, constraints[i]->num_cols);
cons.push_back(tmp_cons); cons.push_back(tmp_cons);
} }
else else
......
...@@ -118,6 +118,9 @@ cdef class FaustAlgoGen@TYPE_NAME@: ...@@ -118,6 +118,9 @@ cdef class FaustAlgoGen@TYPE_NAME@:
&tmp_mat[0,0] &tmp_mat[0,0]
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\ (<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
cons._cons_value_sz cons._cons_value_sz
else:
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
0
else: else:
raise ValueError("Constraint type/name is not recognized.") raise ValueError("Constraint type/name is not recognized.")
cpp_constraints[i].name = cons.name cpp_constraints[i].name = cons.name
...@@ -269,6 +272,9 @@ cdef class FaustAlgoGen@TYPE_NAME@: ...@@ -269,6 +272,9 @@ cdef class FaustAlgoGen@TYPE_NAME@:
&tmp_mat[0,0] &tmp_mat[0,0]
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\ (<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
cons._cons_value_sz cons._cons_value_sz
else:
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
0
else: else:
raise ValueError("Constraint type/name is not recognized.") raise ValueError("Constraint type/name is not recognized.")
cpp_constraints[i].name = cons.name cpp_constraints[i].name = cons.name
...@@ -380,6 +386,9 @@ cdef class FaustAlgoGen@TYPE_NAME@: ...@@ -380,6 +386,9 @@ cdef class FaustAlgoGen@TYPE_NAME@:
&tmp_mat[0,0] &tmp_mat[0,0]
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\ (<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
cons._cons_value_sz cons._cons_value_sz
else:
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
0
else: else:
raise ValueError("Constraint type/name is not recognized.") raise ValueError("Constraint type/name is not recognized.")
cpp_constraints[i].name = cons.name cpp_constraints[i].name = cons.name
...@@ -524,7 +533,9 @@ cdef class FaustAlgoGen@TYPE_NAME@: ...@@ -524,7 +533,9 @@ cdef class FaustAlgoGen@TYPE_NAME@:
&tmp_mat[0,0] &tmp_mat[0,0]
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\ (<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
cons._cons_value_sz cons._cons_value_sz
else:
(<PyxConstraintMat[@TYPE@]*>cpp_constraints[i]).parameter_sz =\
0
else: else:
raise ValueError("Constraint type/name is not recognized.") raise ValueError("Constraint type/name is not recognized.")
cpp_constraints[i].name = cons.name cpp_constraints[i].name = cons.name
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment