-
Notifications
You must be signed in to change notification settings - Fork 13
Finite Lifetime for IO Tensors #51
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
base: devel
Are you sure you want to change the base?
Finite Lifetime for IO Tensors #51
Conversation
… have finite lifetime
…y are I/O buffers
0084047
to
dd1370c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and I already know how important it is ;) I also like the testMemoryMapCorrectness
you added.
No major comments, just some small questions.
uint32_t compute_num = snrt_cluster_compute_core_num(); | ||
uint32_t compute_num = 1; //snrt_cluster_compute_core_num(); | ||
int32_t ldI = compute_num * ${input_samples}; | ||
int32_t batch_offset = ${seq_len} * ${input_samples}; | ||
|
||
${kernelName}(${data_in}, ${data_out}, ldI, batch_offset, batch_size, ${seq_len}, ${input_samples}); | ||
|
||
// JUNGVI: This implementation is broken and has memory leak. | ||
if (snrt_hartid() == 0){ | ||
${kernelName}(${data_in}, ${data_out}, ldI, batch_offset, batch_size, ${seq_len}, ${input_samples}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be part of this PR? How hard is it to fix it or did Run already fix it?
# SCHEREMO: ConstantBuffers are assigned and allocated at compile time, Global Var Buffers are assigned at init time | ||
if isinstance(ctxt.lookup(tensorMemoryConstraint.tensorName), ConstantBuffer) or ctxt.is_global( | ||
tensorMemoryConstraint.tensorName): | ||
if isinstance(ctxt.lookup(tensorMemoryConstraint.tensorName), ConstantBuffer): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please adapt the comment according to you changes.
if hasattr(ctxt.lookup(buffer.name), "_alias"): | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could it be helpful to mark aliased buffers with a special color or sth. else?
def setupModel(self, ctxt: NetworkContext, schedule: Schedule, layerBinding: OrderedDict[str, ONNXLayer], | ||
def setupModel(self, ctxt: NetworkContext, schedule: Schedule, layerBinding: 'OrderedDict[str, ONNXLayer]', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? The ONNXLayer
is imported above.
This PR is based on this currently open PR, don't review it before PR#44 is merged.Added
VariableBuffer
is_output
, andis_input
, to indicate that aVariableBuffer
is an IO of the network. IO buffers have to be treated differently than normal buffers; while they live in the global scope, inputs need to be alive at the beginning of the computation (lifetime[0]=0), and outputs have to be alive at the end of the computation (lifetime[-1]=inf).Changed
_calculateLifetimes
method of theMemoryScheduler
is now giving a proper lifetime ofVariableBuffer
from the global scope.OrderedDict
representing the global context. This is necessary as other global buffers can depend on these arenas for their definition.Fixed
generateBufferAllocationCode
for PULP Deployer. Previously, the output was loaded in L3 at the beginning of the computation. This is completely unnecessary; breaks when the outputs don't have an infinite lifetime, and it is prone to error. Hence now the outputs are not loaded in L3.Softmax_fp32
kernel for Snitch has a memory leak if used with 8 cores. I added a comment and constrained its execution to a single core._calculateLifetimes
: The lifetime of aliased buffers is not correctly computed.PR Merge Checklist
devel
commit and pointing todevel
.CHANGELOG.md
file has been updated.