• 文档 >
  • TBE CPU 自动向量化
快捷方式

TBE CPU 自动向量化

FP8/16/32 自动向量化实现方法

template<typename InType, typename IndexType, typename OffsetType, typename OutType> static bool ALWAYS_INLINE EmbeddingSpMDM_autovec (const int64_t block_size, const int64_t output_size, const int64_t index_size, const int64_t data_size, const InType *input, const IndexType *indices, const OffsetType *offsets_or_lengths, const float *weights, bool normalize_by_lengths, OutType *out, const bool is_weight_positional, const bool use_offsets, const int64_t output_stride, const int64_t input_stride, const bool no_bag, const bool is_bf16_out, const bool is_bf16_in)

针对 FP32 权重类型的 EmbeddingSpMDM_ref 方法的自动向量化版本。

模板参数:
  • InType – 输入数据类型(使用 uint8_t

  • IndexType – 索引数据类型(使用 int64_t

  • OffsetType – 偏移量数据类型(使用 int32_t

  • OutType – 输出数据类型(使用 float

参数:
  • block_size – 块中的元素数量 (int64_t)

  • output_size – 输出中的元素数量 (int64_t)

  • index_size – 索引中的元素数量 (int64_t)

  • data_size – 数据中的元素数量 (int64_t)

  • input – 输入地址 (InType*)

  • indices – 索引地址 (IndexType*)

  • offsets_or_lengths – 偏移量地址 (OffsetType*)

  • weights – 求和的权重;可选,对于非加权求和可为 null (float*)

  • normalize_by_lengths – 是否按长度进行归一化 (bool)

  • out – 输出地址 (OutType*)

  • is_weight_positional – 如果为 true,则权重是位置性的;对于 FP32 自动向量化实现,设置为 false (bool)

  • use_offsets – 如果为 true,将使用偏移量而非长度;对于 FP32 自动向量化实现,设置为 true (bool)

  • output_stride – 如果为-1,则 output_stride 与 block_size 相同;对于 FP32 自动向量化实现,设置为-1 (int64_t)

  • input_stride – 如果为-1,则 input_stride 与 block_size 相同;对于 FP32 自动向量化实现,设置为-1 (int64_t)

  • scale_bias_last – 如果为 true,则缩放和偏置出现在每行的末尾;对于 FP32 自动向量化实现,设置为 true (bool)

  • no_bag – 如果为 true,则无嵌入包;对于 FP32 自动向量化实现,设置为 false (bool)

  • is_bf16_out – 如果为 true,则输出为 BFLOAT16 类型;对于 FP32 自动向量化实现,设置为 false (bool)

  • is_bf16_in – 如果为 true,则输入为 BFLOAT16 类型;对于 FP32 自动向量化实现,设置为 false (bool)

template<typename IndexType, typename OffsetType, typename OutType> static bool ALWAYS_INLINE EmbeddingSpMDMFP8_autovec (const int64_t block_size, const int64_t output_size, const int64_t index_size, const int64_t data_size, const uint8_t *input, const IndexType *indices, const OffsetType *offsets_or_lengths, const float *weights, bool normalize_by_lengths, OutType *out, const bool is_weight_positional, const bool use_offsets, const int64_t output_stride, const int64_t input_stride, const int exponent_bits, const int exponent_bias, const bool is_bf16_out)

针对 FP8 权重类型的 EmbeddingSpMDM_ref 方法的自动向量化版本。

模板参数:
  • InType – 输入数据类型(使用 uint8_t

  • IndexType – 索引数据类型(使用 int64_t

  • OffsetType – 偏移量数据类型(使用 int32_t

  • OutType – 输出数据类型(使用 float

参数:
  • block_size – 块中的元素数量 (int64_t)

  • output_size – 输出中的元素数量 (int64_t)

  • index_size – 索引中的元素数量 (int64_t)

  • data_size – 数据中的元素数量 (int64_t)

  • input – 输入地址 (InType*)

  • indices – 索引地址 (IndexType*)

  • offsets_or_lengths – 偏移量地址 (OffsetType*)

  • weights – 求和的权重;可选,对于非加权求和可为 null (float*)

  • normalize_by_lengths – 是否按长度进行归一化 (bool)

  • out – 输出地址 (OutType*)

  • is_weight_positional – 如果为 true,则权重是位置性的;对于 FP8 自动向量化实现,设置为 false (bool)

  • use_offsets – 如果为 true,将使用偏移量而非长度;对于 FP8 自动向量化实现,设置为 true (bool)

  • output_stride – 如果为-1,则 output_stride 与 block_size 相同;对于 FP8 自动向量化实现,设置为-1 (int64_t)

  • exponent_bits – 用于指数的位数

  • exponent_bias – 用于指数的偏置

  • is_bf16_out – 如果为 true,则输出为 BFLOAT16 类型;对于 FP8 自动向量化实现,设置为 false (bool)

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

查找开发资源并让您的问题得到解答

查看资源