Skip to content

Commit 7fcc351

Browse files
committed
Pass pcg tests
1 parent 7fe5b9c commit 7fcc351

File tree

37 files changed

+1027
-308
lines changed

37 files changed

+1027
-308
lines changed

lib/compiler/src/compiler/task_graph_simulator/simulate_task_graph_execution.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "utils/containers/set_of.h"
99
#include "utils/containers/sorted.h"
1010
#include "utils/exception.h"
11-
#include "utils/graph/digraph/algorithms.h"
11+
#include "utils/graph/digraph/algorithms/get_initial_nodes.h"
1212
#include "utils/graph/digraph/algorithms/get_predecessors.h"
1313
#include "utils/graph/digraph/algorithms/get_successors.h"
1414
#include "utils/graph/digraph/algorithms/is_acyclic.h"

lib/op-attrs/include/op-attrs/get_operator_task_space.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
#include "op-attrs/computation_graph_op_attrs.dtg.h"
55
#include "op-attrs/operator_task_space.dtg.h"
66
#include "op-attrs/parallel_tensor_dim_degrees.dtg.h"
7+
#include "op-attrs/tensor_slot_name.dtg.h"
78

89
namespace FlexFlow {
910

1011
OperatorTaskSpace
1112
get_operator_task_space(ComputationGraphOpAttrs const &attrs,
12-
std::vector<ParallelTensorDimDegrees> const &inputs_degrees);
13+
std::unordered_map<TensorSlotName, ParallelTensorDimDegrees> const &inputs_degrees);
1314

1415
} // namespace FlexFlow
1516

lib/op-attrs/src/op-attrs/get_operator_task_space.cc

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "op-attrs/get_operator_task_space.h"
22
#include "utils/containers/get_only.h"
3+
#include "utils/containers/require_only_key.h"
4+
#include "utils/containers/require_two_keys.h"
35
#include "utils/overload.h"
46
#include <libassert/assert.hpp>
57
#include "op-attrs/ops/element_unary.h"
@@ -13,37 +15,37 @@ namespace FlexFlow {
1315

1416
OperatorTaskSpace
1517
get_operator_task_space(ComputationGraphOpAttrs const &attrs,
16-
std::vector<ParallelTensorDimDegrees> const &inputs_degrees) {
18+
std::unordered_map<TensorSlotName, ParallelTensorDimDegrees> const &inputs_degrees) {
1719
return attrs.visit<
1820
OperatorTaskSpace
1921
>(overload {
2022
[&](ElementUnaryAttrs const &attrs) {
21-
ASSERT(inputs_degrees.size() == 1);
23+
ParallelTensorDimDegrees input = require_only_key(inputs_degrees, TensorSlotName::INPUT);
2224

23-
return get_operator_task_space(attrs, get_only(inputs_degrees));
25+
return get_operator_task_space(attrs, input);
2426
},
2527
[&](ElementBinaryAttrs const &attrs) {
26-
ASSERT(inputs_degrees.size() == 2);
28+
auto [lhs, rhs] = require_two_keys(inputs_degrees, TensorSlotName::LHS_INPUT, TensorSlotName::RHS_INPUT);
2729

2830
return get_operator_task_space(
2931
/*attrs=*/attrs,
30-
/*lhs_input_degrees=*/inputs_degrees.at(0),
31-
/*rhs_input_degrees=*/inputs_degrees.at(1));
32+
/*lhs_input_degrees=*/lhs,
33+
/*rhs_input_degrees=*/rhs);
3234
},
3335
[&](LinearAttrs const &attrs) {
34-
ASSERT(inputs_degrees.size() == 1);
36+
ParallelTensorDimDegrees input = require_only_key(inputs_degrees, TensorSlotName::INPUT);
3537

36-
return get_operator_task_space(attrs, get_only(inputs_degrees));
38+
return get_operator_task_space(attrs, input);
3739
},
3840
[&](InputAttrs const &attrs) {
3941
ASSERT(inputs_degrees.size() == 0);
4042

4143
return get_operator_task_space(attrs);
4244
},
4345
[&](TransposeAttrs const &attrs) {
44-
ASSERT(inputs_degrees.size() == 1);
46+
ParallelTensorDimDegrees input = require_only_key(inputs_degrees, TensorSlotName::INPUT);
4547

46-
return get_operator_task_space(attrs, get_only(inputs_degrees));
48+
return get_operator_task_space(attrs, input);
4749
},
4850
[&](WeightAttrs const &attrs) {
4951
ASSERT(inputs_degrees.size() == 0);

lib/op-attrs/src/op-attrs/shape_inference.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ std::unordered_map<TensorSlotName, TensorShape>
170170
};
171171
},
172172
[&](InputAttrs const &attrs) -> std::unordered_map<TensorSlotName, TensorShape> {
173-
TensorShape input = require_only_key(input_shapes, TensorSlotName::INPUT);
173+
ASSERT(input_shapes.size() == 0);
174174

175175
return {
176176
{
@@ -240,7 +240,7 @@ std::unordered_map<TensorSlotName, TensorShape>
240240
};
241241
},
242242
[&](WeightAttrs const &attrs) -> std::unordered_map<TensorSlotName, TensorShape> {
243-
TensorShape input = require_only_key(input_shapes, TensorSlotName::INPUT);
243+
ASSERT(input_shapes.size() == 0);
244244

245245
return {
246246
{
@@ -711,7 +711,7 @@ std::unordered_map<TensorSlotName, ParallelTensorShape>
711711
return {};
712712
},
713713
[&](WeightAttrs const &attrs) -> std::unordered_map<TensorSlotName, ParallelTensorShape> {
714-
require_only_key(input_shapes, TensorSlotName::INPUT);
714+
ASSERT(input_shapes.size() == 0);
715715

716716
return {};
717717
},

lib/pcg/include/pcg/parallel_computation_graph/parallel_computation_graph_builder.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,10 @@ struct ParallelComputationGraphBuilder {
143143
std::string const &name);
144144

145145
private:
146-
std::vector<parallel_tensor_guid_t>
146+
std::unordered_map<TensorSlotName, parallel_tensor_guid_t>
147147
add_layer(ParallelLayerAttrs const &layer,
148-
std::vector<parallel_tensor_guid_t> const &inputs,
149-
std::vector<InitializerAttrs> const &weight_initializers);
148+
std::unordered_map<TensorSlotName, parallel_tensor_guid_t> const &inputs,
149+
std::unordered_map<TensorSlotName, InitializerAttrs> const &weight_initializers);
150150

151151
parallel_tensor_guid_t
152152
add_weight(ParallelTensorShape const &weight_tensor_shape,

lib/pcg/include/pcg/parallel_computation_graph/parallel_computation_graph_edge.dtg.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ features = [
99
]
1010

1111
includes = [
12-
"utils/graph/dataflow_graph/dataflow_edge.dtg.h",
12+
"utils/graph/kwarg_dataflow_graph/kwarg_dataflow_edge.dtg.h",
13+
"op-attrs/tensor_slot_name.dtg.h",
1314
]
1415

1516
[[fields]]
1617
name = "raw_edge"
17-
type = "::FlexFlow::DataflowEdge"
18+
type = "::FlexFlow::KwargDataflowEdge<::FlexFlow::TensorSlotName>"

lib/pcg/include/pcg/parallel_computation_graph/parallel_computation_graph_edge.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ parallel_tensor_guid_t
1111
get_parallel_tensor(ParallelComputationGraphEdge const &);
1212
parallel_layer_guid_t get_src_layer(ParallelComputationGraphEdge const &);
1313
parallel_layer_guid_t get_dst_layer(ParallelComputationGraphEdge const &);
14-
nonnegative_int get_src_layer_output_idx(ParallelComputationGraphEdge const &);
15-
nonnegative_int get_dst_layer_input_idx(ParallelComputationGraphEdge const &);
14+
TensorSlotName get_src_layer_output_slot_name(ParallelComputationGraphEdge const &);
15+
TensorSlotName get_dst_layer_input_slot_name(ParallelComputationGraphEdge const &);
1616

1717
} // namespace FlexFlow
1818

lib/pcg/include/pcg/parallel_computation_graph/parallel_layer_added_result.dtg.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ type = "struct"
44

55
features = [
66
"eq",
7-
"ord",
87
"fmt",
98
]
109

lib/pcg/include/pcg/parallel_computation_graph/parallel_tensor_guid_t.dtg.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ features = [
99
]
1010

1111
includes = [
12-
"utils/graph/dataflow_graph/dataflow_output.dtg.h",
12+
"utils/graph/kwarg_dataflow_graph/kwarg_dataflow_output.dtg.h",
1313
"op-attrs/tensor_slot_name.dtg.h",
1414
]
1515

lib/pcg/src/pcg/computation_graph.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static std::unordered_map<TensorSlotName, tensor_guid_t>
205205
std::unordered_map<TensorSlotName, IncomingTensorRole> incoming_slot_roles =
206206
get_incoming_tensor_roles(attrs);
207207

208-
assert(incoming_tensors.size() == incoming_slot_roles.size());
208+
ASSERT(incoming_tensors.size() == incoming_slot_roles.size());
209209

210210
std::unordered_set<TensorSlotName> slots_with_desired_role =
211211
keys(filter_values(incoming_slot_roles,

0 commit comments

Comments
 (0)