refactoring: opt graph key gen
This commit is contained in:
parent
be9a8c73a0
commit
18aa6654d5
1 changed files with 5 additions and 9 deletions
|
@ -82,14 +82,10 @@ template <size_t _InputSize, size_t _OutputSize>
|
||||||
std::string get_graph_key(const std::string &op_name, const std::array<ggml_tensor *, _InputSize> &inputs,
|
std::string get_graph_key(const std::string &op_name, const std::array<ggml_tensor *, _InputSize> &inputs,
|
||||||
const std::array<ggml_tensor *, _OutputSize> &outputs) {
|
const std::array<ggml_tensor *, _OutputSize> &outputs) {
|
||||||
constexpr static const auto append_dimensions = [](std::string &key, const ggml_tensor *tensor) {
|
constexpr static const auto append_dimensions = [](std::string &key, const ggml_tensor *tensor) {
|
||||||
key += "_";
|
char buffer[256] = {};
|
||||||
key += std::to_string(tensor->ne[0]);
|
snprintf(buffer, sizeof(buffer), "_%ldx%ldx%ldx%ld", (long)tensor->ne[0], (long)tensor->ne[1],
|
||||||
key += "x";
|
(long)tensor->ne[2], (long)tensor->ne[3]);
|
||||||
key += std::to_string(tensor->ne[1]);
|
key += buffer;
|
||||||
key += "x";
|
|
||||||
key += std::to_string(tensor->ne[2]);
|
|
||||||
key += "x";
|
|
||||||
key += std::to_string(tensor->ne[3]);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string graph_key(op_name);
|
std::string graph_key(op_name);
|
||||||
|
@ -99,7 +95,7 @@ std::string get_graph_key(const std::string &op_name, const std::array<ggml_tens
|
||||||
for (auto &output : outputs) {
|
for (auto &output : outputs) {
|
||||||
append_dimensions(graph_key, output);
|
append_dimensions(graph_key, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
return graph_key;
|
return graph_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue