From e9cc69972afc8835c1e9251081e6ae73d44128b1 Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Fri, 10 Mar 2023 09:43:38 +0100 Subject: [PATCH] cleanup, remove Tensor._get_name_in_ctx https://github.com/rwth-i6/returnn_common/issues/252 --- nn/base.py | 7 ------- nn/naming.py | 4 ++-- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/nn/base.py b/nn/base.py index d5786548..eb8bad2c 100644 --- a/nn/base.py +++ b/nn/base.py @@ -287,13 +287,6 @@ def _assign_parent_name_ctx(self, *, ref_ctx: nn.NameCtx): # None found. Just assign to the root. self.raw_tensor.assign_parent(ref_ctx.root, sub_name or "unnamed_param") - def _get_name_in_ctx(self, ctx: nn.NameCtx) -> str: - """ - :return: RETURNN layer name in the given name context. - """ - assert self.raw_tensor.parent or ctx == self.raw_tensor - return self.raw_tensor.get_name_in_ctx(ctx=ctx) - def get_abs_name(self) -> str: """ :return: absolute RETURNN layer name starting from root context. diff --git a/nn/naming.py b/nn/naming.py index 59f61ac2..e47bd925 100644 --- a/nn/naming.py +++ b/nn/naming.py @@ -1116,8 +1116,8 @@ def make_net_dict_raw(self, net: Net, *, _stack: Optional[_StackInfo] = None) -> def _map_elem_resolve(obj: Any) -> Any: if isinstance(obj, nn.Tensor): - # noinspection PyProtectedMember - return obj._get_name_in_ctx(ctx=net.name_ctx) + assert obj.raw_tensor.parent or net.name_ctx == obj.raw_tensor + return obj.raw_tensor.get_name_in_ctx(ctx=net.name_ctx) if isinstance(obj, Net): return self.make_net_dict_raw( net=obj, _stack=_stack.add(net=obj, layer_abs_name_scope_effective=sub_layer_abs_name_scope)