@@ -1039,7 +1039,7 @@ def get_out_data_from_opts(
1039
1039
if out_dim :
1040
1040
assert out_dim .dimension == new_dim
1041
1041
else :
1042
- out_dim = Dim (kind = dim_tag .kind , description = "%s:slice" % name , dimension = new_dim )
1042
+ out_dim = Dim (kind = dim_tag .kind , description = "%s:slice" % name , dimension = new_dim , auto_generated = True )
1043
1043
return input_data .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_dim , name = "%s_output" % name )
1044
1044
1045
1045
@@ -1219,7 +1219,7 @@ def get_out_data_from_opts(cls, name, sources=(), start=None, size=None, axis="T
1219
1219
out_spatial_dim = Dim (
1220
1220
kind = Dim .Types .Spatial ,
1221
1221
description = "sliced-time:%s" % name ,
1222
- dimension = size )
1222
+ dimension = size , auto_generated = True )
1223
1223
gather_positions_data = gather_positions_data .copy_add_dim_by_tag (
1224
1224
out_spatial_dim , unbroadcast = True , axis = start_data .batch_ndim )
1225
1225
position = InternalLayer (
@@ -2613,7 +2613,7 @@ def get_out_data_from_opts(cls, name, network, shape, maxval, minval=0, dtype="i
2613
2613
elif isinstance (d , int ):
2614
2614
d = Dim (
2615
2615
kind = Dim .Types .Spatial if i < len (shape ) - 1 else Dim .Types .Feature ,
2616
- description = "%s:static:%i" % (name , i ),
2616
+ description = "%s:static:%i" % (name , i ), auto_generated = True ,
2617
2617
dimension = d )
2618
2618
else :
2619
2619
raise TypeError ("Layer %r: invalid type %s in shape %r" % (name , type (d ), shape ))
@@ -2679,7 +2679,7 @@ def get_out_data_from_opts(cls, name, limit, start=0, delta=1, dtype=None, spars
2679
2679
else :
2680
2680
dtype = "int32"
2681
2681
dim = len (range (start , limit , delta ))
2682
- tag = Dim (kind = Dim .Types .Spatial , dimension = dim , description = "%s:range" % name )
2682
+ tag = Dim (kind = Dim .Types .Spatial , dimension = dim , description = "%s:range" % name , auto_generated = True )
2683
2683
if out_spatial_dim :
2684
2684
tag .declare_same_as (out_spatial_dim )
2685
2685
sparse_dim = None
@@ -2799,7 +2799,7 @@ def get_out_data_from_opts(cls, name, sources, dtype="int32", sparse=False, out_
2799
2799
dim_tag = Dim .get_tag_from_size_tensor (source .placeholder )
2800
2800
if not dim_tag :
2801
2801
dim_tag = Dim (
2802
- kind = Dim .Types .Spatial , description = "%s_input_len" % name ,
2802
+ kind = Dim .Types .Spatial , description = "%s_input_len" % name , auto_generated = True ,
2803
2803
batch = source .batch , control_flow_ctx = source .control_flow_ctx ,
2804
2804
dyn_size_ext = source )
2805
2805
if source .placeholder is not None :
@@ -3079,15 +3079,15 @@ def get_out_data_from_opts(cls, name, network, sources, window_size=None, window
3079
3079
filter_size = window_size , stride = stride , dilation_rate = 1 , padding = padding )
3080
3080
out_spatial_dim = Dim (
3081
3081
kind = Dim .Types .Spatial , description = "%s:spatial" % name ,
3082
- dimension = dim , derived_from_tag = in_spatial_dim ,
3082
+ dimension = dim , derived_from_tag = in_spatial_dim , auto_generated = True ,
3083
3083
batch = data .batch , control_flow_ctx = data .control_flow_ctx )
3084
3084
data = data .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_spatial_dim )
3085
3085
new_dim_axis = axis + 1 # add new axis right after
3086
3086
if window_dim :
3087
3087
assert window_dim .dimension == window_size
3088
3088
else :
3089
3089
window_dim = Dim (
3090
- kind = Dim .Types .Spatial , description = "%s:window" % name , dimension = window_size )
3090
+ kind = Dim .Types .Spatial , description = "%s:window" % name , dimension = window_size , auto_generated = True )
3091
3091
return data .copy_add_dim_by_tag (axis = new_dim_axis , dim_tag = window_dim , unbroadcast = True )
3092
3092
3093
3093
# noinspection PyMethodOverriding
@@ -3585,9 +3585,11 @@ def _get_axis_size_splits_num_splits(cls, name, input_data, axis=None,
3585
3585
err_prefix , out_dims , dim , input_data )
3586
3586
if not out_dims :
3587
3587
assert size_splits
3588
- out_dims = [Dim (
3589
- kind = input_data .dim_tags [axis ].kind , description = "%s_split%i" % (name , idx ),
3590
- dimension = size_splits [idx ]) for idx in range (len (size_splits ))]
3588
+ out_dims = [
3589
+ Dim (
3590
+ kind = input_data .dim_tags [axis ].kind , description = "%s_split%i" % (name , idx ),
3591
+ dimension = size_splits [idx ], auto_generated = True )
3592
+ for idx in range (len (size_splits ))]
3591
3593
return axis , out_dims
3592
3594
3593
3595
def _make_split_layer (self , idx ):
@@ -3867,6 +3869,7 @@ def get_out_data_from_opts(cls, name, axis, dims, pad_to_multiples=None, sources
3867
3869
kind = axis_dim_tag .kind ,
3868
3870
description = "%s_split_dims%i_rem" % (name , rem_dim_idx ),
3869
3871
dimension = resolved_shape_dims [rem_dim_idx ],
3872
+ auto_generated = True ,
3870
3873
derived_from_tag = axis_dim_tag ,
3871
3874
batch = axis_dim_tag .batch , control_flow_ctx = axis_dim_tag .control_flow_ctx )
3872
3875
if rem_dim .dimension is None and axis_dim_tag .dyn_size_ext is not None :
@@ -3883,7 +3886,7 @@ def get_out_data_from_opts(cls, name, axis, dims, pad_to_multiples=None, sources
3883
3886
Dim (
3884
3887
kind = axis_dim_tag .kind if not axis_dim_tag .is_batch_dim () else Dim .Types .Spatial ,
3885
3888
description = "%s_split_dims%i" % (name , i ),
3886
- dimension = shape_dim )
3889
+ dimension = shape_dim , auto_generated = True )
3887
3890
if rem_dim is None or i != rem_dim_idx else rem_dim
3888
3891
for i , shape_dim in enumerate (resolved_shape_dims ))
3889
3892
out_batch = data .batch
@@ -4238,7 +4241,7 @@ def get_out_data_from_opts(cls, name, axis, dim=1, sources=(), **kwargs):
4238
4241
else :
4239
4242
new_dim = Dim (
4240
4243
kind = Dim .Types .Feature if init_axis .lower () == "f" else Dim .Types .Spatial ,
4241
- description = "%s_expand_dims" % name ,
4244
+ description = "%s_expand_dims" % name , auto_generated = True ,
4242
4245
dimension = dim )
4243
4246
data = data .copy_template (name = "%s_output" % name )
4244
4247
data = data .copy_add_dim_by_tag (new_dim , unbroadcast = True , axis = axis )
@@ -4394,7 +4397,7 @@ def get_out_data_from_opts(cls, name, sources, axis, repetitions, out_dim=None,
4394
4397
if isinstance (repetitions , int ):
4395
4398
out_dim = tag * repetitions
4396
4399
else :
4397
- out_dim = Dim (description = "repeated:%s" % name , kind = tag .kind , derived_from_tag = tag )
4400
+ out_dim = Dim (description = "repeated:%s" % name , kind = tag .kind , derived_from_tag = tag , auto_generated = True )
4398
4401
return data .copy_template_replace_dim_tag (axis = data .get_batch_axis (0 ), new_dim_tag = out_dim )
4399
4402
4400
4403
@@ -4804,12 +4807,12 @@ def map_axis_name(s):
4804
4807
pass
4805
4808
else :
4806
4809
out .sparse_dim = Dim (
4807
- kind = Dim .Types .Feature , dimension = set_sparse_dim , description = "%s:set-sparse-dim" % name )
4810
+ kind = Dim .Types .Feature , dimension = set_sparse_dim , description = "%s:set-sparse-dim" % name , auto_generated = True )
4808
4811
if increase_sparse_dim :
4809
4812
assert out .sparse
4810
4813
out .sparse_dim = Dim (
4811
4814
kind = Dim .Types .Feature , dimension = out .sparse_dim .dimension + 1 ,
4812
- description = "%s:inc-sparse-dim" % name )
4815
+ description = "%s:inc-sparse-dim" % name , auto_generated = True )
4813
4816
if batch_dim_base :
4814
4817
out .batch = batch_dim_base .output .batch
4815
4818
return out
@@ -5263,7 +5266,7 @@ def get_out_data_from_opts(
5263
5266
filter_size = filter_size [i ], stride = strides [i ], dilation_rate = dilation_rate [i ], padding = padding )
5264
5267
dim_tags .append (Dim (
5265
5268
kind = Dim .Types .Spatial , description = "%s:conv:s%i" % (name , i ), dimension = new_dim ,
5266
- derived_from_tag = old_tag , undefined = not old_tag ))
5269
+ derived_from_tag = old_tag , undefined = not old_tag , auto_generated = True ))
5267
5270
if not out_dim :
5268
5271
assert n_out
5269
5272
out_dim = FeatureDim ("%s:channel" % name , dimension = n_out )
@@ -5767,7 +5770,7 @@ def get_out_data_from_opts(cls, name, sources, network,
5767
5770
padding = padding , output_padding = output_padding [i ]) - remove_padding [i ] * 2
5768
5771
dim_tags .append (Dim (
5769
5772
kind = Dim .Types .Spatial , description = "%s:conv:s%i" % (name , i ), dimension = new_dim ,
5770
- derived_from_tag = old_tag , undefined = not old_tag ))
5773
+ derived_from_tag = old_tag , undefined = not old_tag , auto_generated = True ))
5771
5774
if not out_dim :
5772
5775
assert n_out
5773
5776
out_dim = FeatureDim ("%s:channel" % name , dimension = n_out )
@@ -5983,7 +5986,8 @@ def get_out_data_from_opts(cls, name, sources, mode="", axes=None, axis=None, ke
5983
5986
out_time_dim_axis = x .time_dim_axis
5984
5987
if keep_dims :
5985
5988
for i in axes :
5986
- y_dim_tags [i ] = Dim (kind = y_dim_tags [i ].kind , dimension = 1 , description = "%s:keep-dim-%i" % (name , i ))
5989
+ y_dim_tags [i ] = Dim (
5990
+ kind = y_dim_tags [i ].kind , dimension = 1 , description = "%s:keep-dim-%i" % (name , i ), auto_generated = True )
5987
5991
else :
5988
5992
if out_batch_dim_axis in axes :
5989
5993
out_batch_dim_axis = None
@@ -6184,7 +6188,7 @@ def get_out_data_from_opts(cls, name, sources, axis=None, out_spatial_dim=None,
6184
6188
out = common_source .copy_template (name = "%s_output" % name )
6185
6189
if not out_spatial_dim :
6186
6190
out_spatial_dim = Dim (
6187
- kind = Dim .Types .Spatial , description = "%s:stack" % name , dimension = len (sources ))
6191
+ kind = Dim .Types .Spatial , description = "%s:stack" % name , dimension = len (sources ), auto_generated = True )
6188
6192
assert out_spatial_dim .dimension == len (sources )
6189
6193
out = out .copy_add_dim_by_tag (axis = axis , dim_tag = out_spatial_dim , unbroadcast = True )
6190
6194
return out
@@ -6316,7 +6320,8 @@ def get_out_data_from_opts(cls, name, sources, axes, padding=None, size=None, ke
6316
6320
dim_tags = list (data .dim_tags )
6317
6321
for i , a in enumerate (axes ):
6318
6322
dim_tags [a ] = Dim (
6319
- kind = dim_tags [a ].kind , description = "%s:weighted-sum:%i" % (name , i ), dimension = res_dims [i ])
6323
+ kind = dim_tags [a ].kind , description = "%s:weighted-sum:%i" % (name , i ), dimension = res_dims [i ],
6324
+ auto_generated = True )
6320
6325
data = data .copy_template_new_dim_tags (dim_tags , keep_special_axes = True )
6321
6326
else :
6322
6327
assert all ([d == 1 for d in res_dims ])
@@ -6630,7 +6635,7 @@ def get_out_data_from_opts(cls, name, sources, axis="T", out_dim=None, **kwargs)
6630
6635
data = data .copy_move_axis (old_axis = axis , new_axis = 0 )
6631
6636
data = data .copy_with_batch_dim_axis (1 )
6632
6637
if not out_dim :
6633
- out_dim = Dim (kind = in_dim .kind , description = "%s:chunking" % name )
6638
+ out_dim = Dim (kind = in_dim .kind , description = "%s:chunking" % name , auto_generated = True )
6634
6639
data = data .copy_template_replace_dim_tag (axis = 0 , new_dim_tag = out_dim )
6635
6640
data .time_dim_axis = 0
6636
6641
return data
@@ -7189,9 +7194,9 @@ def __init__(self, axis, amount, pad=True, adjust_size_info=True, **kwargs):
7189
7194
self .output .size_placeholder [axis_wob ] + size_delta , 0 , tf .shape (shifted )[axis ])
7190
7195
from ..util .data import Dim
7191
7196
Dim (
7192
- kind = Dim .Types .Spatial , description = "shift_axis" ,
7197
+ kind = Dim .Types .Spatial , description = "%s_shift_axis" % self . name ,
7193
7198
dyn_size = new_size , batch = self .output .batch ,
7194
- src_data = self .output , src_axis = axis )
7199
+ src_data = self .output , src_axis = axis , auto_generated = True )
7195
7200
self .output .size_placeholder [axis_wob ] = new_size
7196
7201
7197
7202
@classmethod
@@ -7210,7 +7215,7 @@ def get_out_data_from_opts(cls, name, amount, axis, pad, sources=(), **kwargs):
7210
7215
axis = out .get_axis_from_description (axis )
7211
7216
tag = out .dim_tags [axis ]
7212
7217
dim = None if tag .dimension is None else max (0 , tag .dimension - abs (amount ))
7213
- tag = Dim (kind = tag .kind , description = "%s_shift_axis" % name , dimension = dim )
7218
+ tag = Dim (kind = tag .kind , description = "%s_shift_axis" % name , dimension = dim , auto_generated = True )
7214
7219
return out .copy_template_replace_dim_tag (axis = axis , new_dim_tag = tag )
7215
7220
7216
7221
@@ -7319,7 +7324,7 @@ def get_out_data_from_opts(cls, factor, axis, sources, name, out_dim=None, **kwa
7319
7324
if out_dim :
7320
7325
assert out_dim .dimension == dim
7321
7326
else :
7322
- out_dim = Dim (kind = tag .kind , description = "%s_resize" % name , dimension = dim )
7327
+ out_dim = Dim (kind = tag .kind , description = "%s_resize" % name , dimension = dim , auto_generated = True )
7323
7328
return out .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_dim )
7324
7329
7325
7330
@@ -7410,7 +7415,8 @@ def get_out_data_from_opts(cls, name, sources, axis="T", out_dim=None, **kwargs)
7410
7415
axis = out .get_axis_from_description (axis , allow_int = False )
7411
7416
in_dim = out .dim_tags [axis ]
7412
7417
if not out_dim :
7413
- out_dim = Dim (kind = in_dim .kind , description = "%s_removed_items" , dimension = None , derived_from_tag = in_dim )
7418
+ out_dim = Dim (
7419
+ kind = in_dim .kind , description = "%s_removed_items" , dimension = None , derived_from_tag = in_dim , auto_generated = True )
7414
7420
return out .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_dim )
7415
7421
7416
7422
@@ -8582,18 +8588,17 @@ def get_out_data_from_opts(cls, name, network,
8582
8588
elif isinstance (d , int ):
8583
8589
d = Dim (
8584
8590
kind = Dim .Types .Spatial if i < len (shape ) - 1 else Dim .Types .Feature ,
8585
- description = "%s:static:%i" % (name , i ),
8591
+ description = "%s:static:%i" % (name , i ), auto_generated = True ,
8586
8592
dimension = d )
8587
8593
else :
8588
8594
raise TypeError ("Layer %r: invalid type %s in shape %r" % (name , type (d ), shape ))
8589
8595
dim_tags .append (d )
8590
8596
if add_time_axis :
8591
8597
dim_tags .insert (
8592
- 0 , Dim (kind = Dim .Types .Time , description = "%s:dummy-time" % name , dimension = 1 ))
8598
+ 0 , Dim (kind = Dim .Types .Time , description = "%s:dummy-time" % name , dimension = 1 , auto_generated = True ))
8593
8599
if add_batch_axis :
8594
8600
dim_tags .insert (
8595
- 0 , Dim (
8596
- kind = Dim .Types .Batch , description = "batch" , batch = network .get_global_batch_info ()))
8601
+ 0 , Dim (kind = Dim .Types .Batch , description = "batch" , batch = network .get_global_batch_info ()))
8597
8602
return Data (
8598
8603
name = "%s_output" % name , dim_tags = dim_tags , dtype = dtype ,
8599
8604
batch = network .get_global_batch_info () if add_batch_axis else None )
0 commit comments