Skip to content

Commit

Permalink
Allow ISA selection In EmbeddingSpMDM functions (pytorch#418)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: pytorch#418

Allow architecture selection based on environment variables

Reviewed By: dskhudia

Differential Revision: D23302058

fbshipit-source-id: 280e685536156faf983caf317303af8e8decd744
  • Loading branch information
efiks authored and facebook-github-bot committed Aug 27, 2020
1 parent be51cdd commit 59558e6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/EmbeddingSpMDM.cc
Original file line number Diff line number Diff line change
Expand Up @@ -834,9 +834,10 @@ GenerateEmbeddingSpMDM(
if (!cpuinfo_initialize()) {
throw std::runtime_error("Failed to initialize cpuinfo!");
}
const inst_set_t isa = fbgemmInstructionSet();
if ((std::is_same<inType, float>::value ||
std::is_same<inType, float16>::value) &&
block_size == 1 && fbgemmHasAvx2Support()) {
block_size == 1 && isYmm(isa)) {
return
[=](std::int64_t output_size,
std::int64_t index_size,
Expand All @@ -859,7 +860,7 @@ GenerateEmbeddingSpMDM(
is_weight_positional,
use_offsets);
};
} else if (fbgemmHasAvx512Support()) {
} else if (isZmm(isa)) {
static GenEmbeddingSpMDMLookup<
inType,
indxType,
Expand Down Expand Up @@ -892,7 +893,7 @@ GenerateEmbeddingSpMDM(
out,
nullptr /* mask not used in avx512 */);
};
} else if (fbgemmHasAvx2Support()) {
} else if (isYmm(isa)) {
static GenEmbeddingSpMDMLookup<
inType,
indxType,
Expand Down Expand Up @@ -968,7 +969,8 @@ GenerateEmbeddingSpMDMRowWiseSparse(
if (!cpuinfo_initialize()) {
throw std::runtime_error("Failed to initialize cpuinfo!");
}
if (fbgemmHasAvx512Support()) {
inst_set_t isa = fbgemmInstructionSet();
if (isZmm(isa)) {
static GenEmbeddingSpMDMLookup<
inType,
indxType,
Expand Down Expand Up @@ -1004,7 +1006,7 @@ GenerateEmbeddingSpMDMRowWiseSparse(
compressed_indices_table,
nullptr /* mask not used in avx512 */);
};
} else if (fbgemmHasAvx2Support()) {
} else if (isYmm(isa)) {
static GenEmbeddingSpMDMLookup<
inType,
indxType,
Expand Down

0 comments on commit 59558e6

Please sign in to comment.