I have installed DL4J using maven.
I need to see the installed .so and cpp header files that are used for INDArray calls?
Where can I find them ? I think they are located inside .m2/repository in my Ubuntu machine.
Please help !
so/dll files are packed into correpsonding jar files, i.e. nd4j-native.jar
cpp files are not included, but obviously you can find those in libnd4j folder of this repository
Hi, I need use INDArray pointers into my project where I can fetch them from DL4J frontend and pas them to my CPP backend. So that I can perform operations on them. For that I need to include the nd4j header files and link to the nd4j .so files. Can there be any work around ?
If all you want is INDArray shape/buffer - you don't need any header files for that. Just get the pointer out of ND4J in java, and do what you want with it. It's continuous memory buffer. Shape information is available in Java as well
Alright. And Is it possible to perform INDArray reshape operation from the CPP backend ?
Yes and no, but it'll require some coding efforts. Or, you'll have to include our cpp stuff into your project.
If you want to do that, you can link directly to libnd4j. However, there isn't much in terms of documentation on how to do that.
If you are comfortable enough with just the source, you can find it here: https://github.com/eclipse/deeplearning4j/tree/master/libnd4j
I built libnd4j and included NDArray.h file as below:
#include <NDArray.h>
using namespace nd4j;
float* create_array_float(void** ref, const size_t cnt) {
if(*ref == 0) {
// Create a new Array on ref
auto new_size = new Nd4jLong[100];
nd4j::DataType dtype = nd4j::DataType::DataType_FLOAT;
*ref = new NDArray<float>(new_size, dtype);
}
return get_pointer_float(ref);
}
float* get_pointer_float(void** ref) {
// get the data pointer
return ((NDArray<float>*)*ref)->buffer();
}
void array_free(void** ref) {
//delete Array
delete (NDArray<float>*)*ref;
}
And I call them this way :
void* F4 = 0;
float* p = create_array_float(&F4, 100);
But I am able to assign and fetch values to it at any index and is not giving any segmentation fault (p[125] = 5.5)? Does it allocate a large memory internally than specified ?
(Also, what is difference between /nd4j and /libnd4j folders in this repository ? )