I wish to create a custom pooling layer which can efficiently work on GPUs.
For instance, I have following input tensor
in = <tf.Tensor: shape=(4, 5), dtype=float32, numpy=
array([[0., 1., 2., 3., 4.],
[5., 1., 7., 3., 2.],
[9., 9., 2., 3., 5.],
[2., 6., 2., 8., 4.]], dtype=float32)>
I wish to provide a list of column numbers over which I wish to perform pooling, for instance, I wish to perform max pooling over following column indices
pool_cols =
[<tf.Tensor: shape=(2,), dtype=int32, numpy=array([0, 1], dtype=int32)>,
<tf.Tensor: shape=(3,), dtype=int32, numpy=array([2, 3, 4], dtype=int32)>]
And the resultant pooled output will look like
pooled_out = <tf.Tensor: shape=(4, 2), dtype=float32, numpy=
array([[1., 4.],
[5., 7.],
[9., 5.],
[6., 8.]], dtype=float32)>
What would be the most efficient way to do this?