chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,244 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author Yurii Shyrma (iuriish@yahoo.com), created on 14.03.2019
|
||||
//
|
||||
#include <helpers/Loops.h>
|
||||
|
||||
using namespace simdOps;
|
||||
|
||||
// Helper function to safely convert index to output type
|
||||
template<typename Z>
|
||||
SD_INLINE SD_HOST_DEVICE Z convertIndexToZ(sd::LongType index) {
|
||||
if constexpr (any_my_string_v<Z>) {
|
||||
// For string types, we can't meaningfully store an index
|
||||
// You might want to convert to string representation or use default
|
||||
return Z{}; // Default construct empty string
|
||||
// Alternative: return Z(std::to_string(index)); if you want string representation
|
||||
} else {
|
||||
return static_cast<Z>(index);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
template <typename X, typename Z>
|
||||
template <typename OpType>
|
||||
SD_LIB_EXPORT void sd::IndexReductionLoops<X, Z>::loopIndexReduce( X* x, const LongType* xShapeInfo, Z* z,
|
||||
const LongType* zShapeInfo,
|
||||
const LongType* tadShapeInfo,
|
||||
const LongType* tadOffsets, void* vextraParams) {
|
||||
sd::LoopKind::Kind kindOfLoop = sd::LoopKind::deduceKindOfLoopTadXZ(xShapeInfo, zShapeInfo, tadShapeInfo);
|
||||
|
||||
auto extraParams = reinterpret_cast<X*>(vextraParams);
|
||||
const sd::LongType zLen = shape::length(zShapeInfo);
|
||||
const sd::LongType tadLen = shape::length(tadShapeInfo);
|
||||
|
||||
const sd::LongType* tadShape = shape::shapeOf(const_cast<sd::LongType*>(tadShapeInfo));
|
||||
const sd::LongType* tadStride = shape::stride(const_cast<sd::LongType*>(tadShapeInfo));
|
||||
|
||||
switch (kindOfLoop) {
|
||||
//*********************************************//
|
||||
|
||||
//*********************************************//
|
||||
|
||||
//*********************************************//
|
||||
case sd::LoopKind::RANK1: {
|
||||
auto func = PRAGMA_THREADS_FOR {
|
||||
for (auto i = start; i < stop; i++) {
|
||||
auto tad = const_cast<X*>(x) + tadOffsets[i];
|
||||
auto indexValue = OpType::startingIndexValue(tad);
|
||||
|
||||
for (sd::LongType i0 = 0; i0 < tadLen; ++i0) {
|
||||
functions::indexreduce::IndexValue<X> comp(tad[i0 * tadStride[0]], i0);
|
||||
indexValue = OpType::update(indexValue, comp, extraParams);
|
||||
}
|
||||
|
||||
z[i] = convertIndexToZ<Z>(indexValue.index);
|
||||
}
|
||||
};
|
||||
|
||||
samediff::Threads::parallel_tad(func, 0, zLen);
|
||||
} break;
|
||||
|
||||
//*********************************************//
|
||||
case sd::LoopKind::RANK2: {
|
||||
sd::LongType newStride[2];
|
||||
shape::updateStrides(2, tadShape, newStride, 'c');
|
||||
|
||||
auto func = PRAGMA_THREADS_FOR {
|
||||
for (auto i = start; i < stop; i++) {
|
||||
auto tad = const_cast<X*>(x) + tadOffsets[i];
|
||||
auto indexValue = OpType::startingIndexValue(tad);
|
||||
|
||||
for (sd::LongType i0 = 0; i0 < tadShape[0]; ++i0) {
|
||||
for (sd::LongType i1 = 0; i1 < tadShape[1]; ++i1) {
|
||||
const auto tadOffset = i0 * tadStride[0] + i1 * tadStride[1];
|
||||
const auto tadIndex = i0 * newStride[0] + i1;
|
||||
functions::indexreduce::IndexValue<X> comp(tad[tadOffset], tadIndex);
|
||||
indexValue = OpType::update(indexValue, comp, extraParams);
|
||||
}
|
||||
}
|
||||
|
||||
z[i] = convertIndexToZ<Z>(indexValue.index);
|
||||
}
|
||||
};
|
||||
|
||||
samediff::Threads::parallel_tad(func, 0, zLen);
|
||||
} break;
|
||||
|
||||
//*********************************************//
|
||||
case sd::LoopKind::RANK3: {
|
||||
sd::LongType newStride[3];
|
||||
shape::updateStrides(3, tadShape, newStride, 'c');
|
||||
|
||||
auto func = PRAGMA_THREADS_FOR {
|
||||
for (auto i = start; i < stop; i++) {
|
||||
auto tad = const_cast<X*>(x) + tadOffsets[i];
|
||||
auto indexValue = OpType::startingIndexValue(tad);
|
||||
|
||||
for (sd::LongType i0 = 0; i0 < tadShape[0]; ++i0) {
|
||||
for (sd::LongType i1 = 0; i1 < tadShape[1]; ++i1) {
|
||||
for (sd::LongType i2 = 0; i2 < tadShape[2]; ++i2) {
|
||||
const auto tadOffset = i0 * tadStride[0] + i1 * tadStride[1] + i2 * tadStride[2];
|
||||
const auto tadIndex = i0 * newStride[0] + i1 * newStride[1] + i2;
|
||||
functions::indexreduce::IndexValue<X> comp(tad[tadOffset], tadIndex);
|
||||
indexValue = OpType::update(indexValue, comp, extraParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
z[i] = convertIndexToZ<Z>(indexValue.index);
|
||||
}
|
||||
};
|
||||
|
||||
samediff::Threads::parallel_tad(func, 0, zLen);
|
||||
} break;
|
||||
|
||||
//*********************************************//
|
||||
case sd::LoopKind::RANK4: {
|
||||
sd::LongType newStride[4];
|
||||
shape::updateStrides(4, tadShape, newStride, 'c');
|
||||
|
||||
auto func = PRAGMA_THREADS_FOR {
|
||||
for (auto i = start; i < stop; i++) {
|
||||
auto tad = const_cast<X*>(x) + tadOffsets[i];
|
||||
auto indexValue = OpType::startingIndexValue(tad);
|
||||
|
||||
for (sd::LongType i0 = 0; i0 < tadShape[0]; ++i0) {
|
||||
for (sd::LongType i1 = 0; i1 < tadShape[1]; ++i1) {
|
||||
for (sd::LongType i2 = 0; i2 < tadShape[2]; ++i2) {
|
||||
for (sd::LongType i3 = 0; i3 < tadShape[3]; ++i3) {
|
||||
const auto tadOffset = i0 * tadStride[0] + i1 * tadStride[1] + i2 * tadStride[2] + i3 * tadStride[3];
|
||||
const auto tadIndex = i0 * newStride[0] + i1 * newStride[1] + i2 * newStride[2] + i3;
|
||||
functions::indexreduce::IndexValue<X> comp(tad[tadOffset], tadIndex);
|
||||
indexValue = OpType::update(indexValue, comp, extraParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
z[i] = convertIndexToZ<Z>(indexValue.index);
|
||||
}
|
||||
};
|
||||
|
||||
samediff::Threads::parallel_tad(func, 0, zLen);
|
||||
} break;
|
||||
|
||||
//*********************************************//
|
||||
case sd::LoopKind::RANK5: {
|
||||
sd::LongType newStride[5];
|
||||
shape::updateStrides(5, tadShape, newStride, 'c');
|
||||
|
||||
auto func = PRAGMA_THREADS_FOR {
|
||||
for (auto i = start; i < stop; i++) {
|
||||
auto tad = const_cast<X*>(x) + tadOffsets[i];
|
||||
auto indexValue = OpType::startingIndexValue(tad);
|
||||
|
||||
for (sd::LongType i0 = 0; i0 < tadShape[0]; ++i0) {
|
||||
for (sd::LongType i1 = 0; i1 < tadShape[1]; ++i1) {
|
||||
for (sd::LongType i2 = 0; i2 < tadShape[2]; ++i2) {
|
||||
for (sd::LongType i3 = 0; i3 < tadShape[3]; ++i3) {
|
||||
for (sd::LongType i4 = 0; i4 < tadShape[4]; ++i4) {
|
||||
const auto tadOffset = i0 * tadStride[0] + i1 * tadStride[1] + i2 * tadStride[2] +
|
||||
i3 * tadStride[3] + i4 * tadStride[4];
|
||||
const auto tadIndex =
|
||||
i0 * newStride[0] + i1 * newStride[1] + i2 * newStride[2] + i3 * newStride[3] + i4;
|
||||
functions::indexreduce::IndexValue<X> comp(tad[tadOffset], tadIndex);
|
||||
indexValue = OpType::update(indexValue, comp, extraParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
z[i] = convertIndexToZ<Z>(indexValue.index);
|
||||
}
|
||||
};
|
||||
|
||||
samediff::Threads::parallel_tad(func, 0, zLen);
|
||||
} break;
|
||||
|
||||
//*********************************************//
|
||||
|
||||
//*********************************************//
|
||||
default: {
|
||||
sd::LongType tadRank = shape::rank(tadShapeInfo);
|
||||
sd::LongType *tadShape = shape::shapeOf(tadShapeInfo);
|
||||
sd::LongType *tadStride = shape::stride(tadShapeInfo);
|
||||
sd::LongType zRank = shape::rank(zShapeInfo);
|
||||
sd::LongType *zShape = shape::shapeOf(zShapeInfo);
|
||||
sd::LongType *zStride = shape::stride(zShapeInfo);
|
||||
auto func = PRAGMA_THREADS_FOR {
|
||||
for (auto i = start; i < stop; i++) {
|
||||
auto tad = const_cast<X*>(x) + tadOffsets[i];
|
||||
auto indexValue = OpType::startingIndexValue(tad);
|
||||
|
||||
for (sd::LongType j = 0; j < tadLen; j++) {
|
||||
LongType coords[SD_MAX_RANK];
|
||||
INDEX2COORDS(j, tadRank, tadShape, coords);
|
||||
LongType tadOffset;
|
||||
COORDS2INDEX(tadRank, tadStride, coords, tadOffset);
|
||||
functions::indexreduce::IndexValue<X> comp(tad[tadOffset], j);
|
||||
indexValue = OpType::update(indexValue, comp, extraParams);
|
||||
}
|
||||
|
||||
LongType coords[SD_MAX_RANK];
|
||||
INDEX2COORDS(i, zRank, zShape, coords);
|
||||
LongType zOffset;
|
||||
COORDS2INDEX(zRank, zStride, coords, zOffset);
|
||||
z[zOffset] = convertIndexToZ<Z>(indexValue.index);
|
||||
}
|
||||
};
|
||||
samediff::Threads::parallel_tad(func, 0, zLen);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename X, typename Z>
|
||||
SD_LIB_HIDDEN void sd::IndexReductionLoops<X, Z>::wrapIndexReduce(const int opNum, const void* vx,
|
||||
const sd::LongType* xShapeInfo, void* vz,
|
||||
const sd::LongType* zShapeInfo,
|
||||
const sd::LongType* tadShapeInfo,
|
||||
const sd::LongType* tadOffsets, void* vextraParams) {
|
||||
auto x = reinterpret_cast<X*>(const_cast<void *>(vx));
|
||||
auto z = reinterpret_cast<Z*>(vz);
|
||||
|
||||
DISPATCH_BY_OPNUM_TT(loopIndexReduce, PARAMS(x, xShapeInfo, z, zShapeInfo, tadShapeInfo, tadOffsets, vextraParams),
|
||||
INDEX_REDUCE_OPS);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* *
|
||||
* *
|
||||
* * This program and the accompanying materials are made available under the
|
||||
* * terms of the Apache License, Version 2.0 which is available at
|
||||
* * https://www.apache.org/licenses/LICENSE-2.0.
|
||||
* *
|
||||
* * See the NOTICE file distributed with this work for additional
|
||||
* * information regarding copyright ownership.
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* * License for the specific language governing permissions and limitations
|
||||
* * under the License.
|
||||
* *
|
||||
* * SPDX-License-Identifier: Apache-2.0
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// @author Yurii Shyrma (iuriish@yahoo.com)
|
||||
//
|
||||
#include <helpers/cpu/loops/IndexReductionLoops.hpp>
|
||||
#cmakedefine SD_COMMON_TYPES_GEN
|
||||
#if defined(SD_COMMON_TYPES_GEN) && defined(SD_COMMON_TYPES_@FL_TYPE_INDEX@) && defined(SD_INDEXING_TYPES_0)
|
||||
BUILD_DOUBLE_TEMPLATE( SD_LIB_HIDDEN void sd::IndexReductionLoops, ::wrapIndexReduce(const int opNum, const void* vx, const sd::LongType* xShapeInfo, void* z, const sd::LongType* zShapeInfo, const sd::LongType* tadShapeInfo, const sd::LongType* tadOffsets, void* vextraParams), SD_COMMON_TYPES_@FL_TYPE_INDEX@, SD_INDEXING_TYPES_0 );
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* *
|
||||
* *
|
||||
* * This program and the accompanying materials are made available under the
|
||||
* * terms of the Apache License, Version 2.0 which is available at
|
||||
* * https://www.apache.org/licenses/LICENSE-2.0.
|
||||
* *
|
||||
* * See the NOTICE file distributed with this work for additional
|
||||
* * information regarding copyright ownership.
|
||||
* * Unless required by applicable law or agreed to in writing, software
|
||||
* * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* * License for the specific language governing permissions and limitations
|
||||
* * under the License.
|
||||
* *
|
||||
* * SPDX-License-Identifier: Apache-2.0
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// @author Yurii Shyrma (iuriish@yahoo.com)
|
||||
//
|
||||
#include <helpers/cpu/loops/IndexReductionLoops.hpp>
|
||||
#cmakedefine SD_COMMON_TYPES_GEN
|
||||
#if defined(SD_COMMON_TYPES_GEN) && defined(SD_COMMON_TYPES_@FL_TYPE_INDEX@) && defined(SD_INDEXING_TYPES_1)
|
||||
BUILD_DOUBLE_TEMPLATE( SD_LIB_HIDDEN void sd::IndexReductionLoops, ::wrapIndexReduce(const int opNum, const void* vx, const sd::LongType* xShapeInfo, void* z, const sd::LongType* zShapeInfo, const sd::LongType* tadShapeInfo, const sd::LongType* tadOffsets, void* vextraParams), SD_COMMON_TYPES_@FL_TYPE_INDEX@, SD_INDEXING_TYPES_1 );
|
||||
#endif
|
||||
@@ -0,0 +1,29 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
#include <helpers/cpu/loops/Reduction3Loops.hpp>
|
||||
#cmakedefine SD_FLOAT_TYPES_GEN
|
||||
#if defined(SD_FLOAT_TYPES_GEN) && defined(SD_FLOAT_TYPES_@FL_TYPE_INDEX@)
|
||||
namespace sd {
|
||||
|
||||
BUILD_DOUBLE_TEMPLATE( class SD_LIB_HIDDEN Reduction3Loops, , SD_COMMON_TYPES, SD_FLOAT_TYPES_@FL_TYPE_INDEX@);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,82 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
#include <helpers/Loops.h>
|
||||
#include <types/types.h>
|
||||
|
||||
using namespace simdOps;
|
||||
|
||||
namespace sd {
|
||||
|
||||
template <typename X, typename Z>
|
||||
template <typename OpType>
|
||||
SD_LIB_HIDDEN void Reduction3Loops<X, Z>::innerloopReduce3(const X* x, const sd::LongType* xShapeInfo, const X* y,
|
||||
const sd::LongType* yShapeInfo, Z* z,
|
||||
const sd::LongType* zShapeInfo, LongType* dims, int dimsLen,
|
||||
Z* extraParams, int64_t start, int64_t stop) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
Reduction3Loops<X, Z>::template loopReduce3<OpType>(x, xShapeInfo, y, yShapeInfo, z, zShapeInfo, dims, dimsLen,
|
||||
extraParams, start, stop);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename X, typename Z>
|
||||
template <typename OpType>
|
||||
SD_LIB_HIDDEN void Reduction3Loops<X, Z>::innerloopReduce3All(
|
||||
const X* x, const sd::LongType* xShapeInfo, const X* y, const sd::LongType* yShapeInfo, Z* z,
|
||||
const sd::LongType* zShapeInfo, const sd::LongType* xTadShapeInfo, const sd::LongType* xTadOffsets,
|
||||
const sd::LongType* yTadShapeInfo, const sd::LongType* yTadOffsets, Z* extraParams, int64_t start, int64_t stop) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
Reduction3Loops<X, Z>::template loopReduce3All<OpType>(x, xShapeInfo, y, yShapeInfo, z, zShapeInfo, xTadShapeInfo,
|
||||
xTadOffsets, yTadShapeInfo, yTadOffsets, extraParams, start,
|
||||
stop);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename X, typename Y>
|
||||
SD_LIB_HIDDEN void Reduction3Loops<X, Y>::wrapper(int opNum, const X* x, const sd::LongType* xShapeInfo,
|
||||
const X* y, const sd::LongType* yShapeInfo, Y* z,
|
||||
const sd::LongType* zShapeInfo,
|
||||
LongType* dims, int dimsLen,
|
||||
Y* extraParams, int64_t start, int64_t stop) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
DISPATCH_BY_OPNUM_TT(innerloopReduce3,
|
||||
PARAMS(x, xShapeInfo, y, yShapeInfo, z, zShapeInfo, dims, dimsLen, extraParams, start, stop),
|
||||
REDUCE3_OPS);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename X, typename Y>
|
||||
SD_LIB_HIDDEN void Reduction3Loops<X, Y>::wrapperAll(const int opNum, const X* x, const sd::LongType* xShapeInfo,
|
||||
const X* y, const sd::LongType* yShapeInfo, Y* z,
|
||||
const sd::LongType* zShapeInfo, const sd::LongType* xTadShapeInfo,
|
||||
const sd::LongType* xTadOffsets, const sd::LongType* yTadShapeInfo,
|
||||
const sd::LongType* yTadOffsets, Y* extraParams, int64_t start,
|
||||
int64_t stop) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
DISPATCH_BY_OPNUM_TT(innerloopReduce3All,
|
||||
PARAMS(x, xShapeInfo, y, yShapeInfo, z, zShapeInfo, xTadShapeInfo, xTadOffsets, yTadShapeInfo,
|
||||
yTadOffsets, extraParams, start, stop),
|
||||
REDUCE3_OPS);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace sd
|
||||
@@ -0,0 +1,23 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author Yurii Shyrma (iuriish@yahoo.com), created on 14.03.2019
|
||||
//
|
||||
#include <helpers/Loops.h>
|
||||
#include <system/op_boilerplate.h>
|
||||
@@ -0,0 +1,50 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
#include "ReductionLoops.hpp"
|
||||
|
||||
using namespace simdOps;
|
||||
|
||||
namespace sd {
|
||||
|
||||
template <typename X, typename Z>
|
||||
template <typename OpType>
|
||||
void ReductionBoolLoops<X, Z>::innerloopReduce(sd::memory::Workspace* workspace, const X* x,
|
||||
const sd::LongType* xShapeInfo, Z* z, const sd::LongType* zShapeInfo,
|
||||
const LongType* dims, X* extraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
ReductionLoops<X, Z, X>::template loopReduce<OpType>(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename X, typename Z>
|
||||
void ReductionBoolLoops<X, Z>::wrapper(int opNum, memory::Workspace* workspace, const X* x, const LongType* xShapeInfo, Z* z,
|
||||
const LongType* zShapeInfo, const LongType* dims, X* extraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
DISPATCH_BY_OPNUM_TT(innerloopReduce, PARAMS(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams),
|
||||
REDUCE_BOOL_OPS);
|
||||
#endif
|
||||
}
|
||||
|
||||
// NOTE: Template instantiations are handled by TemplateProcessing.cmake
|
||||
// Removed BUILD_DOUBLE_TEMPLATE to avoid duplicate instantiations
|
||||
|
||||
} // namespace sd
|
||||
@@ -0,0 +1,31 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
#include <helpers/cpu/loops/ReductionLoops_float.hpp>
|
||||
#cmakedefine SD_FLOAT_TYPES_GEN
|
||||
#if defined(SD_FLOAT_TYPES_GEN) && defined(SD_FLOAT_TYPES_@FL_TYPE_INDEX@)
|
||||
namespace sd {
|
||||
|
||||
BUILD_DOUBLE_TEMPLATE( class SD_LIB_HIDDEN ReductionFloatLoops, , SD_COMMON_TYPES, SD_FLOAT_TYPES_@FL_TYPE_INDEX@);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
#include <types/types.h>
|
||||
|
||||
#include "ReductionLoops.hpp"
|
||||
|
||||
using namespace simdOps;
|
||||
|
||||
namespace sd {
|
||||
|
||||
template <typename X, typename Z>
|
||||
template <typename OpType>
|
||||
SD_LIB_HIDDEN void ReductionFloatLoops<X, Z>::innerloopReduce(sd::memory::Workspace* workspace, const X* x,
|
||||
const sd::LongType* xShapeInfo, Z* z,
|
||||
const sd::LongType* zShapeInfo, const LongType* dims,
|
||||
Z* extraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
ReductionLoops<X, Z, Z>::template loopReduce<OpType>(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename X, typename Y>
|
||||
SD_LIB_HIDDEN void ReductionFloatLoops<X, Y>::wrapper(int opNum, sd::memory::Workspace* workspace, const X* x,
|
||||
const sd::LongType* xShapeInfo, Y* z,
|
||||
const sd::LongType* zShapeInfo, const LongType* dims, Y* extraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
DISPATCH_BY_OPNUM_TT(innerloopReduce, PARAMS(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams),
|
||||
REDUCE_FLOAT_OPS);
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace sd
|
||||
@@ -0,0 +1,61 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
|
||||
#ifndef LIBND4J_REDUCTIONLOOPS_LONG_CPP
|
||||
#define LIBND4J_REDUCTIONLOOPS_LONG_CPP
|
||||
|
||||
#include "ReductionLoops.hpp"
|
||||
|
||||
using namespace simdOps;
|
||||
|
||||
#include <types/types.h>
|
||||
|
||||
namespace sd {
|
||||
|
||||
template <typename X, typename Z>
|
||||
template <typename OpType>
|
||||
void ReductionLongLoops<X, Z>::innerloopReduce(sd::memory::Workspace* workspace, const X* x,
|
||||
const sd::LongType* xShapeInfo, Z* z, const sd::LongType* zShapeInfo,
|
||||
const LongType* dims, X* extraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
ReductionLoops<X, Z, X>::template loopReduce<OpType>(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename X, typename Z>
|
||||
void ReductionLongLoops<X, Z>::wrapper(int opNum, sd::memory::Workspace* workspace, const X* x,
|
||||
const sd::LongType* xShapeInfo, Z* z, const sd::LongType* zShapeInfo,
|
||||
const LongType* dims, X* extraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
DISPATCH_BY_OPNUM_TT(innerloopReduce, PARAMS(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams),
|
||||
REDUCE_LONG_OPS);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Template instantiations for ReductionLongLoops are generated by TemplateProcessing.cmake
|
||||
// This includes both class instantiations and member function templates (innerloopReduce<OpType>)
|
||||
// for all type combinations in SD_COMMON_TYPES × SD_LONG_TYPES.
|
||||
// No manual BUILD_DOUBLE_TEMPLATE needed here to avoid duplicate instantiation errors.
|
||||
|
||||
} // namespace sd
|
||||
|
||||
#endif // LIBND4J_REDUCTIONLOOPS_LONG_CPP
|
||||
@@ -0,0 +1,55 @@
|
||||
/* ******************************************************************************
|
||||
*
|
||||
*
|
||||
* This program and the accompanying materials are made available under the
|
||||
* terms of the Apache License, Version 2.0 which is available at
|
||||
* https://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* See the NOTICE file distributed with this work for additional
|
||||
* information regarding copyright ownership.
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
******************************************************************************/
|
||||
|
||||
//
|
||||
// @author raver119@gmail.com
|
||||
//
|
||||
#include "ReductionLoops.hpp"
|
||||
|
||||
using namespace simdOps;
|
||||
|
||||
namespace sd {
|
||||
|
||||
template <typename X>
|
||||
template <typename OpType>
|
||||
void ReductionSameLoops<X>::innerloopReduce(sd::memory::Workspace *workspace, const X *x,
|
||||
const sd::LongType *xShapeInfo, X *z, const sd::LongType *zShapeInfo,
|
||||
const LongType *dims, X *extraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
ReductionLoops<X, X, X>::template loopReduce<OpType>(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams);
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename X>
|
||||
void ReductionSameLoops<X>::wrapper(int opNum, sd::memory::Workspace *workspace, const X *vx,
|
||||
const sd::LongType *xShapeInfo, X *z, const sd::LongType *zShapeInfo,
|
||||
const LongType *dims, X *vextraParams) {
|
||||
#ifndef SD_LOOPS_INLINED
|
||||
auto x = reinterpret_cast<X *>(vx);
|
||||
auto z = reinterpret_cast<X *>(vz);
|
||||
auto extraParams = reinterpret_cast<X *>(vextraParams);
|
||||
|
||||
DISPATCH_BY_OPNUM_T(innerloopReduce, PARAMS(workspace, x, xShapeInfo, z, zShapeInfo, dims, extraParams),
|
||||
REDUCE_SAME_OPS);
|
||||
#endif
|
||||
}
|
||||
|
||||
// NOTE: Template instantiations are handled by TemplateProcessing.cmake
|
||||
// Removed BUILD_SINGLE_TEMPLATE to avoid duplicate instantiations
|
||||
|
||||
} // namespace sd
|
||||
Reference in New Issue
Block a user