assert_shape function
Adding an assert_shape function where the user can hang shape information in the graph without risk of changing results.
With these two changes, we could add code like this to the current conv2d function such as
if img_shape is not None:
print deprecation warning
img = assert_shape(img, img_shape)
if ker_shape is not None:
return ConvOp(no shape information)(img, ker)
Then during optimization (in the specialization round) we would look for convOp applied to inputs of known shape, and then swap the general ConvOp for one with the shape hard-coded. The advantage here is that we present a more consistent interface for building graphs with conv2d (no other ops take shape arguments) and we can get the benefit of hard-coded shapes by graph inference even when the user forgot to specify it explicitly.
see ticket* 402 for the optimization
With these two changes, we could add code like this to the current conv2d function such as
if img_shape is not None:
print deprecation warning
img = assert_shape(img, img_shape)
if ker_shape is not None:
return ConvOp(no shape information)(img, ker)
Then during optimization (in the specialization round) we would look for convOp applied to inputs of known shape, and then swap the general ConvOp for one with the shape hard-coded. The advantage here is that we present a more consistent interface for building graphs with conv2d (no other ops take shape arguments) and we can get the benefit of hard-coded shapes by graph inference even when the user forgot to specify it explicitly.
see ticket* 402 for the optimization
Leave a comment