System\Numerics\Tensors\netcore\TensorPrimitives.AddMultiply.cs (3)
31if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, AddMultiplyOperator<float>>(x, y, multiplier, destination))
59if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, AddMultiplyOperator<float>>(x, y, multiplier, destination))
87if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, AddMultiplyOperator<float>>(x, y, multiplier, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Clamp.cs (7)
35if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination))
64if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination))
93if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination))
122if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMinMaxX<float>>(min, max, x, destination))
154if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorXMinMax<float>>(x, min, max, destination))
181if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMinMaxX<float>>(min, max, x, destination))
208if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, ClampOperatorMaxXMin<float>>(max, x, min, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.CosineSimilarity.cs (17)
34if (typeof(T) == typeof(Half))
37return (T)(object)CosineSimilarityHalfCore(Rename<T, Half>(x), Rename<T, Half>(y));
183/// <summary>Provides the same implementation as <see cref="CosineSimilarityCore"/>, but specifically for <see cref="Half"/>.</summary>
184private static Half CosineSimilarityHalfCore(ReadOnlySpan<Half> x, ReadOnlySpan<Half> y)
203ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x));
204ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y));
240return (Half)Finalize(dotProductVector, xSumOfSquaresVector, ySumOfSquaresVector);
245ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x));
246ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y));
282return (Half)Finalize(dotProductVector, xSumOfSquaresVector, ySumOfSquaresVector);
287ref short xRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(x));
288ref short yRef = ref Unsafe.As<Half, short>(ref MemoryMarshal.GetReference(y));
324return (Half)Finalize(dotProductVector, xSumOfSquaresVector, ySumOfSquaresVector);
335return (Half)Finalize(dotProduct, xSumOfSquares, ySumOfSquares);
System\Numerics\Tensors\netcore\TensorPrimitives.FusedMultiplyAdd.cs (3)
40if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, FusedMultiplyAddOperator<float>>(x, y, addend, destination))
75if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, FusedMultiplyAddOperator<float>>(x, y, addend, destination))
109if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, FusedMultiplyAddOperator<float>>(x, y, addend, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.Half.cs (48)
27public static void ConvertToHalf(ReadOnlySpan<float> source, Span<Half> destination) =>
45public static void ConvertToSingle(ReadOnlySpan<Half> source, Span<float> destination) =>
52Debug.Assert(typeof(T) == typeof(Half));
54if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
69Debug.Assert(typeof(T) == typeof(Half));
86Debug.Assert(typeof(T) == typeof(Half));
88if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
104Debug.Assert(typeof(T) == typeof(Half));
106if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
110BitConverter.HalfToInt16Bits((Half)(object)y!),
122Debug.Assert(typeof(T) == typeof(Half));
124if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(y)))
127BitConverter.HalfToInt16Bits((Half)(object)x!),
140Debug.Assert(typeof(T) == typeof(Half));
158Debug.Assert(typeof(T) == typeof(Half));
164BitConverter.HalfToInt16Bits((Half)(object)y!),
176Debug.Assert(typeof(T) == typeof(Half));
178if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
194Debug.Assert(typeof(T) == typeof(Half));
196if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
200BitConverter.HalfToInt16Bits((Half)(object)y!),
212if (typeof(T) == typeof(Half) && IsVectorizable(Rename<T, Half>(x)))
228Debug.Assert(typeof(T) == typeof(Half));
230if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
247Debug.Assert(typeof(T) == typeof(Half));
249if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
253BitConverter.HalfToInt16Bits((Half)(object)y!),
266Debug.Assert(typeof(T) == typeof(Half));
268if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
273BitConverter.HalfToInt16Bits((Half)(object)z!),
285Debug.Assert(typeof(T) == typeof(Half));
287if (TOp.Vectorizable && IsVectorizable(Rename<T, Half>(x)))
291BitConverter.HalfToInt16Bits((Half)(object)y!),
292BitConverter.HalfToInt16Bits((Half)(object)z!),
305private static bool IsVectorizable(ReadOnlySpan<Half> source) =>
309/// <summary><see cref="IUnaryOperator{T, T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary>
317(Half)TUnary.Invoke((float)BitConverter.Int16BitsToHalf(x)));
344/// <summary><see cref="IBinaryOperator{T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary>
351BitConverter.HalfToInt16Bits((Half)TBinary.Invoke(
383/// <summary><see cref="IAggregationOperator{T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary>
390BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke(
424return BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke(
432return BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke(
440return BitConverter.HalfToInt16Bits((Half)TAggregate.Invoke(
445public static short IdentityValue => BitConverter.HalfToInt16Bits((Half)TAggregate.IdentityValue);
448/// <summary><see cref="ITernaryOperator{T}"/> wrapper for working with <see cref="Half"/> reinterpreted as <see cref="short"/> in order to enable vectorization.</summary>
455BitConverter.HalfToInt16Bits((Half)TTernary.Invoke(
System\Numerics\Tensors\netcore\TensorPrimitives.Lerp.cs (3)
32if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, LerpOperator<float>>(x, y, amount, destination))
60if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, LerpOperator<float>>(x, y, amount, destination))
88if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, LerpOperator<float>>(x, y, amount, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MultiplyAdd.cs (3)
31if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddOperator<float>>(x, y, addend, destination))
60if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddOperator<float>>(x, y, addend, destination))
88if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddOperator<float>>(x, y, addend, destination))
System\Numerics\Tensors\netcore\TensorPrimitives.MultiplyAddEstimate.cs (3)
39if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddEstimateOperator<float>>(x, y, addend, destination))
72if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddEstimateOperator<float>>(x, y, addend, destination))
104if (typeof(T) == typeof(Half) && TryTernaryInvokeHalfAsInt16<T, MultiplyAddEstimateOperator<float>>(x, y, addend, destination))