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.
- Loading branch information
Showing
42 changed files
with
797 additions
and
434 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
lib/compiler/include/compiler/cost_estimator/cost_estimator.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#ifndef _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_COST_ESTIMATOR_COST_ESTIMATOR_H | ||
#define _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_COST_ESTIMATOR_COST_ESTIMATOR_H | ||
|
||
#include <vector> | ||
#include "compiler/cost_estimator/op_cost_estimate_key.dtg.h" | ||
#include "compiler/cost_estimator/tensor_set_movement.dtg.h" | ||
#include "op-attrs/parallel_tensor_shape.dtg.h" | ||
#include "op-attrs/pcg_operator_attrs.dtg.h" | ||
#include "pcg/machine_view.dtg.h" | ||
|
||
namespace FlexFlow { | ||
|
||
struct ICostEstimator { | ||
virtual float estimate_cost(OpCostEstimateKey const &) const = 0; | ||
virtual float estimate_cost(TensorSetMovement const &) const = 0; | ||
|
||
ICostEstimator() = default; | ||
ICostEstimator(ICostEstimator const &) = delete; | ||
ICostEstimator &operator=(ICostEstimator const &) = delete; | ||
|
||
virtual ~ICostEstimator() = default; | ||
}; | ||
CHECK_RC_COPY_VIRTUAL_COMPLIANT(ICostEstimator); | ||
|
||
struct CostEstimator { | ||
float estimate_cost(OpCostEstimateKey const &k) const; | ||
float estimate_cost(TensorSetMovement const &m) const; | ||
|
||
template <typename T, typename... Args> | ||
static typename std::enable_if<std::is_base_of<ICostEstimator, T>::value, | ||
CostEstimator>::type | ||
create(Args &&...args) { | ||
return CostEstimator(std::make_shared<T>(std::forward<Args>(args)...)); | ||
} | ||
|
||
private: | ||
CostEstimator(std::shared_ptr<ICostEstimator> implementation_ptr); | ||
|
||
private: | ||
std::shared_ptr<ICostEstimator> implementation_ptr; | ||
}; | ||
|
||
} // namespace FlexFlow | ||
|
||
#endif |
File renamed without changes.
15 changes: 10 additions & 5 deletions
15
...mpiler/comm_cost_estimate_key.struct.toml → ...imator/single_tensor_movement.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 |
---|---|---|
@@ -1,25 +1,30 @@ | ||
namespace = "FlexFlow" | ||
name = "CommCostEstimateKey" | ||
name = "SingleTensorMovement" | ||
features = [ | ||
"eq", | ||
"ord", | ||
"hash", | ||
"fmt", | ||
] | ||
|
||
includes = [ | ||
"op-attrs/parallel_tensor_shape.dtg.h", | ||
"pcg/machine_view.dtg.h", | ||
"<unordered_set>", | ||
] | ||
|
||
src_includes = [ | ||
"utils/hash/unordered_set.h", | ||
"utils/fmt/unordered_set.h", | ||
] | ||
|
||
[[fields]] | ||
name = "parallel_tensor_shape" | ||
type = "::FlexFlow::ParallelTensorShape" | ||
|
||
[[fields]] | ||
name = "src_machine_view" | ||
type = "::FlexFlow::MachineView" | ||
name = "src_machine_views" | ||
type = "std::unordered_set<::FlexFlow::MachineView>" | ||
|
||
[[fields]] | ||
name = "dst_machine_view" | ||
type = "::FlexFlow::MachineView" | ||
type = "std::unordered_set<::FlexFlow::MachineView>" |
21 changes: 21 additions & 0 deletions
21
lib/compiler/include/compiler/cost_estimator/tensor_set_movement.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,21 @@ | ||
namespace = "FlexFlow" | ||
name = "TensorSetMovement" | ||
features = [ | ||
"eq", | ||
"hash", | ||
"fmt", | ||
] | ||
|
||
includes = [ | ||
"compiler/cost_estimator/single_tensor_movement.dtg.h", | ||
"<unordered_set>", | ||
] | ||
|
||
src_includes = [ | ||
"utils/fmt/unordered_multiset.h", | ||
"utils/hash/unordered_multiset.h", | ||
] | ||
|
||
[[fields]] | ||
name = "single_tensor_movements" | ||
type = "std::unordered_multiset<::FlexFlow::SingleTensorMovement>" |
18 changes: 0 additions & 18 deletions
18
lib/compiler/include/compiler/machine_mapping/estimate_cost_across_split.h
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
lib/compiler/include/compiler/machine_mapping/estimate_layer_cost.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
18 changes: 18 additions & 0 deletions
18
lib/compiler/include/compiler/machine_mapping/get_tensor_set_movement_across_split.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_MACHINE_MAPPING_ESTIMATE_COST_ACROSS_SPLIT_H | ||
#define _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_MACHINE_MAPPING_ESTIMATE_COST_ACROSS_SPLIT_H | ||
|
||
#include "compiler/cost_estimator/tensor_set_movement.dtg.h" | ||
#include "compiler/machine_mapping/partial_machine_mapping.dtg.h" | ||
#include "compiler/machine_mapping/transitive_reduced_pcg.dtg.h" | ||
#include "compiler/series_parallel/pcg_binary_series_split.dtg.h" | ||
|
||
namespace FlexFlow { | ||
|
||
TensorSetMovement get_tensor_set_movement_across_split(TransitiveReducedPCG const &transitive_reduced_pcg, | ||
PCGBinarySeriesSplit const &split, | ||
PartialMachineMapping const &pre_mapping, | ||
PartialMachineMapping const &post_mapping); | ||
|
||
} // namespace FlexFlow | ||
|
||
#endif |
16 changes: 16 additions & 0 deletions
16
lib/compiler/include/compiler/machine_mapping/include_unconstrained.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,16 @@ | ||
namespace = "FlexFlow" | ||
name = "IncludeUnconstrained" | ||
features = [ | ||
"eq", | ||
"ord", | ||
"hash", | ||
"fmt", | ||
"rapidcheck", | ||
"json", | ||
] | ||
|
||
includes = [] | ||
|
||
[[fields]] | ||
name = "raw_bool" | ||
type = "bool" |
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
24 changes: 15 additions & 9 deletions
24
lib/compiler/include/compiler/machine_mapping/partial_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
#ifndef _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_MACHINE_MAPPING_PARTIAL_MACHINE_MAPPING_H | ||
#define _FLEXFLOW_LIB_COMPILER_INCLUDE_COMPILER_MACHINE_MAPPING_PARTIAL_MACHINE_MAPPING_H | ||
|
||
#include "compiler/machine_mapping/machine_mapping.dtg.h" | ||
#include "compiler/machine_mapping/machine_mapping_context.dtg.h" | ||
#include "compiler/machine_mapping/partial_machine_mapping.dtg.h" | ||
#include "compiler/machine_mapping/include_unconstrained.dtg.h" | ||
#include "compiler/series_parallel/pcg_binary_sp_decomposition.dtg.h" | ||
#include "pcg/parallel_computation_graph/parallel_tensor_guid_t.dtg.h" | ||
|
||
namespace FlexFlow { | ||
|
||
PartialMachineMapping get_unconstrained_solution(); | ||
PartialMachineMapping get_unconstrained_solution_for_layers(std::unordered_set<parallel_layer_guid_t> const &); | ||
|
||
PartialMachineMapping get_sub_solution(MachineMappingContext const &ctx, | ||
PartialMachineMapping const &partial_solution, | ||
PCGBinarySPDecomposition const &sub_problem); | ||
std::unordered_set<parallel_layer_guid_t> get_all_layers(PartialMachineMapping const &, | ||
IncludeUnconstrained const &); | ||
|
||
PartialMachineMapping with_additional_tensor_machine_views(MachineMappingContext const &ctx, | ||
PartialMachineMapping const &partial_solution, | ||
std::unordered_map<parallel_tensor_guid_t, MachineView> const &additional); | ||
std::optional<MachineView> get_machine_view_for_layer(PartialMachineMapping const &, | ||
parallel_layer_guid_t const &); | ||
|
||
PartialMachineMapping with_additional_layer_machine_views(MachineMappingContext const &ctx, | ||
PartialMachineMapping const &partial_solution, | ||
PartialMachineMapping get_sub_solution(PartialMachineMapping const &partial_solution, | ||
PCGBinarySPDecomposition const &sub_problem); | ||
|
||
PartialMachineMapping with_additional_layer_machine_views(PartialMachineMapping const &partial_solution, | ||
std::unordered_map<parallel_layer_guid_t, MachineView> const &additional); | ||
|
||
MachineMapping require_complete_mapping(PartialMachineMapping const &); | ||
|
||
} // namespace FlexFlow | ||
|
||
#endif |
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 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
16 changes: 16 additions & 0 deletions
16
lib/compiler/src/compiler/cost_estimator/cost_estimator.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include "compiler/cost_estimator/cost_estimator.h" | ||
|
||
namespace FlexFlow { | ||
|
||
CostEstimator::CostEstimator(std::shared_ptr<ICostEstimator> implementation_ptr) | ||
: implementation_ptr(implementation_ptr) {} | ||
|
||
float CostEstimator::estimate_cost(OpCostEstimateKey const &k) const { | ||
return this->implementation_ptr->estimate_cost(k); | ||
} | ||
|
||
float CostEstimator::estimate_cost(TensorSetMovement const &m) const { | ||
return this->implementation_ptr->estimate_cost(m); | ||
} | ||
|
||
} // namespace FlexFlow |
37 changes: 0 additions & 37 deletions
37
lib/compiler/src/compiler/machine_mapping/estimate_cost_across_split.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
Oops, something went wrong.