You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Reorders ndarray dimensions and associated strides for loop interchange.
4135
+
*
4136
+
* ## Notes
4137
+
*
4138
+
* - The returned object has the following properties:
4139
+
*
4140
+
* - **sh**: dimensions sorted in loop order.
4141
+
* - **sx**: first input ndarray strides sorted in loop order.
4142
+
* - **sy**: second input ndarray strides sorted in loop order.
4143
+
* - **sz**: third input ndarray strides sorted in loop order.
4144
+
* - **sw**: output ndarray strides sorted in loop order.
4145
+
*
4146
+
* - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache.
4147
+
*
4148
+
* The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference.
4149
+
*
4150
+
* - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the most common layout order. Accordingly, if the output ndarray has a different layout order (e.g., if the input ndarrays are row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order.
4151
+
*
4152
+
* - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting.
4153
+
*
4154
+
* @param shape - array dimensions
4155
+
* @param stridesX - first input array stride lengths
4156
+
* @param stridesY - second input array stride lengths
4157
+
* @param stridesZ - third input array stride lengths
4158
+
* @param stridesW - output array stride lengths
4159
+
* @returns loop interchange data
4160
+
*
4161
+
* @example
4162
+
* var sh = [ 2, 3, 4 ];
4163
+
*
4164
+
* var sx = [ 12, 4, 1 ]; // row-major
4165
+
* var sy = [ 24, 8, 1 ]; // row-major
4166
+
* var sz = [ 1, 4, 12 ]; // column-major
4167
+
* var sw = [ 1, -2, 6 ]; // column-major
4168
+
*
4169
+
* var o = ns.ternaryLoopOrder( sh, sx, sy, sz, sw );
4170
+
* // returns {...}
4171
+
*
4172
+
* var ssh = o.sh;
4173
+
* // returns [ 2, 3, 4 ]
4174
+
*
4175
+
* var ssx = o.sx;
4176
+
* // returns [ 12, 4, 1 ]
4177
+
*
4178
+
* var ssy = o.sy;
4179
+
* // returns [ 24, 8, 1 ]
4180
+
*
4181
+
* var ssz = o.sz;
4182
+
* // returns [ 1, 4, 12 ]
4183
+
*
4184
+
* var ssw = o.sw;
4185
+
* // returns [ 1, -2, 6 ]
4186
+
*/
4187
+
ternaryLoopOrder: typeofternaryLoopOrder;
4188
+
4189
+
/**
4190
+
* Resolves the output ndarray data type for a ternary function.
4191
+
*
4192
+
* @param xdtype - first input ndarray data type
4193
+
* @param ydtype - second input ndarray data type
4194
+
* @param zdtype - third input ndarray data type
4195
+
* @param policy - output ndarray data type policy
4196
+
* @returns output ndarray data type
4197
+
*
4198
+
* @example
4199
+
* var dt = ns.ternaryOutputDataType( 'float64', 'float32', 'float32', 'complex_floating_point' );
0 commit comments