I’m not sure I understand the use case correctly.
Based on your first code snippet it seems you are trying to create a contiguous tensor, so you wouldn’t need to pass a specific memory format to the initialization of the tensor.
Let me know, if I misunderstand the use case.