-
Notifications
You must be signed in to change notification settings - Fork 4
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
Move core nn
functions to RETURNN
#252
Comments
On RETURNN side, the new frontend API is supposed to cover exactly those core Moving There is already the This also means to rewrite The RETURNN |
About replacing
Can we move those things over to We need to be careful about cases where
if root_mod_call.layer_ref is not None:
assert not self.layer_ref # not sure. maybe just reset?
assert root_mod_call.layer.layer_dict["class"] == "subnetwork"
sub_out = root_mod_call.children.pop("output")
assert sub_out.layer.layer_dict["class"] == "copy"
sub_real_out = sub_out.layer.layer_dict["from"]
assert isinstance(sub_real_out, nn.Tensor)
# noinspection PyProtectedMember
sub_out.layer._replace_by(sub_real_out)
# noinspection PyProtectedMember
root_mod_call.layer._replace_by(sub_real_out)
def assign_new_cur_layer_name_ctx(self, cur_layer_name_ctx: nn.NameCtx):
"""
Changes self.name_ctx to new name_ctx.
"""
prev_layer_name = f"prev:{cur_layer_name_ctx.name}"
assert prev_layer_name not in cur_layer_name_ctx.parent.children
prev_layer_name_ctx = cur_layer_name_ctx.parent.get_child(prev_layer_name)
prev_layer_name_ctx.move_layer_ref_here(self)
assert self.name_ctx is prev_layer_name_ctx
self.cur_layer_name_ctx = cur_layer_name_ctx And this is only called via prev_ref.assign_new_cur_layer_name_ctx(layer_ref.name_ctx) |
This is for preparation of RETURNN Tensor usage. #252
This is for preparation of RETURNN Tensor usage. #252
This is for preparation of RETURNN Tensor usage. #252
This is for preparation of RETURNN Tensor usage. #252
This is for preparation of RETURNN Tensor usage. #252
This is for preparation of RETURNN Tensor usage. #252
There is also Then there is |
We want to remove Tensor.batch_dim. #252
This is somewhat unclear. There is a comment pointing to: #215 (comment) In there, the argument was, For graph-based frameworks (RETURNN, TensorFlow graph mode), it's true that a tensor is immutable. Wrt. our frontend API, we also have tensors immutable. There is no function which would operate inplace on it. Also, for any developer writing code with Maybe a Or should |
Fix #1273. This is also to prepare for rwth-i6/returnn_common#252.
Now rwth-i6/returnn#1277 was merged, which simplifies the code move. |
A bit on the planned process here: We would copy over bit by bit to RETURNN and integrate it into the RETURNN net dict backend of the RETURNN frontend (rwth-i6/returnn#1120). We would not copy all at once. We also would not touch existing code here in RC for now. I'm not sure if there is a good way here for RC to gradually use the moved code. There are also some changes:
In general, as we did not finalize the RC |
I will probably rename |
#1120 Copied from RETURNN-common. rwth-i6/returnn_common#252 On namespace (rf.encoder.conformer.Conformer), see: #1120 (comment) This is currently untested.
A bit on the process here: This is work-in-progress now. We already moved a lot over. But step-by-step, function-by-function, module-by-module. But even |
As a result of rwth-i6/returnn#1120 and rwth-i6/returnn#1264, we want to move core functions over to RETURNN, as this should become the common compatibility layer for different backends such as TensorFlow and PyTorch.
These are mostly the functions in
nn/_generated_layers.py
, but this in turn also means to move over some of the other code logic, like the naming logic, etc.The text was updated successfully, but these errors were encountered: