Skip to content

Commit

Permalink
get_base_extern_data_py_code_str_direct, support other opts
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Sep 17, 2024
1 parent 8d3c1da commit 6a1db79
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nn/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,20 +906,26 @@ def get_base_extern_data_py_code_str(self) -> str:
return "".join(code_lines)

@classmethod
def get_base_extern_data_py_code_str_direct(cls, extern_data: Dict[str, Any]) -> str:
def get_base_extern_data_py_code_str_direct(
cls, extern_data: Dict[str, Any], *, other: Optional[Dict[str, Any]] = None
) -> str:
"""
directly get serialized Python code via extern data
"""
dim_tags_proxy = ReturnnDimTagsProxy()
from returnn.util.pprint import pformat

extern_data = dim_tags_proxy.collect_dim_tags_and_transform_config(extern_data)
other = dim_tags_proxy.collect_dim_tags_and_transform_config(other)

code_lines = [
cls.ImportPyCodeStr,
f"{dim_tags_proxy.py_code_str()}\n",
f"extern_data = {pformat(extern_data)}\n",
]
if other:
for k, v in other.items():
code_lines.append(f"{k} = {pformat(v)}\n")
return "".join(code_lines)

def get_ext_net_dict_py_code_str(
Expand Down

0 comments on commit 6a1db79

Please sign in to comment.