Skip to content

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
lockshaw committed Feb 9, 2025
1 parent 759beb3 commit 6ecf898
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ OperatorType get_op_type(ParallelLayerAttrs const &a) {

ParallelLayerAttrs
parallel_layer_attrs_from_layer_attrs(LayerAttrs const &layer_attrs) {
return ParallelLayerAttrs{pcg_op_attrs_from_compgraph_op_attrs(layer_attrs.attrs),
layer_attrs.name};
return ParallelLayerAttrs{
pcg_op_attrs_from_compgraph_op_attrs(layer_attrs.attrs),
layer_attrs.name};
}

} // namespace FlexFlow
3 changes: 2 additions & 1 deletion lib/pcg/src/pcg/pcg_from_computation_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

namespace FlexFlow {

ParallelComputationGraph pcg_from_computation_graph(ComputationGraph const &cg) {
ParallelComputationGraph
pcg_from_computation_graph(ComputationGraph const &cg) {
auto layer_map = [&](Node const &_, LayerAttrs const &layer) {
return parallel_layer_attrs_from_layer_attrs(layer);
};
Expand Down
38 changes: 23 additions & 15 deletions lib/pcg/test/src/pcg/pcg_from_computation_graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ TEST_SUITE(FF_TEST_SUITE) {

TensorShape input_shape = TensorShape{
TensorDims{FFOrdered<nonnegative_int>{10_n, 12_n}}, DataType::FLOAT};
TensorAttrs input_attrs =
TensorAttrs{input_shape, /*sync_type=*/std::nullopt, /*initializer=*/std::nullopt, CreateGrad::YES};
TensorAttrs input_attrs = TensorAttrs{input_shape,
/*sync_type=*/std::nullopt,
/*initializer=*/std::nullopt,
CreateGrad::YES};
LayerAttrs input_layer_attrs =
LayerAttrs{ComputationGraphOpAttrs{InputAttrs{}}, input_name};
LayerAddedResult input_added =
add_layer(cg, input_layer_attrs, /*inputs=*/{}, /*outputs=*/{input_attrs});
LayerAddedResult input_added = add_layer(
cg, input_layer_attrs, /*inputs=*/{}, /*outputs=*/{input_attrs});
tensor_guid_t input_tensor = get_only(input_added.outputs);

LinearAttrs linear_attrs = LinearAttrs{/*out_channels=*/8_n,
Expand All @@ -34,13 +36,15 @@ TEST_SUITE(FF_TEST_SUITE) {
TensorDims{FFOrdered<nonnegative_int>{10_n, 8_n}}, DataType::FLOAT};
LayerAttrs dense_layer_attrs =
LayerAttrs{ComputationGraphOpAttrs{linear_attrs}, dense_name};
LayerAddedResult dense_added = add_layer(cg,
/*attrs=*/dense_layer_attrs,
/*inputs=*/{input_tensor},
/*outputs=*/{TensorAttrs{dense_output_shape,
/*sync_type=*/std::nullopt,
/*initializer=*/std::nullopt,
CreateGrad::YES}});
LayerAddedResult dense_added =
add_layer(cg,
/*attrs=*/dense_layer_attrs,
/*inputs=*/{input_tensor},
/*outputs=*/
{TensorAttrs{dense_output_shape,
/*sync_type=*/std::nullopt,
/*initializer=*/std::nullopt,
CreateGrad::YES}});
tensor_guid_t dense_output = get_only(dense_added.outputs);

ElementUnaryAttrs relu_attrs =
Expand All @@ -50,7 +54,8 @@ TEST_SUITE(FF_TEST_SUITE) {
add_layer(cg,
/*attrs=*/relu_layer_attrs,
/*inputs=*/{dense_output},
/*outputs=*/{TensorAttrs{dense_output_shape,
/*outputs=*/
{TensorAttrs{dense_output_shape,
/*sync_type=*/std::nullopt,
/*initializer=*/std::nullopt,
CreateGrad::YES}});
Expand All @@ -75,7 +80,8 @@ TEST_SUITE(FF_TEST_SUITE) {
pcg,
/*attrs=*/input_layer_attrs,
/*inputs=*/{},
/*outputs=*/{ParallelTensorAttrs{
/*outputs=*/
{ParallelTensorAttrs{
input_shape, std::nullopt, std::nullopt, CreateGrad::YES}});

parallel_tensor_guid_t input_tensor = get_only(input_added.outputs);
Expand All @@ -100,7 +106,8 @@ TEST_SUITE(FF_TEST_SUITE) {
add_parallel_layer(pcg,
/*attrs=*/dense_layer_attrs,
/*inputs=*/{input_tensor},
/*outputs=*/{ParallelTensorAttrs{dense_output_shape,
/*outputs=*/
{ParallelTensorAttrs{dense_output_shape,
/*sync_type=*/std::nullopt,
/*initializer=*/std::nullopt,
CreateGrad::YES}});
Expand All @@ -115,7 +122,8 @@ TEST_SUITE(FF_TEST_SUITE) {
add_parallel_layer(pcg,
/*attrs=*/relu_layer_attrs,
/*inputs=*/{dense_output},
/*outputs=*/{ParallelTensorAttrs{dense_output_shape,
/*outputs=*/
{ParallelTensorAttrs{dense_output_shape,
/*sync_type=*/std::nullopt,
/*initializer=*/std::nullopt,
CreateGrad::YES}});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#ifndef _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_LABELLED_DATAFLOW_GRAPH_ALGORITHMS_REWRITE_VALUE_LABELS_H
#define _FLEXFLOW_LIB_UTILS_INCLUDE_UTILS_GRAPH_LABELLED_DATAFLOW_GRAPH_ALGORITHMS_REWRITE_VALUE_LABELS_H

#include "utils/graph/labelled_open_dataflow_graph/algorithms/rewrite_value_labels.h"
#include "utils/graph/labelled_dataflow_graph/algorithms/view_as_labelled_open_dataflow_graph.h"
#include "utils/graph/labelled_open_dataflow_graph/algorithms/rewrite_value_labels.h"

namespace FlexFlow {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using ValueLabel = value_type<1>;
using NewNodeLabel = value_type<2>;
using F = std::function<NewNodeLabel(Node const &, NodeLabel const &)>;

template
LabelledDataflowGraphView<NewNodeLabel, ValueLabel> rewrite_node_labels(
LabelledDataflowGraphView<NodeLabel, ValueLabel> const &, F);
template LabelledDataflowGraphView<NewNodeLabel, ValueLabel>
rewrite_node_labels(
LabelledDataflowGraphView<NodeLabel, ValueLabel> const &, F);

} // namespace FlexFlow
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ namespace FlexFlow {
using NodeLabel = value_type<0>;
using ValueLabel = value_type<1>;
using NewValueLabel = value_type<2>;
using F = std::function<NewValueLabel(OpenDataflowValue const &, ValueLabel const &)>;
using F =
std::function<NewValueLabel(OpenDataflowValue const &, ValueLabel const &)>;

template
LabelledDataflowGraphView<NodeLabel, NewValueLabel> rewrite_value_labels(
LabelledDataflowGraphView<NodeLabel, ValueLabel> const &, F);
template LabelledDataflowGraphView<NodeLabel, NewValueLabel>
rewrite_value_labels(
LabelledDataflowGraphView<NodeLabel, ValueLabel> const &, F);

} // namespace FlexFlow
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct F {
}
};

template
LabelledOpenDataflowGraphView<NewNodeLabel, NewValueLabel> rewrite_labels(
LabelledOpenDataflowGraphView<NodeLabel, ValueLabel> const &, F);
template LabelledOpenDataflowGraphView<NewNodeLabel, NewValueLabel>
rewrite_labels(LabelledOpenDataflowGraphView<NodeLabel, ValueLabel> const &,
F);

} // namespace FlexFlow
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using ValueLabel = value_type<1>;
using NewNodeLabel = value_type<2>;
using F = std::function<NewNodeLabel(Node const &, NodeLabel const &)>;

template
LabelledOpenDataflowGraphView<NewNodeLabel, ValueLabel> rewrite_node_labels(
LabelledOpenDataflowGraphView<NodeLabel, ValueLabel> const &, F);
template LabelledOpenDataflowGraphView<NewNodeLabel, ValueLabel>
rewrite_node_labels(
LabelledOpenDataflowGraphView<NodeLabel, ValueLabel> const &, F);

} // namespace FlexFlow
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ namespace FlexFlow {
using NodeLabel = value_type<0>;
using ValueLabel = value_type<1>;
using NewValueLabel = value_type<2>;
using F = std::function<NewValueLabel(OpenDataflowValue const &, ValueLabel const &)>;
using F =
std::function<NewValueLabel(OpenDataflowValue const &, ValueLabel const &)>;

template
LabelledOpenDataflowGraphView<NodeLabel, NewValueLabel> rewrite_value_labels(
LabelledOpenDataflowGraphView<NodeLabel, ValueLabel> const &, F);
template LabelledOpenDataflowGraphView<NodeLabel, NewValueLabel>
rewrite_value_labels(
LabelledOpenDataflowGraphView<NodeLabel, ValueLabel> const &, F);

} // namespace FlexFlow

0 comments on commit 6ecf898

Please sign in to comment.