@@ -1056,7 +1056,7 @@ def get_out_data_from_opts(
1056
1056
if out_dim :
1057
1057
assert out_dim .dimension == new_dim
1058
1058
else :
1059
- out_dim = Dim (kind = dim_tag .kind , description = "%s:slice" % name , dimension = new_dim )
1059
+ out_dim = Dim (kind = dim_tag .kind , description = "%s:slice" % name , dimension = new_dim , auto_generated = True )
1060
1060
return input_data .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_dim , name = "%s_output" % name )
1061
1061
1062
1062
@@ -1236,7 +1236,7 @@ def get_out_data_from_opts(cls, name, sources=(), start=None, size=None, axis="T
1236
1236
out_spatial_dim = Dim (
1237
1237
kind = Dim .Types .Spatial ,
1238
1238
description = "sliced-time:%s" % name ,
1239
- dimension = size )
1239
+ dimension = size , auto_generated = True )
1240
1240
gather_positions_data = gather_positions_data .copy_add_dim_by_tag (
1241
1241
out_spatial_dim , unbroadcast = True , axis = start_data .batch_ndim )
1242
1242
position = InternalLayer (
@@ -2544,7 +2544,9 @@ def get_out_data_from_opts(cls, name, shape, dtype="float32", **kwargs):
2544
2544
:param str dtype:
2545
2545
:rtype: Data
2546
2546
"""
2547
- dim_tags = [d if isinstance (d , Dim ) else SpatialDim ("%s:dim%i" % (name , i ), d ) for i , d in enumerate (shape )]
2547
+ dim_tags = [
2548
+ d if isinstance (d , Dim ) else SpatialDim ("%s:dim%i" % (name , i ), d , auto_generated = True )
2549
+ for i , d in enumerate (shape )]
2548
2550
return Data (name = "%s_output" % name , dim_tags = dim_tags , dtype = dtype )
2549
2551
2550
2552
@@ -2630,7 +2632,7 @@ def get_out_data_from_opts(cls, name, network, shape, maxval, minval=0, dtype="i
2630
2632
elif isinstance (d , int ):
2631
2633
d = Dim (
2632
2634
kind = Dim .Types .Spatial if i < len (shape ) - 1 else Dim .Types .Feature ,
2633
- description = "%s:static:%i" % (name , i ),
2635
+ description = "%s:static:%i" % (name , i ), auto_generated = True ,
2634
2636
dimension = d )
2635
2637
else :
2636
2638
raise TypeError ("Layer %r: invalid type %s in shape %r" % (name , type (d ), shape ))
@@ -2696,12 +2698,12 @@ def get_out_data_from_opts(cls, name, limit, start=0, delta=1, dtype=None, spars
2696
2698
else :
2697
2699
dtype = "int32"
2698
2700
dim = len (range (start , limit , delta ))
2699
- tag = Dim (kind = Dim .Types .Spatial , dimension = dim , description = "%s:range" % name )
2701
+ tag = Dim (kind = Dim .Types .Spatial , dimension = dim , description = "%s:range" % name , auto_generated = True )
2700
2702
if out_spatial_dim :
2701
2703
tag .declare_same_as (out_spatial_dim )
2702
2704
sparse_dim = None
2703
2705
if sparse :
2704
- sparse_dim = SpatialDim ("%s:range-indices" % name )
2706
+ sparse_dim = SpatialDim ("%s:range-indices" % name , auto_generated = True )
2705
2707
return Data (name = "%s_output" % name , dim_tags = [tag ], dtype = dtype , sparse_dim = sparse_dim )
2706
2708
2707
2709
@@ -2816,7 +2818,7 @@ def get_out_data_from_opts(cls, name, sources, dtype="int32", sparse=False, out_
2816
2818
dim_tag = Dim .get_tag_from_size_tensor (source .placeholder )
2817
2819
if not dim_tag :
2818
2820
dim_tag = Dim (
2819
- kind = Dim .Types .Spatial , description = "%s_input_len" % name ,
2821
+ kind = Dim .Types .Spatial , description = "%s_input_len" % name , auto_generated = True ,
2820
2822
batch = source .batch , control_flow_ctx = source .control_flow_ctx ,
2821
2823
dyn_size_ext = source )
2822
2824
if source .placeholder is not None :
@@ -2957,7 +2959,7 @@ def get_out_data_from_opts(cls, name, sources, n_out=NotSpecified, out_dim=None,
2957
2959
if out_dim :
2958
2960
assert out_dim .dimension == dim
2959
2961
else :
2960
- out_dim = FeatureDim ("%s:gating" % name , dimension = dim )
2962
+ out_dim = FeatureDim ("%s:gating" % name , dimension = dim , auto_generated = True )
2961
2963
if n_out is not NotSpecified :
2962
2964
assert n_out == dim
2963
2965
return Data (
@@ -3096,15 +3098,15 @@ def get_out_data_from_opts(cls, name, network, sources, window_size=None, window
3096
3098
filter_size = window_size , stride = stride , dilation_rate = 1 , padding = padding )
3097
3099
out_spatial_dim = Dim (
3098
3100
kind = Dim .Types .Spatial , description = "%s:spatial" % name ,
3099
- dimension = dim , derived_from_tag = in_spatial_dim ,
3101
+ dimension = dim , derived_from_tag = in_spatial_dim , auto_generated = True ,
3100
3102
batch = data .batch , control_flow_ctx = data .control_flow_ctx )
3101
3103
data = data .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_spatial_dim )
3102
3104
new_dim_axis = axis + 1 # add new axis right after
3103
3105
if window_dim :
3104
3106
assert window_dim .dimension == window_size
3105
3107
else :
3106
3108
window_dim = Dim (
3107
- kind = Dim .Types .Spatial , description = "%s:window" % name , dimension = window_size )
3109
+ kind = Dim .Types .Spatial , description = "%s:window" % name , dimension = window_size , auto_generated = True )
3108
3110
return data .copy_add_dim_by_tag (axis = new_dim_axis , dim_tag = window_dim , unbroadcast = True )
3109
3111
3110
3112
# noinspection PyMethodOverriding
@@ -3602,9 +3604,11 @@ def _get_axis_size_splits_num_splits(cls, name, input_data, axis=None,
3602
3604
err_prefix , out_dims , dim , input_data )
3603
3605
if not out_dims :
3604
3606
assert size_splits
3605
- out_dims = [Dim (
3606
- kind = input_data .dim_tags [axis ].kind , description = "%s_split%i" % (name , idx ),
3607
- dimension = size_splits [idx ]) for idx in range (len (size_splits ))]
3607
+ out_dims = [
3608
+ Dim (
3609
+ kind = input_data .dim_tags [axis ].kind , description = "%s_split%i" % (name , idx ),
3610
+ dimension = size_splits [idx ], auto_generated = True )
3611
+ for idx in range (len (size_splits ))]
3608
3612
return axis , out_dims
3609
3613
3610
3614
def _make_split_layer (self , idx ):
@@ -3884,6 +3888,7 @@ def get_out_data_from_opts(cls, name, axis, dims, pad_to_multiples=None, sources
3884
3888
kind = axis_dim_tag .kind ,
3885
3889
description = "%s_split_dims%i_rem" % (name , rem_dim_idx ),
3886
3890
dimension = resolved_shape_dims [rem_dim_idx ],
3891
+ auto_generated = True ,
3887
3892
derived_from_tag = axis_dim_tag ,
3888
3893
batch = axis_dim_tag .batch , control_flow_ctx = axis_dim_tag .control_flow_ctx )
3889
3894
if rem_dim .dimension is None and axis_dim_tag .dyn_size_ext is not None :
@@ -3900,7 +3905,7 @@ def get_out_data_from_opts(cls, name, axis, dims, pad_to_multiples=None, sources
3900
3905
Dim (
3901
3906
kind = axis_dim_tag .kind if not axis_dim_tag .is_batch_dim () else Dim .Types .Spatial ,
3902
3907
description = "%s_split_dims%i" % (name , i ),
3903
- dimension = shape_dim )
3908
+ dimension = shape_dim , auto_generated = True )
3904
3909
if rem_dim is None or i != rem_dim_idx else rem_dim
3905
3910
for i , shape_dim in enumerate (resolved_shape_dims ))
3906
3911
out_batch = data .batch
@@ -4175,7 +4180,7 @@ def get_out_data_from_opts(cls, name, sources, num_axes, in_dim="T", out_dims=No
4175
4180
assert not declare_same_sizes_as
4176
4181
else :
4177
4182
out_dims = [
4178
- SpatialDim ("%s:unflatten-nd:%i" % (name , i ))
4183
+ SpatialDim ("%s:unflatten-nd:%i" % (name , i ), auto_generated = True )
4179
4184
for i in range (num_axes )]
4180
4185
if declare_same_sizes_as :
4181
4186
for i , other in declare_same_sizes_as .items ():
@@ -4255,7 +4260,7 @@ def get_out_data_from_opts(cls, name, axis, dim=1, sources=(), **kwargs):
4255
4260
else :
4256
4261
new_dim = Dim (
4257
4262
kind = Dim .Types .Feature if init_axis .lower () == "f" else Dim .Types .Spatial ,
4258
- description = "%s_expand_dims" % name ,
4263
+ description = "%s_expand_dims" % name , auto_generated = True ,
4259
4264
dimension = dim )
4260
4265
data = data .copy_template (name = "%s_output" % name )
4261
4266
data = data .copy_add_dim_by_tag (new_dim , unbroadcast = True , axis = axis )
@@ -4411,7 +4416,7 @@ def get_out_data_from_opts(cls, name, sources, axis, repetitions, out_dim=None,
4411
4416
if isinstance (repetitions , int ):
4412
4417
out_dim = tag * repetitions
4413
4418
else :
4414
- out_dim = Dim (description = "repeated:%s" % name , kind = tag .kind , derived_from_tag = tag )
4419
+ out_dim = Dim (description = "repeated:%s" % name , kind = tag .kind , derived_from_tag = tag , auto_generated = True )
4415
4420
return data .copy_template_replace_dim_tag (axis = data .get_batch_axis (0 ), new_dim_tag = out_dim )
4416
4421
4417
4422
@@ -4821,12 +4826,12 @@ def map_axis_name(s):
4821
4826
pass
4822
4827
else :
4823
4828
out .sparse_dim = Dim (
4824
- kind = Dim .Types .Feature , dimension = set_sparse_dim , description = "%s:set-sparse-dim" % name )
4829
+ kind = Dim .Types .Feature , dimension = set_sparse_dim , description = "%s:set-sparse-dim" % name , auto_generated = True )
4825
4830
if increase_sparse_dim :
4826
4831
assert out .sparse
4827
4832
out .sparse_dim = Dim (
4828
4833
kind = Dim .Types .Feature , dimension = out .sparse_dim .dimension + 1 ,
4829
- description = "%s:inc-sparse-dim" % name )
4834
+ description = "%s:inc-sparse-dim" % name , auto_generated = True )
4830
4835
if batch_dim_base :
4831
4836
out .batch = batch_dim_base .output .batch
4832
4837
return out
@@ -5103,7 +5108,7 @@ def transform_input(cls, input_data, network, in_dim=None, in_spatial_dims=None,
5103
5108
cls ._check_defined_in_spatial_dims (len (in_spatial_dims ) == 1 )
5104
5109
if input_expand_dims :
5105
5110
for i in range (input_expand_dims ):
5106
- dim_tag = SpatialDim ("input_expand_dims:%i" % i , dimension = 1 )
5111
+ dim_tag = SpatialDim ("input_expand_dims:%i" % i , dimension = 1 , auto_generated = True )
5107
5112
input_data = input_data .copy_add_dim_by_tag (dim_tag , unbroadcast = True )
5108
5113
in_spatial_dims .append (dim_tag )
5109
5114
if input_split_feature_dim :
@@ -5280,10 +5285,10 @@ def get_out_data_from_opts(
5280
5285
filter_size = filter_size [i ], stride = strides [i ], dilation_rate = dilation_rate [i ], padding = padding )
5281
5286
dim_tags .append (Dim (
5282
5287
kind = Dim .Types .Spatial , description = "%s:conv:s%i" % (name , i ), dimension = new_dim ,
5283
- derived_from_tag = old_tag , undefined = not old_tag ))
5288
+ derived_from_tag = old_tag , undefined = not old_tag , auto_generated = True ))
5284
5289
if not out_dim :
5285
5290
assert n_out
5286
- out_dim = FeatureDim ("%s:channel" % name , dimension = n_out )
5291
+ out_dim = FeatureDim ("%s:channel" % name , dimension = n_out , auto_generated = True )
5287
5292
dim_tags .append (out_dim )
5288
5293
feature_dim_axis = NotSpecified
5289
5294
# Swap the dims if the input dim order doesn't fit the flag auto_use_channel_first.
@@ -5784,10 +5789,10 @@ def get_out_data_from_opts(cls, name, sources, network,
5784
5789
padding = padding , output_padding = output_padding [i ]) - remove_padding [i ] * 2
5785
5790
dim_tags .append (Dim (
5786
5791
kind = Dim .Types .Spatial , description = "%s:conv:s%i" % (name , i ), dimension = new_dim ,
5787
- derived_from_tag = old_tag , undefined = not old_tag ))
5792
+ derived_from_tag = old_tag , undefined = not old_tag , auto_generated = True ))
5788
5793
if not out_dim :
5789
5794
assert n_out
5790
- out_dim = FeatureDim ("%s:channel" % name , dimension = n_out )
5795
+ out_dim = FeatureDim ("%s:channel" % name , dimension = n_out , auto_generated = True )
5791
5796
dim_tags .append (out_dim )
5792
5797
return Data (
5793
5798
name = "%s_output" % name , dim_tags = dim_tags ,
@@ -6000,7 +6005,8 @@ def get_out_data_from_opts(cls, name, sources, mode="", axes=None, axis=None, ke
6000
6005
out_time_dim_axis = x .time_dim_axis
6001
6006
if keep_dims :
6002
6007
for i in axes :
6003
- y_dim_tags [i ] = Dim (kind = y_dim_tags [i ].kind , dimension = 1 , description = "%s:keep-dim-%i" % (name , i ))
6008
+ y_dim_tags [i ] = Dim (
6009
+ kind = y_dim_tags [i ].kind , dimension = 1 , description = "%s:keep-dim-%i" % (name , i ), auto_generated = True )
6004
6010
else :
6005
6011
if out_batch_dim_axis in axes :
6006
6012
out_batch_dim_axis = None
@@ -6201,7 +6207,7 @@ def get_out_data_from_opts(cls, name, sources, axis=None, out_spatial_dim=None,
6201
6207
out = common_source .copy_template (name = "%s_output" % name )
6202
6208
if not out_spatial_dim :
6203
6209
out_spatial_dim = Dim (
6204
- kind = Dim .Types .Spatial , description = "%s:stack" % name , dimension = len (sources ))
6210
+ kind = Dim .Types .Spatial , description = "%s:stack" % name , dimension = len (sources ), auto_generated = True )
6205
6211
assert out_spatial_dim .dimension == len (sources )
6206
6212
out = out .copy_add_dim_by_tag (axis = axis , dim_tag = out_spatial_dim , unbroadcast = True )
6207
6213
return out
@@ -6333,7 +6339,8 @@ def get_out_data_from_opts(cls, name, sources, axes, padding=None, size=None, ke
6333
6339
dim_tags = list (data .dim_tags )
6334
6340
for i , a in enumerate (axes ):
6335
6341
dim_tags [a ] = Dim (
6336
- kind = dim_tags [a ].kind , description = "%s:weighted-sum:%i" % (name , i ), dimension = res_dims [i ])
6342
+ kind = dim_tags [a ].kind , description = "%s:weighted-sum:%i" % (name , i ), dimension = res_dims [i ],
6343
+ auto_generated = True )
6337
6344
data = data .copy_template_new_dim_tags (dim_tags , keep_special_axes = True )
6338
6345
else :
6339
6346
assert all ([d == 1 for d in res_dims ])
@@ -6484,7 +6491,8 @@ def get_out_data_from_opts(cls, name, sources, axis="T", out_dim=None, size_base
6484
6491
assert not out_dim
6485
6492
out_dim = size_base .output .get_time_dim_tag ()
6486
6493
if not out_dim :
6487
- out_dim = (repeat if isinstance (repeat , int ) else SpatialDim ("%s:repeat" % repeat .name )) + in_dim
6494
+ out_dim = (
6495
+ repeat if isinstance (repeat , int ) else SpatialDim ("%s:repeat" % repeat .name , auto_generated = True )) + in_dim
6488
6496
assert out_dim .dimension == out_dim_int
6489
6497
x = x .copy_template_replace_dim_tag (axis = axis_int , new_dim_tag = out_dim )
6490
6498
if isinstance (repeat , LayerBase ):
@@ -6647,7 +6655,7 @@ def get_out_data_from_opts(cls, name, sources, axis="T", out_dim=None, **kwargs)
6647
6655
data = data .copy_move_axis (old_axis = axis , new_axis = 0 )
6648
6656
data = data .copy_with_batch_dim_axis (1 )
6649
6657
if not out_dim :
6650
- out_dim = Dim (kind = in_dim .kind , description = "%s:chunking" % name )
6658
+ out_dim = Dim (kind = in_dim .kind , description = "%s:chunking" % name , auto_generated = True )
6651
6659
data = data .copy_template_replace_dim_tag (axis = 0 , new_dim_tag = out_dim )
6652
6660
data .time_dim_axis = 0
6653
6661
return data
@@ -7143,7 +7151,7 @@ def find_axis(a_axis, b_axis):
7143
7151
7144
7152
if not b_var_dims and add_var2_if_empty :
7145
7153
b_var_dims .append (
7146
- SpatialDim ("%s:dot:dummy-var2" % name , dimension = 1 ))
7154
+ SpatialDim ("%s:dot:dummy-var2" % name , dimension = 1 , auto_generated = True ))
7147
7155
7148
7156
dim_tags = list (a_rem_dims + a_var_dims + b_var_dims )
7149
7157
return Data (
@@ -7206,9 +7214,9 @@ def __init__(self, axis, amount, pad=True, adjust_size_info=True, **kwargs):
7206
7214
self .output .size_placeholder [axis_wob ] + size_delta , 0 , tf .shape (shifted )[axis ])
7207
7215
from ..util .data import Dim
7208
7216
Dim (
7209
- kind = Dim .Types .Spatial , description = "shift_axis" ,
7217
+ kind = Dim .Types .Spatial , description = "%s_shift_axis" % self . name ,
7210
7218
dyn_size = new_size , batch = self .output .batch ,
7211
- src_data = self .output , src_axis = axis )
7219
+ src_data = self .output , src_axis = axis , auto_generated = True )
7212
7220
self .output .size_placeholder [axis_wob ] = new_size
7213
7221
7214
7222
@classmethod
@@ -7227,7 +7235,7 @@ def get_out_data_from_opts(cls, name, amount, axis, pad, sources=(), **kwargs):
7227
7235
axis = out .get_axis_from_description (axis )
7228
7236
tag = out .dim_tags [axis ]
7229
7237
dim = None if tag .dimension is None else max (0 , tag .dimension - abs (amount ))
7230
- tag = Dim (kind = tag .kind , description = "%s_shift_axis" % name , dimension = dim )
7238
+ tag = Dim (kind = tag .kind , description = "%s_shift_axis" % name , dimension = dim , auto_generated = True )
7231
7239
return out .copy_template_replace_dim_tag (axis = axis , new_dim_tag = tag )
7232
7240
7233
7241
@@ -7336,7 +7344,7 @@ def get_out_data_from_opts(cls, factor, axis, sources, name, out_dim=None, **kwa
7336
7344
if out_dim :
7337
7345
assert out_dim .dimension == dim
7338
7346
else :
7339
- out_dim = Dim (kind = tag .kind , description = "%s_resize" % name , dimension = dim )
7347
+ out_dim = Dim (kind = tag .kind , description = "%s_resize" % name , dimension = dim , auto_generated = True )
7340
7348
return out .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_dim )
7341
7349
7342
7350
@@ -7427,7 +7435,8 @@ def get_out_data_from_opts(cls, name, sources, axis="T", out_dim=None, **kwargs)
7427
7435
axis = out .get_axis_from_description (axis , allow_int = False )
7428
7436
in_dim = out .dim_tags [axis ]
7429
7437
if not out_dim :
7430
- out_dim = Dim (kind = in_dim .kind , description = "%s_removed_items" , dimension = None , derived_from_tag = in_dim )
7438
+ out_dim = Dim (
7439
+ kind = in_dim .kind , description = "%s_removed_items" , dimension = None , derived_from_tag = in_dim , auto_generated = True )
7431
7440
return out .copy_template_replace_dim_tag (axis = axis , new_dim_tag = out_dim )
7432
7441
7433
7442
@@ -8599,18 +8608,17 @@ def get_out_data_from_opts(cls, name, network,
8599
8608
elif isinstance (d , int ):
8600
8609
d = Dim (
8601
8610
kind = Dim .Types .Spatial if i < len (shape ) - 1 else Dim .Types .Feature ,
8602
- description = "%s:static:%i" % (name , i ),
8611
+ description = "%s:static:%i" % (name , i ), auto_generated = True ,
8603
8612
dimension = d )
8604
8613
else :
8605
8614
raise TypeError ("Layer %r: invalid type %s in shape %r" % (name , type (d ), shape ))
8606
8615
dim_tags .append (d )
8607
8616
if add_time_axis :
8608
8617
dim_tags .insert (
8609
- 0 , Dim (kind = Dim .Types .Time , description = "%s:dummy-time" % name , dimension = 1 ))
8618
+ 0 , Dim (kind = Dim .Types .Time , description = "%s:dummy-time" % name , dimension = 1 , auto_generated = True ))
8610
8619
if add_batch_axis :
8611
8620
dim_tags .insert (
8612
- 0 , Dim (
8613
- kind = Dim .Types .Batch , description = "batch" , batch = network .get_global_batch_info ()))
8621
+ 0 , Dim (kind = Dim .Types .Batch , description = "batch" , batch = network .get_global_batch_info ()))
8614
8622
return Data (
8615
8623
name = "%s_output" % name , dim_tags = dim_tags , dtype = dtype ,
8616
8624
batch = network .get_global_batch_info () if add_batch_axis else None )
0 commit comments