serizba / cppflow

Run TensorFlow models in C++ without installation and without Bazel
https://serizba.github.io/cppflow/
MIT License
779 stars 177 forks source link

leak test #172

Closed ghost closed 2 years ago

ghost commented 2 years ago

Ok, run this code and see if it gets killed/out of memory for you.

include <cppflow/tensor.h>

include

include

int main(int argc, char*argv) { std::vector shape = {256,256}; std::vector data; data.resize(256256);

for(size_t i = 0; i < 1000000; i++)
{
    cppflow::tensor t(data,shape);
}               

}

ghost commented 2 years ago

Now I do this and see what happens

include <cppflow/tensor.h>

include <c/c_api.h>

include

include

void test_cppflow() { std::vector shape = {256,256}; std::vector data; data.resize(256*256);

for(size_t i = 0; i < 1000000; i++)
{
    cppflow::tensor t(data,shape);
}               

}

int main(int argc, char * argv) { TF_Tensor t;

std::vector<int64_t> shape = {256,256};

for(size_t i = 0; i < 1000000; i++)
{
    TF_Tensor * t = TF_AllocateTensor(TF_FLOAT, shape.data(), shape.size(), 256*256);
    TF_DeleteTensor(t);
}               

}

ghost commented 2 years ago

Ok, cppflow pass the test. I have to now determine if garbage collector needs to be cycled. Sorry.

ghost commented 2 years ago

Tensorflow still slow as balls though.