-
Notifications
You must be signed in to change notification settings - Fork 21.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
aten/src/ATen/native/TensorShape.cpp
Outdated
@@ -121,6 +121,93 @@ Tensor repeat(const Tensor& self, IntList repeats) { | |||
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.
aten/src/ATen/native/TensorShape.cpp
Outdated
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.
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.