You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
BiRNN layer allocation implementation does wrong allocation.
More accurate, the allocate method might be called with a shared_outputs parameter, containing preallocated buffer for outputs (of shape out_shape), but allocate method does allocation of the internal_buffer (of shape hidden_shape) there, which is larger than output. Thus, the code using preallocation for this layer fails.
Quick fix is to allocate buffers for outputs (in the passed memory) and for internals (in another memory), but this doubles memory footprint. This also requires copying to output buffer in fprop.
Sequential container does extra allocation call / MergeBroadcast integration. In the allocate method of sequential container extra allocate call might occur for the last layer, that owning its outputs (see else branches). The code is calling allocate for this last layer and for all layers. Moreover, the second call does not include shared memory parameter, which might be passed to the sequential container. In simple cases this might lead to increased memory consumption, leaks, and the last layer outputs allocation override (this might be argued by this lines, but this is a shaky argument because of method overriding possibility).
Now, consider the case of MergeBroadcast class, which is consists of a list of Sequential containers and a shared output buffer. The issue leads to overriding of this output buffer in the last layer (ignoring shared buffer). Thus, the Broadcast branch outputs are not merged as they are not written to the shared buffer. This becomes a problem in the case, where BiRNN layer is the last outputs owning layer in the branch. This layer overrides allocation method, so the repeated allocation occurs, and the second allocation will not be aware of shared memory.
MergeBroadcast and BiRNN interaction during bprop.
Consider the following model:
I thought this is because of propagated error shape mismatched to the expected by BiRNNbprop method. The addition of Reshape layer, which is in the correct implementation should restore and propagate back its input shape, solved the issue. Nevertheless, I think the MergeBroadcast layer should restore output shapes for branches in the back propagation pass.
Environment: python 3.5.2, neon 2.6.0 (f9d771b), cuda 8.0, gpu K40s.
The text was updated successfully, but these errors were encountered:
Hello, I have been trying to use MergeBroadcast and BiRNN layers and faced some issues.
Fails during initialization with the following error:
More accurate, the
allocate
method might be called with ashared_outputs
parameter, containing preallocated buffer for outputs (of shapeout_shape
), butallocate
method does allocation of the internal_buffer (of shapehidden_shape
) there, which is larger than output. Thus, the code using preallocation for this layer fails.Quick fix is to allocate buffers for outputs (in the passed memory) and for internals (in another memory), but this doubles memory footprint. This also requires copying to output buffer in
fprop
.Sequential
container does extra allocation call /MergeBroadcast
integration.In the
allocate
method ofsequential
container extraallocate
call might occur for the last layer, that owning its outputs (see else branches). The code is callingallocate
for this last layer and for all layers. Moreover, the second call does not includeshared memory
parameter, which might be passed to the sequential container. In simple cases this might lead to increased memory consumption, leaks, and the last layer outputs allocation override (this might be argued by this lines, but this is a shaky argument because of method overriding possibility).Now, consider the case of
MergeBroadcast
class, which is consists of a list ofSequential
containers and a sharedoutput buffer
. The issue leads to overriding of this output buffer in the last layer (ignoring shared buffer). Thus, theBroadcast
branch outputs are not merged as they are not written to the shared buffer. This becomes a problem in the case, where BiRNN layer is the last outputs owning layer in the branch. This layer overrides allocation method, so the repeated allocation occurs, and the second allocation will not be aware of shared memory.MergeBroadcast
andBiRNN
interaction duringbprop
.Consider the following model:
Trying to run this will give the error, saying that something is wrong with the
error
shape:I thought this is because of propagated
error
shape mismatched to the expected byBiRNN
bprop
method. The addition ofReshape
layer, which is in the correct implementation should restore and propagate back its input shape, solved the issue. Nevertheless, I think theMergeBroadcast
layer should restore output shapes for branches in the back propagation pass.Environment: python 3.5.2, neon 2.6.0 (f9d771b), cuda 8.0, gpu K40s.
The text was updated successfully, but these errors were encountered: