@@ -2823,11 +2823,6 @@ def __init__(self, name,
2823
2823
if time_dim_axis is NotSpecified :
2824
2824
time_dim_axis = _default_time_dim_axis_dim_tags (dim_tags )
2825
2825
dim_tags = tuple (dim_tags )
2826
- if auto_create_placeholders :
2827
- _auto_create_size_placeholders_on_dim_tags (name = name , dim_tags = dim_tags )
2828
- if batch_dim_axis_ is not None :
2829
- if dim_tags [batch_dim_axis_ ].batch and not self ._batch :
2830
- self ._batch = dim_tags [batch_dim_axis_ ].batch
2831
2826
del shape_
2832
2827
del batch_dim_axis_
2833
2828
else :
@@ -2846,7 +2841,7 @@ def __init__(self, name,
2846
2841
dim_tags = _infer_dim_tags_tuple_from_shape (
2847
2842
shape , batch_dim_axis = batch_dim_axis , time_dim_axis = time_dim_axis , feature_dim_axis = feature_dim_axis ,
2848
2843
size_placeholder = size_placeholder , name = name ,
2849
- auto_create_placeholders = auto_create_placeholders ,
2844
+ extern_data = auto_create_placeholders ,
2850
2845
dim_tags = dim_tags , sparse = sparse )
2851
2846
del batch_dim_axis
2852
2847
del shape
@@ -2893,8 +2888,10 @@ def __init__(self, name,
2893
2888
base_tag = self ._dim_tags [_axis ]
2894
2889
if base_tag != _dim_tag :
2895
2890
base_tag .declare_same_as (_dim_tag )
2896
- if _dim_tag .dyn_size is not None :
2897
- self .set_dynamic_size (_axis , _dim_tag .dyn_size )
2891
+ self ._dim_tags = self ._dim_tags [:_axis ] + (_dim_tag ,) + self ._dim_tags [_axis + 1 :]
2892
+ if auto_create_placeholders :
2893
+ # Do that after same_dim_tags_as handling.
2894
+ _auto_create_size_placeholders_on_dim_tags (name = name , dim_tags = self ._dim_tags )
2898
2895
self ._adapt_batch_consistent_dim_tags ()
2899
2896
self .sanity_check (assume_complete = False )
2900
2897
@@ -5780,7 +5777,7 @@ def _infer_dim_tags_tuple_from_shape(
5780
5777
size_placeholder ,
5781
5778
dim_tags ,
5782
5779
name ,
5783
- auto_create_placeholders
5780
+ extern_data
5784
5781
):
5785
5782
"""
5786
5783
:param tuple[int|None]|list[int|None] shape: this is without batch-dim-axis
@@ -5790,7 +5787,7 @@ def _infer_dim_tags_tuple_from_shape(
5790
5787
:param bool sparse:
5791
5788
:param dict[int,tf.Tensor]|None size_placeholder: key is axis without batch-dim
5792
5789
:param dict[int,Dim]|None dim_tags: some existing explicitly specified dim tags. key is axis with batch-dim
5793
- :param bool auto_create_placeholders :
5790
+ :param bool extern_data :
5794
5791
:param str name:
5795
5792
:return: dim tags tuple
5796
5793
:rtype: tuple[Dim]
@@ -5808,8 +5805,6 @@ def _infer_dim_tags_tuple_from_shape(
5808
5805
dim_tags = dim_tags .copy () if dim_tags else {}
5809
5806
if batch_dim_axis is not None and batch_dim_axis not in dim_tags :
5810
5807
dim_tags [batch_dim_axis ] = Dim (kind = Dim .Types .Batch , description = "batch:%s" % name )
5811
- # noinspection PyShadowingNames
5812
- batch_dim = dim_tags [batch_dim_axis ] if batch_dim_axis is not None else None
5813
5808
# Note: Consistent to Data.get_dim_tag,
5814
5809
# prefer interpretation as spatial axis if there is a dynamic size or this is marked as time axis.
5815
5810
if size_placeholder :
@@ -5833,7 +5828,7 @@ def _infer_dim_tags_tuple_from_shape(
5833
5828
axis_wo_b = _get_axis_wo_b (axis , batch_dim_axis = batch_dim_axis )
5834
5829
dyn_size = size_placeholder .get (axis_wo_b ) if (size_placeholder and axis_wo_b is not None ) else None
5835
5830
dim = batch_shape [axis ]
5836
- if auto_create_placeholders and dim is None and dyn_size is None and axis != batch_dim_axis :
5831
+ if extern_data and dim is None and dyn_size is None and axis != batch_dim_axis :
5837
5832
if not tag :
5838
5833
if axis == time_dim_axis :
5839
5834
tag_name = "time"
@@ -5845,7 +5840,6 @@ def _infer_dim_tags_tuple_from_shape(
5845
5840
# This is such that Dim.is_equal behaves as before, e.g. in Data.get_common_data.
5846
5841
kind = Dim .Types .Spatial )
5847
5842
dim_tags [axis ] = tag
5848
- _create_size_placeholder (name = name , axis_wo_b = axis_wo_b , tag = tag , batch_dim = batch_dim )
5849
5843
dyn_size = tag .dyn_size
5850
5844
if tag :
5851
5845
# Just some sanity checks.
0 commit comments