Skip to content

Commit 16e8bfe

Browse files
manuelcandalesfacebook-github-bot
authored andcommitted
Fix op transpose_copy (#758)
Summary: Pull Request resolved: #758 ghstack-source-id: 203458980 exported-using-ghexport Reviewed By: SS-JIA Differential Revision: D50104694 fbshipit-source-id: e1020aeca472281e77c45b2e144410ed4d64a4cf
1 parent fc76d9e commit 16e8bfe

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

kernels/portable/cpu/op_transpose_copy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ Tensor& transpose_copy_int_out(
3939
out);
4040

4141
if (dim0 < 0) {
42-
dim0 += nonzero_dim(out);
42+
dim0 += nonzero_dim(in);
4343
}
4444
if (dim1 < 0) {
45-
dim1 += nonzero_dim(out);
45+
dim1 += nonzero_dim(in);
4646
}
4747

4848
Tensor::SizesType expected_out_size[kTensorDimensionLimit];

kernels/portable/cpu/util/transpose_util.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,11 @@ inline void get_transpose_out_target_size(
160160
size_t* out_ndim) {
161161
*out_ndim = in.dim();
162162

163-
size_t i = 0;
164-
for (; i < in.dim() - 1; ++i) {
163+
if (in.dim() == 0) {
164+
return;
165+
}
166+
167+
for (size_t i = 0; i < in.dim(); ++i) {
165168
out_sizes[i] = in.size(i);
166169
}
167170
out_sizes[dim0] = in.size(dim1);

0 commit comments

Comments
 (0)