Mentions légales du service

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

Prepare TransformHelper<FPP,GPU2> to the python wrapper (functions are defined...

Prepare TransformHelper<FPP,GPU2> to the python wrapper (functions are defined but left to define later).
parent d237b12d
Branches
Tags
No related merge requests found
......@@ -25,15 +25,21 @@ namespace Faust
void push_first(const MatGeneric<FPP,GPU2>*, const bool optimizedCopy=false, const bool copying=true);
faust_unsigned_int getNbRow(){ return this->transform->getNbRow();}
faust_unsigned_int getNbCol(){ return this->transform->getNbCol();}
unsigned int get_fact_nb_rows(const faust_unsigned_int id) const;
unsigned int get_fact_nb_cols(const faust_unsigned_int id) const;
template<typename Head, typename ... Tail>
void push_back_(Head& h, Tail&... t);
void push_back_();
void display() const;
std::string to_string() const;
MatDense<FPP,GPU2> get_product();
void get_product(MatDense<FPP,GPU2>& M);
MatDense<FPP,GPU2> multiply(const MatDense<FPP,GPU2> &A, const bool transpose=false, const bool conjugate=false);
TransformHelper<FPP,GPU2>* multiply(const FPP& a);
Vect<FPP,GPU2> multiply(const Faust::Vect<FPP,GPU2>& a);
Real<FPP> normFro() const;
Real<FPP> normL1() const;
Real<FPP> normInf() const;
faust_unsigned_int size() const;
void update_total_nnz() const;
Real<FPP> spectralNorm(int32_t nb_iter_max, float threshold, int& flag);
......@@ -48,6 +54,17 @@ namespace Faust
typename Transform<FPP,GPU2>::iterator end() const;
void tocpu(TransformHelper<FPP,Cpu>& cpu_transf);
void save_mat_file(const char* filename) const;
TransformHelper<FPP,GPU2>* vertcat(const TransformHelper<FPP,GPU2>*);
TransformHelper<FPP,GPU2>* horzcat(const TransformHelper<FPP,GPU2>*);
void set_FM_mul_mode() const;
void set_Fv_mul_mode() const;
faust_unsigned_int get_total_nnz() const;
faust_unsigned_int get_fact_nnz(const faust_unsigned_int id) const;
bool is_fact_sparse(const faust_unsigned_int id) const;
TransformHelper<FPP,GPU2>* normalize(const int meth /* 1 for 1-norm, 2 for 2-norm (2-norm), -1 for inf-norm */) const;
TransformHelper<FPP,GPU2>* transpose();
TransformHelper<FPP,GPU2>* conjugate();
TransformHelper<FPP,GPU2>* adjoint();
};
}
#include "faust_TransformHelper_gpu.hpp"
......
......@@ -65,6 +65,12 @@ namespace Faust
this->transform->Display();
}
template<typename FPP>
string TransformHelper<FPP,GPU2>::to_string() const
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
}
template<typename FPP>
template<typename Head, typename ... Tail>
void TransformHelper<FPP,GPU2>::push_back_(Head& h, Tail&... t)
......@@ -100,6 +106,18 @@ namespace Faust
return this->transform->get_product().norm();
}
template<typename FPP>
Real<FPP> TransformHelper<FPP,GPU2>::normL1() const
{
return this->transform->get_product().normL1();
}
template<typename FPP>
Real<FPP> TransformHelper<FPP,GPU2>::normInf() const
{
return this->transform->normL1(!this->is_transposed);
}
template<typename FPP>
faust_unsigned_int TransformHelper<FPP,GPU2>::size() const
{
......@@ -160,6 +178,24 @@ namespace Faust
return this;
}
template<typename FPP>
Vect<FPP,GPU2> TransformHelper<FPP,GPU2>::multiply(const Faust::Vect<FPP,GPU2>& a)
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
}
template<typename FPP>
void TransformHelper<FPP,GPU2>::set_FM_mul_mode() const
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
}
template<typename FPP>
void TransformHelper<FPP,GPU2>::set_Fv_mul_mode() const
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
}
template<typename FPP>
void TransformHelper<FPP,GPU2>::pop_front()
{
......@@ -268,4 +304,76 @@ namespace Faust
cpu_transf.display();
}
template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::vertcat(const TransformHelper<FPP,GPU2>* G)
{
//TODO
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return nullptr;
}
template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::horzcat(const TransformHelper<FPP,GPU2>* G)
{
//TODO
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return nullptr;
}
template<typename FPP>
faust_unsigned_int TransformHelper<FPP,GPU2>::get_total_nnz() const
{
return this->transform.get_total_nnz();
}
template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::normalize(const int meth /* 1 for 1-norm, 2 for 2-norm (2-norm), -1 for inf-norm */) const
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return nullptr;
}
template<typename FPP>
unsigned int TransformHelper<FPP,GPU2>::get_fact_nb_rows(const faust_unsigned_int id) const
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return 0;
}
template<typename FPP>
unsigned int TransformHelper<FPP,GPU2>::get_fact_nb_cols(const faust_unsigned_int id) const
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return 0;
}
template<typename FPP>
faust_unsigned_int TransformHelper<FPP,GPU2>::get_fact_nnz(const faust_unsigned_int id) const
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return 0;
}
template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::transpose()
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return nullptr;
}
template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::conjugate()
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return nullptr;
}
template<typename FPP>
TransformHelper<FPP,GPU2>* TransformHelper<FPP,GPU2>::adjoint()
{
throw std::runtime_error("This operation is yet to implement in Faust C++ core for GPU.");
return nullptr;
}
}
......@@ -515,5 +515,13 @@ namespace Faust
cpu_transf.save_mat_file(filename, transpose, conjugate);
}
template<>
Real<@FAUST_SCALAR_FOR_GM@> Faust::Transform<@FAUST_SCALAR_FOR_GM@, GPU2>::normL1(const bool transpose /* = false */) const
{
double norm;
MatDense<@FAUST_SCALAR_FOR_GM@, GPU2> full = get_product(transpose?'T':'N');
norm = std::abs(full.normL1(/*transpose*/)); //transpose not necessary because full is already transposed if needed
return norm;
}
}
......@@ -54,9 +54,11 @@ namespace Faust
void multiplyLeft(const Transform<FPP,GPU2> & A);
void multiply(const FPP& a);
Real<FPP> spectralNorm(int32_t nb_iter_max, float threshold, int& flag);
Real<FPP> normL1(const bool transpose = false) const;
void tocpu(Transform<FPP, Cpu>& cpu_transf) const;
Transform<FPP, Cpu> tocpu() const;
void save_mat_file(const char* filename, const bool transpose, const bool conjugate) const;
// using transf_iterator = typename std::vector<MatGeneric<FPP,Cpu>*>::const_iterator;
//
// transf_iterator begin() const;
......
......@@ -56,7 +56,7 @@ FaustCoreCpp<FPP, DEV>::FaustCoreCpp(Faust::TransformHelper<FPP,DEV> *th)
template<typename FPP, FDevice DEV>
void FaustCoreCpp<FPP,DEV>::push_back(FPP* valueMat, unsigned int nbrow,unsigned int nbcol, bool optimizedCopy /* false by deft */)
{
Faust::MatDense<FPP,DEV> dense_mat(valueMat,nbrow,nbcol);
Faust::MatDense<FPP,DEV> dense_mat(nbrow, nbcol, valueMat);
// Faust::MatSparse<FPP,DEV> sparse_mat(dense_mat);
// sparse_mat.Display();
if(transform == nullptr) transform = new Faust::TransformHelper<FPP,DEV>();
......@@ -181,7 +181,8 @@ template<typename FPP, FDevice DEV>
double FaustCoreCpp<FPP,DEV>::norm(int ord, double threshold, int max_num_its) const
{
int flag; //not used yet
switch(ord) {
switch(ord)
{
case 2:
return this->transform->spectralNorm(max_num_its, threshold, flag);
case 1:
......@@ -189,6 +190,7 @@ double FaustCoreCpp<FPP,DEV>::norm(int ord, double threshold, int max_num_its) c
default:
handleError("FaustCoreCpp", "norm(int ord) unvalid norm order.");
}
//TODO: call normFro and normInf from here (and delete the two functions below)
return -1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment