You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/09/28 10:38:38 UTC

[GitHub] [tvm] Mousius commented on a change in pull request #9088: Introduce centralised name transformation functions

Mousius commented on a change in pull request #9088:
URL: https://github.com/apache/tvm/pull/9088#discussion_r717446902



##########
File path: src/relay/backend/name_transforms.h
##########
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file relay/backend/name_transforms.h
+ * \brief Transformations which are applied on names to generate appropriately named compiler
+ * artifacts
+ *
+ * Example:
+ * ToCFunctionStyle(PrefixName(CombineNames({"Device", "target", "Invoke"})))
+ * // TVMDeviceTargetInvoke
+ *
+ * ToCFunctionStyle(PrefixGeneratedName(CombineNames({"model", "Run"})))
+ * // TVMGenModelRun
+ *
+ * ToCVariableStyle(PrefixName(CombineNames({"Device", "target", "t"})))
+ * // tvm_device_target_t
+ *
+ * ToCVariableStyle(PrefixGeneratedName(CombineNames({"model", "Devices"})))
+ * // tvmgen_model_devices
+ *
+ */
+
+#include <tvm/runtime/container/array.h>
+#include <tvm/runtime/container/string.h>
+#include <tvm/runtime/logging.h>
+
+#include <algorithm>
+#include <iostream>
+#include <string>
+
+#ifndef TVM_RELAY_BACKEND_NAME_TRANSFORMS_H_
+#define TVM_RELAY_BACKEND_NAME_TRANSFORMS_H_
+
+namespace tvm {
+namespace relay {
+namespace backend {
+
+/*!
+ * \brief Transform a name to the C variable style assuming it is
+ * appropriately constructed using the prefixing functions
+ * \param original_name Original name
+ * \return Transformed function in the C function style
+ */
+std::string ToCFunctionStyle(const std::string& original_name);

Review comment:
       I'd prefer to reference these from the business case it serves, in this case we're generating code to fit the C runtime style guide rather than generic functions for styling. If you feel strongly I can change them?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org