Skip to content

Commit

Permalink
cleanup, remove Tensor._get_name_in_ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Mar 10, 2023
1 parent c1cf7cf commit e9cc699
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
7 changes: 0 additions & 7 deletions nn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions nn/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e9cc699

Please sign in to comment.