Skip to content
Snippets Groups Projects
Commit 4f2a37f1 authored by Prakalp Srivastava's avatar Prakalp Srivastava
Browse files

No internal nodes for linear-svm. Using just vector ops

parent 9d65e025
No related branches found
No related tags found
No related merge requests found
......@@ -53,41 +53,43 @@ void packData(RootIn* args,
args->nrows = nrows;
}
void LinearLeaf( float* X, size_t bytesX, float* W, size_t bytesW, float* Y, size_t bytesY)
void LinearRoot( float* X, size_t bytesX, float* W, size_t bytesW, float* Y, size_t bytesY, int nrows)
{
__visc__hint(visc::DEVICE);
__visc__attributes(2, X, W, 1, Y);
void* thisNode = __visc__getNode();
//void* thisNode = __visc__getNode();
int rowID = __visc__getNodeInstanceID_x(thisNode);
//int rowID = __visc__getNodeInstanceID_x(thisNode);
int length = __visc__getVectorLength();
int offsetX = rowID*length;
float temp[length];
__visc__vector_mul(X+offsetX, W, temp, length);
Y[rowID] = __visc__reduction_sum(temp, length);
for(int rowID = 0; rowID < nrows; rowID++) {
int offsetX = rowID*length;
__visc__vector_mul(X+offsetX, W, temp, length);
Y[rowID] = __visc__reduction_sum(temp, length);
}
}
// Root node for linear SVM
void LinearRoot(float *X, size_t bytesX,
float *W, size_t bytesW,
float *Y, size_t bytesY,
int nrows
) {
__visc__hint(visc::DEVICE);
__visc__attributes(2, X, W, 1, Y);
void* LinearLeafNode = __visc__createNode1D(LinearLeaf, nrows);
// Bind edges
__visc__bindIn(LinearLeafNode, 0, 0, 0); // Bind X
__visc__bindIn(LinearLeafNode, 1, 1, 0); // Bind bytesX
__visc__bindIn(LinearLeafNode, 2, 2, 0); // Bind W
__visc__bindIn(LinearLeafNode, 3, 3, 0); // Bind bytesW
__visc__bindIn(LinearLeafNode, 4, 4, 0); // Bind Y
__visc__bindIn(LinearLeafNode, 5, 5, 0); // Bind bytesY
}
//void LinearRoot(float *X, size_t bytesX,
//float *W, size_t bytesW,
//float *Y, size_t bytesY,
//int nrows
//) {
//__visc__hint(visc::DEVICE);
//__visc__attributes(2, X, W, 1, Y);
//void* LinearLeafNode = __visc__createNode1D(LinearLeaf, nrows);
//Bind edges
//__visc__bindIn(LinearLeafNode, 0, 0, 0); // Bind X
//__visc__bindIn(LinearLeafNode, 1, 1, 0); // Bind bytesX
//__visc__bindIn(LinearLeafNode, 2, 2, 0); // Bind W
//__visc__bindIn(LinearLeafNode, 3, 3, 0); // Bind bytesW
//__visc__bindIn(LinearLeafNode, 4, 4, 0); // Bind Y
//__visc__bindIn(LinearLeafNode, 5, 5, 0); // Bind bytesY
//}
int main (int argc, char *argv[]) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment