Tilewise Lamda Function
/src/tilewise.hppLines 134–164Automatically creates general flow to apply a lambda function tilewise to data in ddr or data in ocm
template <MultiCoreMode multicoreMode = MultiCoreMode::Single,
Granularity granularity = Granularity::Square,
typename AxesVal = 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>
INLINE void invokeTilewise(InTensorShape& inp,
OutTensorShape& out,
const Func func,
OcmAllocatorType&& ocmMemAlloc = OcmAllocatorType())| Name | Type | Default | Description |
|---|---|---|---|
multicoreMode | MultiCoreMode | MultiCoreMode::Single | Multi-core behavior (Single or All). |
granularity | Granularity | Granularity::Square | The granularity of the iterator. |
AxesVal | typename | AxisGroup<Direction::Channel, Direction::Width, Direction::Height> | The axis pattern to access data with. |
InTensorShape | typename | The input tensor data type. | |
OutTensorShape | typename | The output tensor data type. | |
Func | typename | The type of the function to apply, must be callable on the element type of the tensor. | |
OcmAllocatorType | typename | MemAllocator | Type of ocm allocator. |
InT | typename | typename InTensorShape::elemType | The element type of input tensor. |
OutT | typename | typename OutTensorShape::elemType | The element type of output tensor. |
| Name | Type | Description |
|---|---|---|
inp | InTensorShape& | The input ddr or ocm region. |
out | OutTensorShape& | The output ddr or ocm region. |
func | const Func | The function to apply. |
ocmMemAlloc | OcmAllocatorType&& | Ocm memory allocator. |
INLINE void
Tilewise Sum
/src/neuralNetBlocks/pool.hppLines 976–984Calculates tile sum across each tile in 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)| Name | Type | Default | Description |
|---|---|---|---|
numChn | std::int32_t | Number of elements in NDArray. | |
reductionHeight | std::int32_t | core_array::coreDim | Reduction Receptive Field in Height. |
reductionWidth | std::int32_t | core_array::coreDim | Reduction Receptive Field in Width. |
T | typename | The type of the data. |
| Name | Type | Description |
|---|---|---|
qData | container::NDArray<qVar_t<T>, numChn>& | The input NDArray. |
INLINE void
Tilewise Max
/src/neuralNetBlocks/pool.hppLines 1012–1051Calculates 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.
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)| Name | Type | Default | Description |
|---|---|---|---|
numChn | std::int32_t | The number of tiles to operate over | |
reductionHeight | std::int32_t | core_array::coreDim | Reduction Receptive Field in Height |
reductionWidth | std::int32_t | core_array::coreDim | Reduction Receptive Field in Width / // clang-format on |
T | typename | The type of the data in the qVar_t's |
| Name | Type | Description |
|---|---|---|
qData | container::NDArray<qVar_t<T>, numChn>& | The input ND array |
INLINE void
Tilewise Average
/src/neuralNetBlocks/pool.hppLines 1181–1189Calculates 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.
template <std::int32_t reductionHeight = core_array::coreDim,
std::int32_t reductionWidth = core_array::coreDim,
std::size_t numTiles,
typename T>
void calculateTileAverage(container::NDArray<qVar_t<T>, numTiles>& qData)| Name | Type | Default | Description |
|---|---|---|---|
reductionHeight | std::int32_t | core_array::coreDim | Reduction receptive field in height. |
reductionWidth | std::int32_t | core_array::coreDim | Reduction receptive field in width. |
numTiles | std::size_t | The number of tiles to process. | |
T | typename | The input type. |
| Name | Type | Description |
|---|---|---|
qData | container::NDArray<qVar_t<T>, numTiles>& | The input NDArray. |
void
