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
{{ message }}
Repository navigation
[SM6.10] Convert needs an overload that takes an InterpretedVector #8418
Convert currently does not support packed type vector sizes that are not a multiple of the number of elements per scalar.
For example, if we have packed vector with component type F8_E4M3FN and size 7, it gets loaded to into vector<uint, 2>. When we want to convert it to vector<half, 7>, the Convert function does not support that because it returns vector<half, 8>. It has no way of knowing that the vector<uint, 2> actually contains 7 valid packed element and not 8.
VectorRef<ComponentType::F8_E4M3FN, 7> vecRef = {Buf, 0};
vector<uint, 2> vecPacked = BiasRef.Buf.Load<vector<uint,2>(0);
vector<half, 7> vecConverted = Convert<ComponentType::F16, ComponentType::F8_E4M3FN>(vecPacked);
error: cannot initialize a variable of type 'vector<half, 7>' with an rvalue of type 'vector<half, 8>'
We should add a Convert function that takes an InterpretedVector that would carry the packed element count into Convert and enable returning of the correct vector type.
Once this is fixed, update MultiplyAdd implementations in the linalg.h header that take a VectorRef to use this new overload.
changed the title [-][SM6.10] Convert need InterpretedVector overload[/-][+][SM6.10] Convert needs an overload that takes InterpretedVector[/+]on May 1, 2026
changed the title [-][SM6.10] Convert needs an overload that takes InterpretedVector[/-][+][SM6.10] Convert needs an overload that takes sn InterpretedVector[/+]on May 1, 2026
changed the title [-][SM6.10] Convert needs an overload that takes sn InterpretedVector[/-][+][SM6.10] Convert needs an overload that takes an InterpretedVector[/+]on May 1, 2026
Since an InterpretedVector for the input to Convert won't solve the problem - N is number of HLSL native scalars in the vector rather than packed elements, I have an alternative solution:
We could add a template argument to Convert which defaults to __detail::DstN<DestTy, OriginTy, N>::Value, but can be overridden to specify a different number for output components when converting from packed to non-packed, and the desired number of output components isn't an even multiple of ElementsPerScalar.
template <ComponentEnum DestTy, ComponentEnum OriginTy, typename T, int N,
int DestN = __detail::DstN<DestTy, OriginTy, N>::Value>
We could constrain the new template argument (say: DestN) to:
Activity
[-][SM6.10] Convert need InterpretedVector overload[/-][+][SM6.10] Convert needs an overload that takes InterpretedVector[/+][-][SM6.10] Convert needs an overload that takes InterpretedVector[/-][+][SM6.10] Convert needs an overload that takes sn InterpretedVector[/+][-][SM6.10] Convert needs an overload that takes sn InterpretedVector[/-][+][SM6.10] Convert needs an overload that takes an InterpretedVector[/+]Added no-op Convert version when DestTy and OriginTy match.
tex3d commentedon May 4, 2026
Since an
InterpretedVectorfor the input to Convert won't solve the problem -Nis number of HLSL native scalars in the vector rather than packed elements, I have an alternative solution:We could add a template argument to
Convertwhich defaults to__detail::DstN<DestTy, OriginTy, N>::Value, but can be overridden to specify a different number for output components when converting from packed to non-packed, and the desired number of output components isn't an even multiple ofElementsPerScalar.We could constrain the new template argument (say:
DestN) to:DestN > __detail::DstN<DestTy, OriginTy, N - 1>::Value && DestN <= __detail::DstN<DestTy, OriginTy, N>::ValueNo changes should be required for the DXIL op, since that dimension is explicit in the overload, though it will require testing.
V-FEXrt commentedon Aug 19, 2026
This also needs to be fixed for OuterProduct once it's updated to handle packed vectorsOuterProduct is natively only now
V-FEXrt commentedon Sep 25, 2026
This is implemented already :)
https://godbolt.org/z/3aohe15ah
The
vector<half, 8>gets truncated before going into theMultiplyAdd