Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions kernels/portable/cpu/scalar_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,6 @@ struct promote_type_with_scalar_type {
static_assert(
!is_bits_type<T1>::value,
"promote_type_with_scalar_type not valid for bits dtypes");
static_assert(
!std::is_same<
T1,
typename ScalarTypeToCppType<exec_aten::ScalarType::BFloat16>::type>::
value,
"promote_type_with_scalar_type not valid for BFloat16");
using promote_type_with_scalar_type_not_respecting_half_to_float =
typename std::conditional<
is_complex_type<T1>::value ||
Expand All @@ -119,10 +113,14 @@ struct promote_type_with_scalar_type {
public:
using type = typename std::conditional<
half_to_float &&
std::is_same<
promote_type_with_scalar_type_not_respecting_half_to_float,
typename ScalarTypeToCppType<exec_aten::ScalarType::Half>::type>::
value,
(std::is_same<
promote_type_with_scalar_type_not_respecting_half_to_float,
typename ScalarTypeToCppType<
exec_aten::ScalarType::Half>::type>::value ||
std::is_same<
promote_type_with_scalar_type_not_respecting_half_to_float,
typename ScalarTypeToCppType<
exec_aten::ScalarType::BFloat16>::type>::value),
typename ScalarTypeToCppType<exec_aten::ScalarType::Float>::type,
promote_type_with_scalar_type_not_respecting_half_to_float>::type;
};
Expand Down
41 changes: 28 additions & 13 deletions runtime/core/exec_aten/util/genScalarTypeTable.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,35 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

indexToType = ["U1", "I1", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "B1"]
indexToType = [
"U1",
"I1",
"I2",
"I4",
"I8",
"F2",
"F4",
"F8",
"C2",
"C4",
"C8",
"B1",
"BF",
]
promoteTypesLookup = [
["U1", "I2", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "U1"],
["I2", "I1", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I1"],
["I2", "I2", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I2"],
["I4", "I4", "I4", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I4"],
["I8", "I8", "I8", "I8", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I8"],
["F2", "F2", "F2", "F2", "F2", "F2", "F4", "F8", "C2", "C4", "C8", "F2"],
["F4", "F4", "F4", "F4", "F4", "F4", "F4", "F8", "C4", "C4", "C8", "F4"],
["F8", "F8", "F8", "F8", "F8", "F8", "F8", "F8", "C8", "C8", "C8", "F8"],
["C2", "C2", "C2", "C2", "C2", "C2", "C4", "C8", "C2", "C4", "C8", "C2"],
["C4", "C4", "C4", "C4", "C4", "C4", "C4", "C8", "C4", "C4", "C8", "C4"],
["C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8"],
["U1", "I1", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "B1"],
["U1", "I2", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "U1", "BF"],
["I2", "I1", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I1", "BF"],
["I2", "I2", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I2", "BF"],
["I4", "I4", "I4", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I4", "BF"],
["I8", "I8", "I8", "I8", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "I8", "BF"],
["F2", "F2", "F2", "F2", "F2", "F2", "F4", "F8", "C2", "C4", "C8", "F2", "F4"],
["F4", "F4", "F4", "F4", "F4", "F4", "F4", "F8", "C4", "C4", "C8", "F4", "F4"],
["F8", "F8", "F8", "F8", "F8", "F8", "F8", "F8", "C8", "C8", "C8", "F8", "F8"],
["C2", "C2", "C2", "C2", "C2", "C2", "C4", "C8", "C2", "C4", "C8", "C2", "C4"],
["C4", "C4", "C4", "C4", "C4", "C4", "C4", "C8", "C4", "C4", "C8", "C4", "C4"],
["C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8", "C8"],
["U1", "I1", "I2", "I4", "I8", "F2", "F4", "F8", "C2", "C4", "C8", "B1", "BF"],
["BF", "BF", "BF", "BF", "BF", "F4", "F4", "F8", "C4", "C4", "C8", "BF", "BF"],
]
for rowIndex, row in enumerate(promoteTypesLookup):
for colIndex, col in enumerate(row):
Expand Down
Loading
Loading