Skip to content

Commit f225aa0

Browse files
committed
Don't accelerate TensorPrimitives.SinCos for the time being
1 parent d52bc9b commit f225aa0

File tree

1 file changed

+4
-102
lines changed

1 file changed

+4
-102
lines changed
Lines changed: 4 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
54
using System.Runtime.Intrinsics;
65

76
namespace System.Numerics.Tensors
@@ -30,109 +29,12 @@ public static void SinCos<T>(ReadOnlySpan<T> x, Span<T> sinDestination, Span<T>
3029
/// <summary>T.SinCos(x)</summary>
3130
private readonly struct SinCosOperator<T> : IUnaryInputBinaryOutput<T> where T : ITrigonometricFunctions<T>
3231
{
33-
public static bool Vectorizable => (typeof(T) == typeof(float))
34-
|| (typeof(T) == typeof(double));
32+
public static bool Vectorizable => false; // TODO: vectorize
3533

3634
public static (T, T) Invoke(T x) => T.SinCos(x);
37-
38-
public static (Vector128<T> First, Vector128<T> Second) Invoke(Vector128<T> x)
39-
{
40-
#if NET9_0_OR_GREATER
41-
if (typeof(T) == typeof(double))
42-
{
43-
(Vector128<double> sin, Vector128<double> cos) = Vector128.SinCos(x.AsDouble());
44-
return (sin.As<double, T>(), cos.As<double, T>());
45-
}
46-
else
47-
{
48-
Debug.Assert(typeof(T) == typeof(float));
49-
(Vector128<float> sin, Vector128<float> cos) = Vector128.SinCos(x.AsSingle());
50-
return (sin.As<float, T>(), cos.As<float, T>());
51-
}
52-
#else
53-
if (typeof(T) == typeof(float))
54-
{
55-
return (
56-
SinOperatorSingle.Invoke(x.AsSingle()).As<float, T>(),
57-
CosOperatorSingle.Invoke(x.AsSingle()).As<float, T>()
58-
);
59-
}
60-
else
61-
{
62-
Debug.Assert(typeof(T) == typeof(double));
63-
return (
64-
SinOperatorDouble.Invoke(x.AsDouble()).As<double, T>(),
65-
CosOperatorDouble.Invoke(x.AsDouble()).As<double, T>()
66-
);
67-
}
68-
#endif
69-
}
70-
71-
public static (Vector256<T> First, Vector256<T> Second) Invoke(Vector256<T> x)
72-
{
73-
#if NET9_0_OR_GREATER
74-
if (typeof(T) == typeof(double))
75-
{
76-
(Vector256<double> sin, Vector256<double> cos) = Vector256.SinCos(x.AsDouble());
77-
return (sin.As<double, T>(), cos.As<double, T>());
78-
}
79-
else
80-
{
81-
Debug.Assert(typeof(T) == typeof(float));
82-
(Vector256<float> sin, Vector256<float> cos) = Vector256.SinCos(x.AsSingle());
83-
return (sin.As<float, T>(), cos.As<float, T>());
84-
}
85-
#else
86-
if (typeof(T) == typeof(float))
87-
{
88-
return (
89-
SinOperatorSingle.Invoke(x.AsSingle()).As<float, T>(),
90-
CosOperatorSingle.Invoke(x.AsSingle()).As<float, T>()
91-
);
92-
}
93-
else
94-
{
95-
Debug.Assert(typeof(T) == typeof(double));
96-
return (
97-
SinOperatorDouble.Invoke(x.AsDouble()).As<double, T>(),
98-
CosOperatorDouble.Invoke(x.AsDouble()).As<double, T>()
99-
);
100-
}
101-
#endif
102-
}
103-
104-
public static (Vector512<T> First, Vector512<T> Second) Invoke(Vector512<T> x)
105-
{
106-
#if NET9_0_OR_GREATER
107-
if (typeof(T) == typeof(double))
108-
{
109-
(Vector512<double> sin, Vector512<double> cos) = Vector512.SinCos(x.AsDouble());
110-
return (sin.As<double, T>(), cos.As<double, T>());
111-
}
112-
else
113-
{
114-
Debug.Assert(typeof(T) == typeof(float));
115-
(Vector512<float> sin, Vector512<float> cos) = Vector512.SinCos(x.AsSingle());
116-
return (sin.As<float, T>(), cos.As<float, T>());
117-
}
118-
#else
119-
if (typeof(T) == typeof(float))
120-
{
121-
return (
122-
SinOperatorSingle.Invoke(x.AsSingle()).As<float, T>(),
123-
CosOperatorSingle.Invoke(x.AsSingle()).As<float, T>()
124-
);
125-
}
126-
else
127-
{
128-
Debug.Assert(typeof(T) == typeof(double));
129-
return (
130-
SinOperatorDouble.Invoke(x.AsDouble()).As<double, T>(),
131-
CosOperatorDouble.Invoke(x.AsDouble()).As<double, T>()
132-
);
133-
}
134-
#endif
135-
}
35+
public static (Vector128<T> First, Vector128<T> Second) Invoke(Vector128<T> x) => throw new NotSupportedException();
36+
public static (Vector256<T> First, Vector256<T> Second) Invoke(Vector256<T> x) => throw new NotSupportedException();
37+
public static (Vector512<T> First, Vector512<T> Second) Invoke(Vector512<T> x) => throw new NotSupportedException();
13638
}
13739
}
13840
}

0 commit comments

Comments
 (0)