简体   繁体   中英

Is there any contiguous function in tensorflow2.0?

In PyTorch, people usually call tensor.permute(2,0,1,3).contiguous() . If I call this function in tensorflow 2.0, is it enough to just call tf.reshape(tensor, perm = [2, 0, 1, 3]) ?

or what is a contiguous function in tensorflow 2.0?

From the official docs of tf.transpose ,

In NumPy , transposes are memory-efficient constant time operations as they simply return a new view of the same data with adjusted strides . TensorFlow does not support strides, so transpose returns a new tensor with the items permuted .

Also, TensorFlow doesn't seem to support Fortran (Column-Major) ordering. Hence, I think we automatically get Contiguous (Row-Major) ordering tensor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM