From 32a081fd456bc6689641146619db7452007b81f8 Mon Sep 17 00:00:00 2001 From: Andrew Tulloch Date: Wed, 20 Mar 2019 03:22:47 -0700 Subject: [PATCH] Truncate function name --- src/relay/backend/compile_engine.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/relay/backend/compile_engine.cc b/src/relay/backend/compile_engine.cc index 73bae053cc82..722172bd617d 100644 --- a/src/relay/backend/compile_engine.cc +++ b/src/relay/backend/compile_engine.cc @@ -80,7 +80,16 @@ class ScheduleGetter : } readable_name_stream_ << "fused"; cache_node->outputs = this->VisitExpr(prim_func->body); - cache_node->func_name = readable_name_stream_.str(); + auto candidate_name = readable_name_stream_.str(); + constexpr static size_t kMaxFuncNameLength = 80; + if (candidate_name.size() > kMaxFuncNameLength) { + std::stringstream truncated_name; + truncated_name << candidate_name.substr(0, kMaxFuncNameLength); + truncated_name << "_" << std::hash{}(candidate_name) << "_"; + candidate_name = truncated_name.str(); + } + cache_node->func_name = candidate_name; + CachedFunc cfunc(cache_node); CHECK(master_op_.defined()); // Fusion over tupled results may leave identity relationships