Add assert about the shape in the graph.

fix gh-1738