Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit d26f79a

Browse files
Merge pull request #261 from facebookresearch/pr/reduction1D
Fix and reactivate 1-D reduction tests
2 parents 5e21c1a + 84760e6 commit d26f79a

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

include/tc/core/utils/dlpack-inl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ inline void SetStrides(DLTensor& t, const std::vector<int64_t>& strides) {
109109

110110
inline void SetStridesFromSizes(DLTensor& t, const std::vector<int64_t>&) {
111111
auto ndim = t.ndim;
112+
if (ndim == 0) {
113+
return;
114+
}
112115
t.strides[ndim - 1] = 1;
113116
for (int i = ndim - 2; i >= 0; --i) {
114117
t.strides[i] = t.strides[i + 1] * t.shape[i + 1];

test/test_tc_mapper.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,30 +139,30 @@ TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv0) {
139139
Check(A, mappingOptions, 0);
140140
}
141141

142-
TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv1) {
142+
TEST_F(TcMapper1DReductionTest, Reduction1Dv1) {
143143
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
144144
.tile(0)
145-
.mapToBlocks({})
145+
.mapToBlocks({1})
146146
.mapToThreads({16});
147147
LOG(INFO) << mappingOptions << endl;
148148
at::Tensor A = at::CUDA(at::kFloat).rand({M});
149149
Check(A, mappingOptions, 1);
150150
}
151151

152-
TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv2) {
152+
TEST_F(TcMapper1DReductionTest, Reduction1Dv2) {
153153
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
154154
.tile(0)
155-
.mapToBlocks({})
155+
.mapToBlocks({1})
156156
.mapToThreads({16});
157157
LOG(INFO) << mappingOptions << endl;
158158
at::Tensor A = at::CUDA(at::kFloat).rand({M});
159159
Check(A, mappingOptions, 2);
160160
}
161161

162-
TEST_F(TcMapper1DReductionTest, DISABLED_Reduction1Dv3) {
162+
TEST_F(TcMapper1DReductionTest, Reduction1Dv3) {
163163
auto mappingOptions = tc::CudaMappingOptions::makeNaiveCudaMappingOptions()
164164
.tile(0)
165-
.mapToBlocks({})
165+
.mapToBlocks({1})
166166
.mapToThreads({16});
167167
LOG(INFO) << mappingOptions << endl;
168168
at::Tensor A = at::CUDA(at::kFloat).rand({M});

0 commit comments

Comments
 (0)