Implement torch.reshape and Tensor.reshape#5575
Conversation
This implements reshape which has similar semantics to numpy.reshape. It will return a view of the source tensor if possible. Otherwise, it returns a copy.
| return result; | ||
| } | ||
|
|
||
| static std::vector<int64_t> infer_size(IntList shape, int64_t numel) { |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| static std::vector<int64_t> infer_size(IntList shape, int64_t numel) { | ||
| auto res = shape.vec(); | ||
| int64_t newsize = 1; | ||
| auto infer_dim = at::optional<int64_t>(); |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| view_d--; | ||
| } | ||
| if (view_numel != tensor_numel) { | ||
| return {}; |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
* Implement torch.reshape and Tensor.reshape This implements reshape which has similar semantics to numpy.reshape. It will return a view of the source tensor if possible. Otherwise, it returns a copy. * Remove in-place reshape_ that was an alias for resize_ * Update documentation
This implements reshape which has similar semantics to numpy.reshape. It
will return a view of the source tensor if possible. Otherwise, it
returns a copy.