tf.sequence_mask
>>> x=[1,2,3]>>> z=tf.sequence_mask(x)>>> sess.run(z)array([[ True, False, False], [ True, True, False], [ True, True, True]])