Skip to content
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

Tensors allocated on cache does not appear deallocation capable #84

Open
jerinphilip opened this issue Mar 24, 2022 · 2 comments
Open
Labels
bug Something isn't working

Comments

@jerinphilip
Copy link

Assuming TensorAllocator is an attempt at implementing an equivalent of std::allocator.

Both tensors_ and cache_ in ExpressionGraph are TensorAllocators.

The cache_ allocates some tensors that are incapable of being deallocated from outside. cache_ is private to this class, and the missing free is a flaw(?).

if(!node->val()) {
if(node->memoize())
cache_->allocate(node->val(), node->shape(), node->value_type());
else
tensors_->allocate(node->val(), node->shape(), node->value_type());
}
}

I could not find a cache_->free(), tensors_ on the other hand are capable of being freed manually through external calls.

void free(const Tensor& tensor) { tensors_->free(tensor); }

@jerinphilip jerinphilip added the bug Something isn't working label Mar 24, 2022
@jerinphilip
Copy link
Author

/marian-dev/src$ grep -R "setMemoize([^)]*)" --exclude-dir 3rd_party/
tensors/cpu/intgemm_interface.h:    setMemoize(false);
tensors/cpu/intgemm_interface.h:    setMemoize(false); // Enabling memoization leads to a massive memory leak. Instead use special "midterm" memory.
tensors/cpu/intgemm_interface.h:                       // Still, I don't understand why setMemoize(true) still leaks.
tensors/cpu/intgemm_interface.h:      setMemoize(false);
tensors/cpu/intgemm_interface.h:      setMemoize(false);
tensors/cpu/intgemm_interface.h:      setMemoize(false);
tensors/cpu/intgemm_interface.h:        setMemoize(false); // AFAIK dot is never called with the same matrices
tensors/cpu/intgemm_interface.h:        setMemoize(false); // AFAIK affine is never called with the same matrices
graph/node_operators.cpp:  setMemoize(graph->isInference());
graph/node.h:  virtual void setMemoize(bool memoize) override { memoize_ = memoize; };
graph/chainable.h:  virtual void setMemoize(bool) = 0;

Memoization appears to be set for nodes at inference.

@jerinphilip
Copy link
Author

@XapaJIaMnu

Still, I don't understand why setMemoize(true) still leaks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant