Tilewise Lamda Function
File:
/src/tilewise.hppLines 96–128 /**
* @brief Automatically creates general flow to apply a lambda function tilewise to data in ddr or data in ocm
*
* @tparam multicoreMode Multi-core behavior (Single or All).
* @tparam InTensorShape The input tensor data type.
* @tparam OutTensorShape The output tensor data type.
* @tparam granularity The granularity of the iterator.
* @tparam _Axes The axis pattern to access data with.
* @tparam OcmAllocatorType Type of ocm allocator.
* @tparam Func The type of the function to apply, must be callable on the element type of the tensor.
* @tparam InT The element type of input tensor.
* @tparam OutT The element type of output tensor.
* @param inp The input ddr or ocm region.
* @param out The output ddr or ocm region.
* @param func The function to apply.
* @param ocmMemAlloc Ocm memory allocator.
*/
template <MultiCoreMode multicoreMode = MultiCoreMode::Single,
Granularity granularity = Granularity::Square,
typename _Axes = AxisGroup<Direction::Channel, Direction::Width, Direction::Height>,
typename InTensorShape,
typename OutTensorShape,
typename Func,
typename OcmAllocatorType = MemAllocator,
typename InT = typename InTensorShape::elemType,
typename OutT = typename OutTensorShape::elemType,
std::enable_if_t<compareSequences(InTensorShape::dimSequence, OutTensorShape::dimSequence) &&
std::is_convertible<typename std::result_of_t<Func(InT&)>, OutT>::value,
int> = 0>
void invokeTilewise(InTensorShape& inp,
OutTensorShape& out,
const Func& func,
OcmAllocatorType&& ocmMemAlloc = OcmAllocatorType()) {
Tilewise Sum
File:
/src/neuralNetBlocks/pool.hppLines 942–955 /**
* @brief Calculates tile sum across each tile in the input NDArray.
*
* @tparam numChn Number of elements in NDArray.
* @tparam reductionHeight Reduction Receptive Field in Height.
* @tparam reductionWidth Reduction Receptive Field in Width.
* @tparam T The type of the data.
* @param qData The input NDArray.
*/
template <std::int32_t numChn,
std::int32_t reductionHeight = core_array::coreDim,
std::int32_t reductionWidth = core_array::coreDim,
typename T>
INLINE void calculateTileSum(container::NDArray<qVar_t<T>, numChn>& qData) {
Tilewise Max
File:
/src/neuralNetBlocks/pool.hppLines 962–991 /*
* @brief Calculates the tile max for each qVar_t in the input array.
*
* After the function, each element holds the max of all of
* the elements in that tile. This is done by first computing the
* max of each row with west <-> east neighbor movement and then
* computing the max column-wise using north <-> south neighbor
* movement.
*
* The parameters "reductionHeight" and "reductionWidth" specify
* a rectangular area in which computations are performed, avoiding
* unnecessary data movements by only computing values within the
* specified area. By utilizing these parameters, performance
* improvements can be observed when the data does not utilize the
* full tile.
*
* @ingroup pooling
* @param qData The input ND array
*
* @tparam numChn The number of tiles to operate over
* @tparam T The type of the data in the qVar_t's
* @tparam reductionHeight Reduction Receptive Field in Height
* @tparam reductionWidth Reduction Receptive Field in Width
*/
// clang-format on
template <std::int32_t numChn,
std::int32_t reductionHeight = core_array::coreDim,
std::int32_t reductionWidth = core_array::coreDim,
typename T>
INLINE void calculateTileMaximum(container::NDArray<qVar_t<T>, numChn>& qData) {
Tilewise Average
File:
/src/neuralNetBlocks/pool.hppLines 1142–1159 /**
* @brief Calculates the tile average for each qVar_t in the input array.
* After the function, each element holds the average of all of
* the elements in that tile.
*
*
* @tparam reductionHeight Reduction receptive field in height.
* @tparam reductionWidth Reduction receptive field in width.
* @tparam numTiles The number of tiles to process.
* @tparam T The input type.
* @param qData The input NDArray.
* @return INLINE
*/
template <std::int32_t reductionHeight = core_array::coreDim,
std::int32_t reductionWidth = core_array::coreDim,
std::size_t numTiles,
typename T>
INLINE void calculateTileAverage(container::NDArray<qVar_t<T>, numTiles>& qData) {