Skip to content

Add memory format support to resize_as_ operator#27979

Closed
VitalyFedyunin wants to merge 24 commits intogh/VitalyFedyunin/14/basefrom
gh/VitalyFedyunin/14/head
Closed

Add memory format support to resize_as_ operator#27979
VitalyFedyunin wants to merge 24 commits intogh/VitalyFedyunin/14/basefrom
gh/VitalyFedyunin/14/head

Conversation

@VitalyFedyunin
Copy link
Contributor

@VitalyFedyunin VitalyFedyunin commented Oct 15, 2019

Rationale to add optional memory format to resize_as_ and resize_ operators is the fact that they are frequently used as inplace empty_like and empty operators inside of our code base. So having them to accept memory format similarly to empty_like and empty seems to be logical.

We could also add two new operators, but it will be more confusing (taking into account that renaming existing operators in not an option).


Stack from ghstack:

Adds memory_format keyword argument (positional for cpp).

'Preserve' behavior now follows next rules:

  1. If tensor is non-overlapping and dense - output tensor will have the same strides as input tensor.
  2. If not (1) and tensor is stored in the channels last format, output tensor going to have channels last format.
  3. Output tensor is going to be contiguous in all other cases.

Dense tensor is the tensor that store values in a contiguous block of memory.
Non-overlapping tensor is the tensor in which elements occupy individual non-repetitive memory.

Differential Revision: D17980311

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants