@@ -24,15 +24,16 @@ template <typename T, typename Context>
24
24
void ContiguousKernel (const Context& dev_ctx,
25
25
const DenseTensor& input,
26
26
DenseTensor* out) {
27
- if (out->numel () == 0 ) {
28
- dev_ctx.template Alloc <T>(out);
29
- return ;
30
- }
31
27
phi::DenseTensorMeta meta = input.meta ();
32
28
meta.strides = meta.calc_strides (meta.dims );
33
29
meta.offset = 0 ;
34
30
out->set_meta (meta);
35
31
32
+ if (out->numel () == 0 ) {
33
+ dev_ctx.template Alloc <T>(out);
34
+ return ;
35
+ }
36
+
36
37
// use XPUCopyTypeTrait to deal with double and int16_t copy instead of
37
38
// XPUTypeTrait
38
39
using XPUType = typename XPUCopyTypeTrait<T>::Type;
@@ -59,15 +60,17 @@ template <>
59
60
void ContiguousKernel<phi::dtype::complex<float >, XPUContext>(
60
61
const XPUContext& dev_ctx, const DenseTensor& input, DenseTensor* out) {
61
62
using T = phi::dtype::complex<float >;
62
- if (out->numel () == 0 ) {
63
- dev_ctx.template Alloc <T>(out);
64
- return ;
65
- }
63
+
66
64
phi::DenseTensorMeta meta = input.meta ();
67
65
meta.strides = meta.calc_strides (meta.dims );
68
66
meta.offset = 0 ;
69
67
out->set_meta (meta);
70
68
69
+ if (out->numel () == 0 ) {
70
+ dev_ctx.template Alloc <T>(out);
71
+ return ;
72
+ }
73
+
71
74
// The current complex number implementation uses separate real/imaginary
72
75
// parts,resulting in redundant operations and performance
73
76
// penalties.Optimization should address this in future iterations.
0 commit comments