-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
uTensor leaks memory #162
Comments
Here's the overview of active memory on the heap (generated via mbed-find-dangling-ptrs):
I think these are related to the prediction tensor cause the allocations show up late in my log (not 100% in order as the mem tracer uses RawSerial and the application normal Serial):
And are not free'd. Also, there's still some 132 bytes not accounted for, and the mem tracer can't find them either. Maybe it doesn't work so well with shared pointers? |
@mbartling Can you please share your memory debugging setup/info here as well? |
@janjongboom
@Knight-X @mbartling However, in my current attempt to remove share-pointers, application will be responsible to delete the output tensor. Re-running the context will override the output-tensor. A heads up. |
@neil-tan My feeling for this API would be that uTensor should not handle input / output memory. The application passes in the input layer, with memory owned by the application; and the application passes in memory for the output layer (also memory owned by the application). Add some runtime guarantees for the types to ensure people don't pass in the wrong values. Also I believe the API will be much cleaner this way. E.g.: float input[33] = { 0 };
float output[4] = { 0 };
Context ctx;
get_trained_ctx(ctx, input, 33, output, 4);
ctx.eval(); |
I have a simple neural network with two hidden layers. Every time I classify through uTensor I'm leaking ~250 bytes of memory.
Here's how to log memory:
Set the following macro:
Use the following snippet:
Then I'm invoking uTensor like this:
Note that if I delete the RamTensor after running this will hardfault so I assume the memory for that is managed by uTensor.
This leaks memory:
My model can be found here: https://github.com/janjongboom/utensor-test/tree/fixed
The text was updated successfully, but these errors were encountered: