forked from flexflow/FlexFlow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate over to use type-erased binary tree
- Loading branch information
Showing
44 changed files
with
666 additions
and
467 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
lib/compiler/include/compiler/machine_mapping/get_optimal_machine_mapping.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 6 additions & 15 deletions
21
lib/compiler/include/compiler/machine_mapping/machine_mapping_cache.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
lib/compiler/include/compiler/machine_mapping/machine_mapping_cache.struct.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace = "FlexFlow" | ||
name = "MachineMappingCache" | ||
features = [ | ||
"eq", | ||
"hash", | ||
"fmt", | ||
] | ||
|
||
includes = [ | ||
"<unordered_map>", | ||
"compiler/machine_mapping/machine_mapping_state.dtg.h", | ||
"compiler/machine_mapping/machine_mapping_result.dtg.h", | ||
] | ||
|
||
src_includes = [ | ||
"utils/fmt/unordered_map.h", | ||
"utils/hash/unordered_map.h", | ||
] | ||
|
||
[[fields]] | ||
name = "raw_map" | ||
type = "std::unordered_map<::FlexFlow::MachineMappingState, ::FlexFlow::MachineMappingResult>" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 13 additions & 7 deletions
20
lib/compiler/src/compiler/machine_mapping/machine_mapping_cache.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,23 @@ | ||
#include "compiler/machine_mapping/machine_mapping_cache.h" | ||
#include "utils/containers/try_at.h" | ||
#include "utils/containers/contains_key.h" | ||
|
||
namespace FlexFlow { | ||
|
||
std::optional<MachineMappingResult> | ||
MachineMappingCache::load(MachineMappingState const &state) const { | ||
return try_at(this->cache, state); | ||
MachineMappingCache empty_machine_mapping_cache() { | ||
return MachineMappingCache{{}}; | ||
} | ||
|
||
void MachineMappingCache::save(MachineMappingState const &state, | ||
MachineMappingResult const &result) { | ||
assert(!contains_key(cache, state)); | ||
cache.emplace(state, result); | ||
std::optional<MachineMappingResult> machine_mapping_cache_load(MachineMappingCache const &cache, MachineMappingState const &k) { | ||
return try_at(cache.raw_map, k); | ||
} | ||
|
||
void machine_mapping_cache_save(MachineMappingCache &cache, MachineMappingState const &k, MachineMappingResult const &v) { | ||
if (contains_key(cache.raw_map, k)) { | ||
throw mk_runtime_error(fmt::format("machine_mapping_cache_save expected key to not already exist, but received existing key {}", k)); | ||
} | ||
|
||
cache.raw_map.emplace(k, v); | ||
} | ||
|
||
} // namespace FlexFlow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 0 additions & 91 deletions
91
lib/compiler/test/src/compiler/machine_mapping/machine_mapping_cache.cc
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.