TensroIterator preserve format for binary, ternary operators.#28291
TensroIterator preserve format for binary, ternary operators.#28291VitalyFedyunin wants to merge 22 commits intogh/VitalyFedyunin/17/basefrom
Conversation
[ghstack-poisoned]
…rs." [ghstack-poisoned]
…nary operators." [ghstack-poisoned]
…ternary operators." [ghstack-poisoned]
…tors." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…rs." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…rmat for binary, ternary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…"TensroIterator preserve format for binary, ternary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…ary, ternary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…rve format for binary, ternary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
|
@ngimel I will add tests and benchmark results, so far I just looking your opinion on structure. |
…ry operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…y, ternary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
… operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…ternary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…rators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
| # lambda x, y: x.abs(), # https://github.com/pytorch/pytorch/issues/24531 | ||
| # lambda x, y: x.acos(), # https://github.com/pytorch/pytorch/issues/24532 | ||
| lambda x, y: x.add(y, alpha=3), | ||
| lambda x, y: x.addcdiv(2, y, y), |
There was a problem hiding this comment.
given that y is contiguous, what are we testing here? Should it have been x, y in the arguments (same for addcmul)
There was a problem hiding this comment.
Addressed by adding more tests
| op.tensor = at::empty(tensor_shape, op.options()); | ||
| op.tensor.unsafeGetTensorImpl()->empty_tensor_restride( | ||
| MemoryFormat::ChannelsLast); | ||
| op.stride_bytes = apply_perm_and_mul(op.tensor.strides(), element_size); |
There was a problem hiding this comment.
I cannot convince myself that op.stride_bytes and op.tensor.strides() are guaranteed to be consistent (one is defined by perm_ which can be whatever, and the other is hardcoded nhwc), and tests are only testing contiguity of output which is guaranteed by empty_tensor_restride, not its correctness.
There was a problem hiding this comment.
Addressed by adding comment
…nary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…perators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…inary, ternary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
… operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…rnary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…rnary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
…rnary operators." Differential Revision: [D18044977](https://our.internmc.facebook.com/intern/diff/D18044977) [ghstack-poisoned]
|
@VitalyFedyunin merged this pull request in a7df369. |
Summary: Pull Request resolved: pytorch/pytorch#28291 Test Plan: Imported from OSS Differential Revision: D18044977 Pulled By: VitalyFedyunin fbshipit-source-id: 793bab47d8cfc1b0d6229f1b0688352ee94c3e48
ghstack-source-id: 2a042e5 Pull Request resolved: pytorch/pytorch#28291
Stack from ghstack:
resize_op. #28292 Add memory format support to theresize_op.operator==of TensorOptions as confusing one #28076 Killoperator==of TensorOptions as confusing oneresize_as_operator #27979 Add memory format support toresize_as_operatorDifferential Revision: D18044977