@@ -79,16 +79,16 @@ at::Tensor AtenIpexJITDev::dil_convolution_sigmoid(
79
79
}
80
80
81
81
/* *
82
- * Dispatch at::matmul + at::div pattern to ipex for jit inference, but only one-element
83
- * tensor and channel dim boadcast is enabled in oneDNN 2.2.0 now. So, for simplicity,this path is just
84
- * a fallback path now.
85
- * output(out) = (tensor1 * tensor2).div(div_input)
86
- *
87
- * @param tensor1
88
- * @param tensor2
89
- * @param out Optinal output provided by user for matmul
90
- * @param div_input Input Tensor for div
91
- * @return Value for the fusion pattern output.
82
+ * Dispatch at::matmul + at::div pattern to ipex for jit inference, but only
83
+ * one-element tensor and channel dim boadcast is enabled in oneDNN 2.2.0 now.
84
+ * So, for simplicity,this path is just a fallback path now. output(out) =
85
+ * (tensor1 * tensor2).div(div_input)
86
+ *
87
+ * @param tensor1
88
+ * @param tensor2
89
+ * @param out Optinal output provided by user for matmul
90
+ * @param div_input Input Tensor for div
91
+ * @return Value for the fusion pattern output.
92
92
*/
93
93
at::Tensor AtenIpexJITDev::dil_matmul_div (
94
94
const at::Tensor& tensor1,
@@ -101,19 +101,18 @@ at::Tensor AtenIpexJITDev::dil_matmul_div(
101
101
if (out.defined ()) {
102
102
at::matmul_out (out, tensor1, tensor2);
103
103
return out.div (div_input);
104
- }
104
+ }
105
105
auto output = at::matmul (tensor1, tensor2);
106
106
return output.div (div_input);
107
-
108
-
109
107
}
110
108
111
109
/* *
112
- *Dispatch at::matmul + at::div pattern to ipex for jit inference, but only bmm with same shape for
113
- *tensor1 and tensor2 and scalar input for div will be dispatched to oneDNN kernel. Otherwise will fallback.
114
- *For oneDNN kernel, scalar input will be used as the scale attribute for matmul primitive.
110
+ *Dispatch at::matmul + at::div pattern to ipex for jit inference, but only bmm
111
+ *with same shape for tensor1 and tensor2 and scalar input for div will be
112
+ *dispatched to oneDNN kernel. Otherwise will fallback. For oneDNN kernel,
113
+ *scalar input will be used as the scale attribute for matmul primitive.
115
114
*output(out) = (tensor1 * tensor2).div(div_input_scalar).
116
- *ToDo: matmul + div scalar for matmul with other shape
115
+ *ToDo: matmul + div scalar for matmul with other shape
117
116
*
118
117
*@param tensor1
119
118
*@param tensor2
@@ -131,8 +130,8 @@ at::Tensor AtenIpexJITDev::dil_matmul_div(
131
130
#endif
132
131
auto dim_tensor1 = tensor1.dim ();
133
132
auto dim_tensor2 = tensor2.dim ();
134
- if (dim_tensor1 == dim_tensor2 && dim_tensor1 >= 3 ) {
135
- float scale = 1.0 / div_input.to <float >();
133
+ if (dim_tensor1 == dim_tensor2 && dim_tensor1 >= 3 ) {
134
+ float scale = 1 .0f / div_input.to <float >();
136
135
return bmm_impl (tensor1, tensor2, out, ideep::attr_t (), scale);
137
136
} else {
138
137
return AtenIpexJITDev::dil_matmul_div (tensor1, tensor2, out, at::native::wrapped_scalar_tensor (div_input));
@@ -309,26 +308,24 @@ at::Tensor AtenIpexJITDev::dil_linear_fuse_eltwise(
309
308
return linear_impl (self, weight, bias, attr);
310
309
}
311
310
312
-
313
311
/* *
314
312
*Dispatch Linear + Add fusion pattern to ipex oneDNN kernel for inference mode.
315
313
*This feature might improve performance for cases like residual learning blocks
316
- *Pattern: accum = accum * alpha + Linear(self, weight, bias)
314
+ *Pattern: accum = accum * alpha + Linear(self, weight, bias)
317
315
*
318
- *@param self Activatin input for Linear
316
+ *@param self Activatin input for Linear
319
317
*@param weight Weight for Linear
320
318
*@param bias Bias for Linear
321
319
*@param accum One input for add operation, another is the output of Linear
322
- *@param alpha Scale for accum when doing add operation.
320
+ *@param alpha Scale for accum when doing add operation.
323
321
*
324
- *@return Value for the fusion pattern output.
322
+ *@return Value for the fusion pattern output.
325
323
*/
326
- at::Tensor AtenIpexJITDev::dil_linear_add (
327
- const at::Tensor& self,
328
- const at::Tensor& weight,
329
- const at::Tensor& bias,
330
- at::Tensor& accumu,
331
- at::Scalar alpha) {
324
+ at::Tensor AtenIpexJITDev::dil_linear_add (const at::Tensor &self,
325
+ const at::Tensor &weight,
326
+ const at::Tensor &bias,
327
+ at::Tensor &accumu,
328
+ at::Scalar alpha) {
332
329
#if defined(IPEX_PROFILE_OP)
333
330
RECORD_FUNCTION (" AtenIpexJITDev::dil_linear_add" , std::vector<c10::IValue>({}));
334
331
#endif
@@ -468,5 +465,17 @@ at::Tensor AtenIpexJITDev::dil_layernorm(
468
465
at::native_layer_norm (input, normalized_shape, weight, bias, eps));
469
466
}
470
467
468
+ at::Tensor AtenIpexJITDev::dil_shuffle (const at::Tensor &self,
469
+ at::IntArrayRef view_shape, int64_t dim0,
470
+ int64_t dim1) {
471
+ ideep::tensor _self = itensor_view_from_dense (self);
472
+ auto group_dim = dim0 < dim1 ? dim0 : dim1;
473
+ auto groups = view_shape[group_dim];
474
+ auto output = at::empty_like (self);
475
+ ideep::tensor _output = itensor_view_from_dense (output);
476
+ ideep::channel_shuffle_forward::compute (_self, _output, groups, group_dim);
477
+ return output;
478
+ }
479
+
471
480
} // namespace cpu
472
481
} // namespace torch_ipex
0 commit comments