access2rohit commented on a change in pull request #16104: Faster Transpose 2D
URL: https://github.com/apache/incubator-mxnet/pull/16104#discussion_r322388690
##########
File path: src/operator/tensor/matrix_op-inl.h
##########
@@ -257,6 +257,43 @@ struct TransposeParam : public
dmlc::Parameter<TransposeParam> {
}
};
+
+/*!
+ * \brief This function performs transpose operation on a 2D matrix by
utilizing the L1 cache
+ * \param in input tensor
+ * \param out output tensor
+ * \param shape_0 shape of dim 0 of input
+ * \param shape_1 shape of dim 1 of input
+ */
+template<typename xpu, typename DType>
+MSHADOW_XINLINE void Transpose2D(DType *in, DType *out, index_t shape_0,
index_t shape_1) {
+ // ensure cache line hits and prevent cache miss for any configuration
+ // L1 cache size to be utilized = 32kb = 2^15
+ // Largest size of a single unit of any dtype <= 8 byte = 2^3
+ // Number of elements - (2^15/2^3) = 2^12
+ // Block-size - 2^6 v 2^6 (64 v 64)
+
+ // But we could leverage unrolling of for loops (for parallelization)
+ // Block-size - 2^5 v 2^5 (32 v 32) with 4 pragma for loop unrolled
+ index_t blocksize = 32;
+ index_t n = shape_0;
Review comment:
Actually make thenm`rows` and `columns` since it is 2D and improves code
readibility. In higher order transposes we can add description in comments on
how indices are ordered and then name them accordingly.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services