Skip to content

Commit

Permalink
new naming, no TF dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
albertz committed Aug 9, 2023
1 parent dafa290 commit 54bb95d
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions nn/naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,10 +879,10 @@ def get_complete_py_code_str(self, root_module: nn.Module):
root_module=root_module, with_imports=False, ref_extern_data_dims_via_global_config=False
)

# avoid TF dependency
ImportPyCodeStr = (
"from returnn.tf.util.data import (\n"
" Dim, batch_dim, single_step_dim,"
" SpatialDim, FeatureDim, ImplicitDynSizeDim, ImplicitSparseDim)\n\n"
"from returnn.tensor import Dim, batch_dim, single_step_dim\n"
"from returnn.tensor.marked_dim import ImplicitDynSizeDim, ImplicitSparseDim\n\n"
)

def get_base_extern_data_py_code_str(self) -> str:
Expand Down Expand Up @@ -1284,14 +1284,7 @@ def dim_repr(self):
if dim.derived_from_op:
return self.parent.dim_ref_repr(dim, brackets=False, prefer_ref=False)
assert not dim.match_priority
# We assume FeatureDim, SpatialDim and Dim are imported.
if dim.kind == nn.Dim.Types.Feature:
return f"FeatureDim({dim.description!r}, {dim.dimension})"
if dim.kind == nn.Dim.Types.Spatial:
if dim.dimension is not None:
return f"SpatialDim({dim.description!r}, {dim.dimension})"
else:
return f"SpatialDim({dim.description!r})"
# We assume Dim is imported.
# generic fallback
return f"Dim(kind={dim.kind}, description={dim.description!r}, dimension={dim.dimension})"

Expand Down

0 comments on commit 54bb95d

Please sign in to comment.