Commit 6e727bcd authored by traveller59's avatar traveller59
Browse files

small cpu bug fix

parent fa75f6d9
...@@ -223,13 +223,15 @@ Index getIndicePairsSubM(tv::TensorView<const Index> indicesIn, ...@@ -223,13 +223,15 @@ Index getIndicePairsSubM(tv::TensorView<const Index> indicesIn,
std::vector<Index> validPoints_(kernelVolume * (NDim + 1)); std::vector<Index> validPoints_(kernelVolume * (NDim + 1));
Index* validPoints = validPoints_.data(); Index* validPoints = validPoints_.data();
Index *pointPtr = nullptr; Index *pointPtr = nullptr;
Index index = 0; tsl::robin_map<Index, Index> hash;
for (int j = 0; j < numActIn; ++j) { for (int j = 0; j < numActIn; ++j) {
Index index = 0;
index = tv::rowArrayIdx<Index, NDim>(indicesIn.data() + j * (NDim + 1) + 1, index = tv::rowArrayIdx<Index, NDim>(indicesIn.data() + j * (NDim + 1) + 1,
outSpatialShape) + outSpatialShape) +
spatialVolume * indicesIn(j, 0); spatialVolume * indicesIn(j, 0);
gridsOut[index] = j; hash[index] = j;
} }
Index index = 0;
for (int j = 0; j < numActIn; ++j) { for (int j = 0; j < numActIn; ++j) {
numValidPoints = getValidOutPos<Index, NDim>( numValidPoints = getValidOutPos<Index, NDim>(
indicesIn.data() + j * (NDim + 1) + 1, kernelSize, stride, padding, indicesIn.data() + j * (NDim + 1) + 1, kernelSize, stride, padding,
...@@ -239,9 +241,10 @@ Index getIndicePairsSubM(tv::TensorView<const Index> indicesIn, ...@@ -239,9 +241,10 @@ Index getIndicePairsSubM(tv::TensorView<const Index> indicesIn,
auto offset = pointPtr[NDim]; auto offset = pointPtr[NDim];
index = tv::rowArrayIdx<Index, NDim>(pointPtr, outSpatialShape) + index = tv::rowArrayIdx<Index, NDim>(pointPtr, outSpatialShape) +
spatialVolume * indicesIn(j, 0); spatialVolume * indicesIn(j, 0);
if (gridsOut[index] > -1) { auto iter = hash.find(index);
if (iter != hash.end()) {
indicePairs(offset, 0, indiceNum[offset]) = j; indicePairs(offset, 0, indiceNum[offset]) = j;
indicePairs(offset, 1, indiceNum[offset]++) = gridsOut[index]; indicePairs(offset, 1, indiceNum[offset]++) = iter->second;
} }
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment