-
Notifications
You must be signed in to change notification settings - Fork 225
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
25 changed files
with
471 additions
and
57 deletions.
There are no files selected for viewing
17 changes: 0 additions & 17 deletions
17
bin/export-model-arch/include/export_model_arch/json_sp_model_export.h
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
20 changes: 0 additions & 20 deletions
20
bin/export-model-arch/src/export_model_arch/json_sp_model_export.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
4 changes: 2 additions & 2 deletions
4
lib/compiler/include/compiler/series_parallel/pcg/pcg_binary_parallel_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
4 changes: 2 additions & 2 deletions
4
lib/compiler/include/compiler/series_parallel/pcg/pcg_binary_series_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
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
13 changes: 13 additions & 0 deletions
13
lib/compiler/src/compiler/series_parallel/pcg/pcg_binary_parallel_split.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,13 @@ | ||
#include "compiler/series_parallel/pcg/pcg_binary_parallel_split.h" | ||
#include "compiler/series_parallel/pcg/pcg_binary_sp_decomposition.h" | ||
|
||
namespace FlexFlow { | ||
|
||
BinaryParallelSplit binary_parallel_split_from_pcg_parallel_split(PCGBinaryParallelSplit const &pcg_split) { | ||
return BinaryParallelSplit{ | ||
binary_sp_tree_from_pcg_sp_tree(pcg_split.get_left_child()), | ||
binary_sp_tree_from_pcg_sp_tree(pcg_split.get_right_child()), | ||
}; | ||
} | ||
|
||
} // namespace FlexFlow |
13 changes: 13 additions & 0 deletions
13
lib/compiler/src/compiler/series_parallel/pcg/pcg_binary_series_split.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,13 @@ | ||
#include "compiler/series_parallel/pcg/pcg_binary_series_split.h" | ||
#include "compiler/series_parallel/pcg/pcg_binary_sp_decomposition.h" | ||
|
||
namespace FlexFlow { | ||
|
||
BinarySeriesSplit binary_series_split_from_pcg_series_split(PCGBinarySeriesSplit const &pcg_split) { | ||
return BinarySeriesSplit{ | ||
binary_sp_tree_from_pcg_sp_tree(pcg_split.get_left_child()), | ||
binary_sp_tree_from_pcg_sp_tree(pcg_split.get_right_child()), | ||
}; | ||
} | ||
|
||
} // 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
29 changes: 29 additions & 0 deletions
29
lib/pcg/include/pcg/file_format/v1/v1_binary_sp_decomposition/json.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,29 @@ | ||
#ifndef _FLEXFLOW_LIB_PCG_INCLUDE_PCG_FILE_FORMAT_V1_V1_BINARY_SP_DECOMPOSITION_JSON_H | ||
#define _FLEXFLOW_LIB_PCG_INCLUDE_PCG_FILE_FORMAT_V1_V1_BINARY_SP_DECOMPOSITION_JSON_H | ||
|
||
#include <nlohmann/json.hpp> | ||
#include "pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_sp_decomposition.dtg.h" | ||
|
||
namespace nlohmann { | ||
|
||
template <> | ||
struct adl_serializer<::FlexFlow::V1BinarySPDecomposition> { | ||
static ::FlexFlow::V1BinarySPDecomposition from_json(json const &); | ||
static void to_json(json &, ::FlexFlow::V1BinarySPDecomposition const &); | ||
}; | ||
|
||
template <> | ||
struct adl_serializer<::FlexFlow::V1BinarySeriesSplit> { | ||
static ::FlexFlow::V1BinarySeriesSplit from_json(json const &); | ||
static void to_json(json &, ::FlexFlow::V1BinarySeriesSplit const &); | ||
}; | ||
|
||
template <> | ||
struct adl_serializer<::FlexFlow::V1BinaryParallelSplit> { | ||
static ::FlexFlow::V1BinaryParallelSplit from_json(json const &); | ||
static void to_json(json &, ::FlexFlow::V1BinaryParallelSplit const &); | ||
}; | ||
|
||
} // namespace nlohmann | ||
|
||
#endif |
25 changes: 25 additions & 0 deletions
25
...nclude/pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_parallel_split.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,25 @@ | ||
namespace = "FlexFlow" | ||
name = "V1BinaryParallelSplit" | ||
features = [ | ||
"eq", | ||
"hash", | ||
"fmt", | ||
] | ||
|
||
fwd_decls = [ | ||
"struct V1BinarySPDecomposition" | ||
] | ||
|
||
post_includes = [ | ||
"pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_sp_decomposition.dtg.h", | ||
] | ||
|
||
[[fields]] | ||
name = "left_child" | ||
type = "::FlexFlow::V1BinarySPDecomposition" | ||
indirect = true | ||
|
||
[[fields]] | ||
name = "right_child" | ||
type = "::FlexFlow::V1BinarySPDecomposition" | ||
indirect = true |
25 changes: 25 additions & 0 deletions
25
.../include/pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_series_split.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,25 @@ | ||
namespace = "FlexFlow" | ||
name = "V1BinarySeriesSplit" | ||
features = [ | ||
"eq", | ||
"hash", | ||
"fmt", | ||
] | ||
|
||
fwd_decls = [ | ||
"struct V1BinarySPDecomposition" | ||
] | ||
|
||
post_includes = [ | ||
"pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_sp_decomposition.dtg.h", | ||
] | ||
|
||
[[fields]] | ||
name = "left_child" | ||
type = "::FlexFlow::V1BinarySPDecomposition" | ||
indirect = true | ||
|
||
[[fields]] | ||
name = "right_child" | ||
type = "::FlexFlow::V1BinarySPDecomposition" | ||
indirect = true |
24 changes: 24 additions & 0 deletions
24
...ude/pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_sp_decomposition.variant.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,24 @@ | ||
namespace = "FlexFlow" | ||
name = "V1BinarySPDecomposition" | ||
features = [ | ||
"eq", | ||
"hash", | ||
"fmt", | ||
] | ||
|
||
includes = [ | ||
"pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_series_split.dtg.h", | ||
"pcg/file_format/v1/v1_binary_sp_decomposition/v1_binary_parallel_split.dtg.h", | ||
] | ||
|
||
[[values]] | ||
type = "::FlexFlow::V1BinarySeriesSplit" | ||
key = "series" | ||
|
||
[[values]] | ||
type = "::FlexFlow::V1BinaryParallelSplit" | ||
key = "parallel" | ||
|
||
[[values]] | ||
type = "int" | ||
key = "leaf" |
75 changes: 75 additions & 0 deletions
75
lib/pcg/src/pcg/file_format/v1/v1_binary_sp_decomposition/json.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,75 @@ | ||
#include "pcg/file_format/v1/v1_binary_sp_decomposition/json.h" | ||
#include "utils/exception.h" | ||
#include "utils/overload.h" | ||
#include "utils/fmt/json.h" | ||
|
||
using namespace ::FlexFlow; | ||
|
||
namespace nlohmann { | ||
|
||
V1BinarySPDecomposition adl_serializer<V1BinarySPDecomposition>::from_json(json const &j) { | ||
std::string type = j.at("type").get<std::string>(); | ||
|
||
if (type == "series") { | ||
return V1BinarySPDecomposition{ | ||
j.get<V1BinarySeriesSplit>(), | ||
}; | ||
} else if (type == "parallel") { | ||
return V1BinarySPDecomposition{ | ||
j.get<V1BinaryParallelSplit>(), | ||
}; | ||
} else if (type == "leaf") { | ||
return V1BinarySPDecomposition{ | ||
j.at("value").get<int>(), | ||
}; | ||
} else { | ||
throw mk_runtime_error(fmt::format("Unknown json type value for LeafOnlyBinarySPDecompositionTree \"{}\" in json object: {}", type, j)); | ||
} | ||
} | ||
|
||
void adl_serializer<V1BinarySPDecomposition>::to_json(json &j, V1BinarySPDecomposition const &tree) { | ||
tree.visit<std::monostate>(overload { | ||
[&](V1BinarySeriesSplit const &split) { | ||
j = split; | ||
j["type"] = "series"; | ||
return std::monostate{}; | ||
}, | ||
[&](V1BinaryParallelSplit const &split) { | ||
j = split; | ||
j["type"] = "parallel"; | ||
return std::monostate{}; | ||
}, | ||
[&](int leaf) { | ||
j["value"] = leaf; | ||
j["type"] = "leaf"; | ||
return std::monostate{}; | ||
}, | ||
}); | ||
} | ||
|
||
V1BinarySeriesSplit adl_serializer<V1BinarySeriesSplit>::from_json(json const &j) { | ||
return V1BinarySeriesSplit{ | ||
/*lhs=*/j.at("left_child").get<V1BinarySPDecomposition>(), | ||
/*rhs=*/j.at("right_child").get<V1BinarySPDecomposition>(), | ||
}; | ||
} | ||
|
||
void adl_serializer<V1BinarySeriesSplit>::to_json(json &j, V1BinarySeriesSplit const &series) { | ||
j["left_child"] = series.get_left_child(); | ||
j["right_child"] = series.get_right_child(); | ||
} | ||
|
||
V1BinaryParallelSplit adl_serializer<V1BinaryParallelSplit>::from_json(json const &j) { | ||
return V1BinaryParallelSplit{ | ||
/*lhs=*/j.at("left_child").get<V1BinarySPDecomposition>(), | ||
/*rhs=*/j.at("right_child").get<V1BinarySPDecomposition>(), | ||
}; | ||
} | ||
|
||
void adl_serializer<V1BinaryParallelSplit>::to_json(json &j, V1BinaryParallelSplit const &series) { | ||
j["left_child"] = series.get_left_child(); | ||
j["right_child"] = series.get_right_child(); | ||
} | ||
|
||
|
||
} // namespace FlexFlow |
Oops, something went wrong.