move temp() to test.cu

This commit is contained in:
Hieu Hoang 2016-09-16 16:03:42 +02:00
parent 78444bc2eb
commit 32a5985500
2 changed files with 23 additions and 23 deletions

View File

@ -39,34 +39,11 @@ std::string Expr::Debug() const
}
///////////////////////////////////////////////////////
#include "tensor_operators.h"
void temp()
{
std::vector<float> hVec({1,2, 4,3, 7,9, 7,3});
thrust::device_vector<float> dVec(8);
thrust::copy(hVec.begin(), hVec.end(), dVec.begin());
float *data = thrust::raw_pointer_cast(dVec.data());
gSoftMax<<<4, 2, sizeof(float)>>>(data, 4, 2);
std::vector<float> hVec2(8);
thrust::copy(dVec.begin(), dVec.end(), hVec2.begin());
cerr << "hVec2=";
for (size_t i = 0; i < hVec.size(); ++i) {
cerr << hVec2[i] << " ";
}
cerr << endl;
}
ExpressionGraph::ExpressionGraph(int cudaDevice)
: stack_(new ChainableStack)
{
std::srand (time(NULL));
cudaSetDevice(0);
temp();
exit(0);
}
}

View File

@ -3,6 +3,29 @@
#include "mnist.h"
#include "vocab.h"
#include "tensor_operators.h"
///////////////////////////////////////////////////////
void temp()
{
std::vector<float> hVec({1,2, 4,3, 7,9, 7,3});
thrust::device_vector<float> dVec(8);
thrust::copy(hVec.begin(), hVec.end(), dVec.begin());
float *data = thrust::raw_pointer_cast(dVec.data());
gSoftMax<<<4, 2, sizeof(float)>>>(data, 4, 2);
std::vector<float> hVec2(8);
thrust::copy(dVec.begin(), dVec.end(), hVec2.begin());
cerr << "hVec2=";
for (size_t i = 0; i < hVec.size(); ++i) {
cerr << hVec2[i] << " ";
}
cerr << endl;
exit(0);
}
///////////////////////////////////////////////////////
int main(int argc, char** argv) {
using namespace std;