@@ -104,13 +104,15 @@ void check_embedding_xbit_args(
104104
105105 ET_CHECK_MSG (
106106 out.scalar_type () == ScalarType::Float ||
107- out.scalar_type () == ScalarType::Half,
107+ out.scalar_type () == ScalarType::Half ||
108+ out.scalar_type () == ScalarType::BFloat16,
108109 " out.scalar_type() %" PRId8 " is not supported:" ,
109110 static_cast <int8_t >(out.scalar_type ()));
110111
111112 ET_CHECK_MSG (
112113 weight_scales.scalar_type () == ScalarType::Float ||
113- weight_scales.scalar_type () == ScalarType::Half,
114+ weight_scales.scalar_type () == ScalarType::Half ||
115+ weight_scales.scalar_type () == ScalarType::BFloat16,
114116 " weight_scales.scalar_type() %" PRId8 " is not supported:" ,
115117 static_cast <int8_t >(weight_scales.scalar_type ()));
116118
@@ -284,17 +286,19 @@ Tensor& quantized_embedding_xbit_out(
284286
285287 constexpr auto name = " quantized_decomposed::embedding_xbit.out" ;
286288 ScalarType indices_type = indices.scalar_type ();
287- ET_SWITCH_TWO_TYPES (Float, Half, out_type, ctx, name, CTYPE_OUT , [&]() {
288- ET_SWITCH_TWO_TYPES (Int, Long, indices_type, ctx, name, CTYPE_IDX , [&]() {
289- embedding_xbit_per_channel<CTYPE_OUT , CTYPE_OUT , CTYPE_IDX >(
290- weight,
291- weight_scales,
292- opt_weight_zero_points,
293- indices,
294- out,
295- weight_nbit);
296- });
297- });
289+ ET_SWITCH_THREE_TYPES (
290+ Float, Half, BFloat16, out_type, ctx, name, CTYPE_OUT , [&]() {
291+ ET_SWITCH_TWO_TYPES (
292+ Int, Long, indices_type, ctx, name, CTYPE_IDX , [&]() {
293+ embedding_xbit_per_channel<CTYPE_OUT , CTYPE_OUT , CTYPE_IDX >(
294+ weight,
295+ weight_scales,
296+ opt_weight_zero_points,
297+ indices,
298+ out,
299+ weight_nbit);
300+ });
301+ });
298302
299303 return out;
300304}
@@ -358,19 +362,22 @@ Tensor& quantized_embedding_xbit_dtype_out(
358362
359363 constexpr auto name = " quantized_decomposed::embedding_xbit.dtype_out" ;
360364 ScalarType indices_type = indices.scalar_type ();
361- ET_SWITCH_TWO_TYPES (Float, Half, params_type, ctx, name, CTYPE_P , [&]() {
362- ET_SWITCH_TWO_TYPES (Float, Half, out_type, ctx, name, CTYPE_OUT , [&]() {
363- ET_SWITCH_TWO_TYPES (Int, Long, indices_type, ctx, name, CTYPE_IDX , [&]() {
364- embedding_xbit_per_channel<CTYPE_P , CTYPE_OUT , CTYPE_IDX >(
365- weight,
366- weight_scales,
367- opt_weight_zero_points,
368- indices,
369- out,
370- weight_nbit);
365+ ET_SWITCH_THREE_TYPES (
366+ Float, Half, BFloat16, params_type, ctx, name, CTYPE_P , [&]() {
367+ ET_SWITCH_THREE_TYPES (
368+ Float, Half, BFloat16, out_type, ctx, name, CTYPE_OUT , [&]() {
369+ ET_SWITCH_TWO_TYPES (
370+ Int, Long, indices_type, ctx, name, CTYPE_IDX , [&]() {
371+ embedding_xbit_per_channel<CTYPE_P , CTYPE_OUT , CTYPE_IDX >(
372+ weight,
373+ weight_scales,
374+ opt_weight_zero_points,
375+ indices,
376+ out,
377+ weight_nbit);
378+ });
379+ });
371380 });
372- });
373- });
374381
375382 return out;
376383}
0 commit comments