Skip to content

Commit f2c8e7b

Browse files
author
Victor Li
committed
Merge branch 'substitution-builder' into master
2 parents 030bfd6 + 7928864 commit f2c8e7b

File tree

65 files changed

+2302
-519
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2302
-519
lines changed

bin/export-model-arch/src/export_model_arch.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "utils/cli/cli_parse.h"
1414
#include "utils/cli/cli_parse_result.h"
1515
#include "utils/cli/cli_spec.h"
16+
#include "utils/graph/open_dataflow_graph/algorithms/as_dot.h"
1617
#include "utils/graph/series_parallel/binary_sp_decomposition_tree/right_associative_binary_sp_tree_from_nary.h"
1718
#include "utils/graph/series_parallel/get_series_parallel_decomposition.h"
1819

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_APPLY_SUBSTITUTION_H
2+
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_APPLY_SUBSTITUTION_H
3+
4+
#include "substitutions/pcg_pattern_match.dtg.h"
5+
#include "substitutions/sub_parallel_computation_graph.dtg.h"
6+
#include "substitutions/substitution.dtg.h"
7+
8+
namespace FlexFlow {
9+
10+
/**
11+
* @brief Applies \p substitution to \p sub_pcg at the location specified by \p
12+
* match, returning the resulting SubParallelComputationGraph
13+
*
14+
* @param sub_pcg
15+
* @param substitution
16+
* @param match The location at which to apply substitution. This location in
17+
* sub_pcg should match substitution's PCGPattern. Likely created by running
18+
* FlexFlow::find_pattern_matches(PCGPattern const &,
19+
* SubParallelComputationGraph const &).
20+
* @return SubParallelComputationGraph A sub-PCG similar to sub_pcg, but with
21+
* the subgraph specified by match replaced with the result of the output
22+
* expression of substitution
23+
*/
24+
SubParallelComputationGraph
25+
apply_substitution(SubParallelComputationGraph const &sub_pcg,
26+
Substitution const &substitution,
27+
PCGPatternMatch const &match);
28+
29+
} // namespace FlexFlow
30+
31+
#endif

lib/substitutions/include/substitutions/substitution_internal/evaluate_substitution_output.h renamed to lib/substitutions/include/substitutions/apply_substitution/evaluate_substitution_output.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_SUBSTITUTION_INTERNAL_EVALUATE_SUBSTITUTION_OUTPUT_H
2-
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_SUBSTITUTION_INTERNAL_EVALUATE_SUBSTITUTION_OUTPUT_H
1+
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_EVALUATE_SUBSTITUTION_OUTPUT_H
2+
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_EVALUATE_SUBSTITUTION_OUTPUT_H
33

4+
#include "substitutions/apply_substitution/output_expr_to_result_sub_pcg_mapping.dtg.h"
45
#include "substitutions/pcg_pattern_match.dtg.h"
56
#include "substitutions/sub_parallel_computation_graph.dtg.h"
67
#include "substitutions/substitution.dtg.h"
7-
#include "substitutions/substitution_internal/output_expr_to_result_sub_pcg_mapping.dtg.h"
88
#include <utility>
99

1010
namespace FlexFlow {

lib/substitutions/include/substitutions/substitution_internal/output_expr_to_result_sub_pcg_mapping.h renamed to lib/substitutions/include/substitutions/apply_substitution/output_expr_to_result_sub_pcg_mapping.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_SUBSTITUTION_INTERNAL_OUTPUT_EXPR_TO_RESULT_SUB_PCG_MAPPING_H
2-
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_SUBSTITUTION_INTERNAL_OUTPUT_EXPR_TO_RESULT_SUB_PCG_MAPPING_H
1+
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_OUTPUT_EXPR_TO_RESULT_SUB_PCG_MAPPING_H
2+
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_OUTPUT_EXPR_TO_RESULT_SUB_PCG_MAPPING_H
33

44
#include "pcg/parallel_computation_graph/parallel_tensor_guid_t.dtg.h"
5+
#include "substitutions/apply_substitution/output_expr_to_result_sub_pcg_mapping.dtg.h"
56
#include "substitutions/output_graph/output_graph_expr.dtg.h"
67
#include "substitutions/output_graph/output_graph_expr_node_output.dtg.h"
78
#include "substitutions/sub_parallel_computation_graph.dtg.h"
8-
#include "substitutions/substitution_internal/output_expr_to_result_sub_pcg_mapping.dtg.h"
99

1010
namespace FlexFlow {
1111

lib/substitutions/include/substitutions/substitution_internal/output_expr_to_result_sub_pcg_mapping.struct.toml renamed to lib/substitutions/include/substitutions/apply_substitution/output_expr_to_result_sub_pcg_mapping.struct.toml

File renamed without changes.

lib/substitutions/include/substitutions/substitution_internal/perform_shape_inference.h renamed to lib/substitutions/include/substitutions/apply_substitution/perform_shape_inference.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_SUBSTITUTION_INTERNAL_PERFORM_SHAPE_INFERENCE_H
2-
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_SUBSTITUTION_INTERNAL_PERFORM_SHAPE_INFERENCE_H
1+
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_PERFORM_SHAPE_INFERENCE_H
2+
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_APPLY_SUBSTITUTION_PERFORM_SHAPE_INFERENCE_H
33

44
#include "op-attrs/parallel_tensor_shape.dtg.h"
55
#include "pcg/parallel_computation_graph/parallel_layer_attrs.dtg.h"

lib/substitutions/include/substitutions/constraint_type.enum.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ features = [
99

1010
[[values]]
1111
name = "EQUAL"
12+
13+
[[values]]
14+
name = "DIVISIBLE_BY"
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_OPERATOR_PATTERN_GET_ATTRIBUTE_MAP_H
2+
#define _FLEXFLOW_LIB_SUBSTITUTIONS_INCLUDE_SUBSTITUTIONS_OPERATOR_PATTERN_GET_ATTRIBUTE_MAP_H
3+
4+
#include "op-attrs/pcg_operator_attrs.dtg.h"
5+
#include "substitutions/operator_pattern/operator_attribute_key.dtg.h"
6+
#include "substitutions/operator_pattern/operator_attribute_value.dtg.h"
7+
8+
namespace FlexFlow {
9+
10+
std::unordered_map<OperatorAttributeKey, OperatorAttributeValue>
11+
get_attribute_map(PCGOperatorAttrs const &);
12+
13+
} // namespace FlexFlow
14+
15+
#endif

lib/substitutions/include/substitutions/operator_pattern/operator_attribute_constraint.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ OperatorAttributeConstraint op_type_equals_constraint(OperatorType);
99

1010
OperatorAttributeConstraint op_attr_key_equals(OperatorAttributeKey,
1111
OperatorAttributeValue const &);
12+
OperatorAttributeConstraint op_attr_key_divisible_by(OperatorAttributeKey,
13+
int denominator);
1214
OperatorAttributeConstraint
1315
make_equals_constraint(OperatorAttributeExpr const &,
1416
OperatorAttributeValue const &);

lib/substitutions/include/substitutions/operator_pattern/operator_attribute_key.enum.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ values = [
5656
{ name = "SHOULD_BROADCAST_RHS" },
5757
{ name = "DIM" },
5858
{ name = "AFFINE" },
59+
{ name = "ELEMENTWISE_AFFINE" },
5960
{ name = "MOMENTUM" },
6061
{ name = "REGULARIZER" },
6162
{ name = "SHAPE" },

0 commit comments

Comments
 (0)