Skip to content

Commit aeb13f2

Browse files
csarofeenfacebook-github-bot
authored andcommitted
Make ValType hashable. (#35917)
Summary: Build fix stemming from #34785 Pull Request resolved: #35917 Differential Revision: D20829353 Pulled By: soumith fbshipit-source-id: 4ba84ecedd354efbc9ac47c9b0f0e3871b404f13
1 parent 1a146b0 commit aeb13f2

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

torch/csrc/jit/codegen/cuda/fusion.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ namespace torch {
1414
namespace jit {
1515
namespace fuser {
1616

17+
// https://stackoverflow.com/questions/18837857/cant-use-enum-class-as-unordered-map-key
18+
struct TypeHash {
19+
template <typename T>
20+
std::size_t operator()(T t) const {
21+
return static_cast<std::size_t>(t);
22+
}
23+
};
24+
1725
/*
1826
* Usage: FusionGuard and Fusion are required user interfaces for any operation
1927
* underlying the code generator. In order to create values, expressions, and
@@ -175,7 +183,7 @@ struct TORCH_CUDA_API Fusion : public IRInputOutput {
175183
StmtNameType getExprName();
176184

177185
// map from valtype to individual name counters
178-
std::unordered_map<ValType, StmtNameType> val_type_name_map = {
186+
std::unordered_map<ValType, StmtNameType, TypeHash> val_type_name_map = {
179187
{ValType::TensorView, 0},
180188
{ValType::TensorDomain, 0},
181189
{ValType::IterDomain, 0},

0 commit comments

Comments
 (0)