This is an automated email from the ASF dual-hosted git repository.
spectrometerHBH pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new f42a279b56 [REFACTOR] Move source_utils.h into runtime/opencl (#19456)
f42a279b56 is described below
commit f42a279b5670a2f8aaf55f42d428839a2b382516
Author: Tianqi Chen <[email protected]>
AuthorDate: Mon Apr 27 16:38:42 2026 -0400
[REFACTOR] Move source_utils.h into runtime/opencl (#19456)
Move source_utils.h header into runtime/opencl directory with
SplitKernels inlined. Removes the standalone source_utils.cc file and
updates 2 include paths to reflect the new location.
## Test plan
- [x] Compilation of modified translation units verified
- [ ] Full CI suite validates broader impacts
---
src/runtime/opencl/opencl_module.cc | 2 +-
src/runtime/opencl/opencl_module_spirv.cc | 2 +-
.../{source_utils.cc => opencl/source_utils.h} | 23 ++++++++---
src/runtime/source_utils.h | 44 ----------------------
4 files changed, 20 insertions(+), 51 deletions(-)
diff --git a/src/runtime/opencl/opencl_module.cc
b/src/runtime/opencl/opencl_module.cc
index c5afaeba7d..c8ccbfa09f 100644
--- a/src/runtime/opencl/opencl_module.cc
+++ b/src/runtime/opencl/opencl_module.cc
@@ -30,8 +30,8 @@
#include <vector>
#include "../../support/bytes_io.h"
-#include "../source_utils.h"
#include "opencl_common.h"
+#include "source_utils.h"
namespace tvm {
namespace runtime {
diff --git a/src/runtime/opencl/opencl_module_spirv.cc
b/src/runtime/opencl/opencl_module_spirv.cc
index 12b6df9aa1..67e7b1c1d5 100644
--- a/src/runtime/opencl/opencl_module_spirv.cc
+++ b/src/runtime/opencl/opencl_module_spirv.cc
@@ -25,10 +25,10 @@
#include <vector>
#include "../../support/bytes_io.h"
-#include "../source_utils.h"
#include "../spirv/spirv_shader.h"
#include "opencl_common.h"
#include "opencl_module.h"
+#include "source_utils.h"
namespace tvm {
namespace runtime {
diff --git a/src/runtime/source_utils.cc b/src/runtime/opencl/source_utils.h
similarity index 69%
rename from src/runtime/source_utils.cc
rename to src/runtime/opencl/source_utils.h
index e1cf94e52e..9f17d67012 100644
--- a/src/runtime/source_utils.cc
+++ b/src/runtime/opencl/source_utils.h
@@ -18,15 +18,26 @@
*/
/*!
- * \file source_utils.cc
+ * \file source_utils.h
+ * \brief Minimum source manipulation utils for the OpenCL runtime.
*/
-#include "source_utils.h"
+
+#ifndef TVM_RUNTIME_OPENCL_SOURCE_UTILS_H_
+#define TVM_RUNTIME_OPENCL_SOURCE_UTILS_H_
+
+#include <string>
+#include <unordered_map>
namespace tvm {
namespace runtime {
-
-std::unordered_map<std::string, std::string> SplitKernels(std::string source,
- std::string
delimiter) {
+/*!
+ * \brief Split the source file on separate kernels by specified delimiter.
+ * \param source The source code of the kernels.
+ * \param delimiter The delimiter which is using for splitting kernels.
+ * \return Mapping from primitive name to kernel source
+ */
+inline std::unordered_map<std::string, std::string> SplitKernels(
+ const std::string& source, const std::string& delimiter = "// Function: ")
{
std::unordered_map<std::string, std::string> split_kernels;
if (source.size()) {
size_t begin = source.find(delimiter);
@@ -47,3 +58,5 @@ std::unordered_map<std::string, std::string>
SplitKernels(std::string source,
}
} // namespace runtime
} // namespace tvm
+
+#endif // TVM_RUNTIME_OPENCL_SOURCE_UTILS_H_
diff --git a/src/runtime/source_utils.h b/src/runtime/source_utils.h
deleted file mode 100644
index 5476585b94..0000000000
--- a/src/runtime/source_utils.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * 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 source_utils.h
- * \brief Minimum source manipulation utils for runtime.
- */
-
-#ifndef TVM_RUNTIME_SOURCE_UTILS_H_
-#define TVM_RUNTIME_SOURCE_UTILS_H_
-
-#include <string>
-#include <unordered_map>
-
-namespace tvm {
-namespace runtime {
-/*!
- * \brief Split the source file on separate kernels by specified delimiter.
- * \param source The source code of the kernels.
- * \param delimiter The delimiter which is using for splitting kernels.
- * \return Mapping from primitive name to kernel source
- */
-std::unordered_map<std::string, std::string> SplitKernels(std::string source,
- std::string
delimiter = "// Function: ");
-} // namespace runtime
-} // namespace tvm
-
-#endif // TVM_RUNTIME_SOURCE_UTILS_H_