fixed invalid memory access, caused by iterator invalidation
fixed invalid memory access, caused by iterator invalidation

Summary: ASAN caught invalid memory problems in 3 of the tests in PatternNetTransformTests. The cause was pushing elements into a vector, that although will remain the same when in scope, can be relocated when resized; thus invalidating the iterator pointer.

Reviewed By: bwasti

Differential Revision: D5510112

fbshipit-source-id: affb11dbd221c826e108136789ef11c96c5d9843

pietern/caffe2,xzturn/caffe2,sf-wind/caffe2,davinwang/caffe2,sf-wind/caffe2,sf-wind/caffe2,davinwang/caffe2,sf-wind/caffe2,Yangqing/caffe2,xzturn/caffe2,Yangqing/caffe2,xzturn/caffe2,davinwang/caffe2,xzturn/caffe2,Yangqing/caffe2,caffe2/caffe2,sf-wind/caffe2,davinwang/caffe2,pietern/caffe2,pietern/caffe2,Yangqing/caffe2,Yangqing/caffe2,xzturn/caffe2,pietern/caffe2,davinwang/caffe2,pietern/caffe2