Skip to content

Commit 7ee59ed

Browse files
committed
[ET-VK] Fix OSS build by replace starts_with usage
`starts_with` is a C++20 feature but OSS is on C++17. https://en.cppreference.com/w/cpp/string/basic_string/starts_with Differential Revision: [D64076249](https://our.internmc.facebook.com/intern/diff/D64076249/) ghstack-source-id: 246947068 Pull Request resolved: #6028
1 parent b66c255 commit 7ee59ed

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

backends/vulkan/runtime/graph/ops/impl/Staging.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ void add_staging_to_tensor_node(
5151
{}));
5252
}
5353

54+
const std::string kBitw8PrefixStr = "bitw8_image_to_nchw_nobitw8buffer";
55+
56+
bool is_bitw8_shader(const vkapi::ShaderInfo& shader) {
57+
const auto size = shader.kernel_name.size();
58+
const std::string& shader_prefix_str = shader.kernel_name.substr(0, size);
59+
return shader_prefix_str == kBitw8PrefixStr;
60+
}
61+
5462
void add_tensor_to_staging_node(
5563
ComputeGraph& graph,
5664
const ValueRef in_tensor,
@@ -80,7 +88,7 @@ void add_tensor_to_staging_node(
8088
// output buffer. Therefore, the global work group size for this shader will
8189
// be the number of elements in the output buffer divided by 4, as opposed to
8290
// the extents of the input texture.
83-
if (shader.kernel_name.starts_with("bitw8_image_to_nchw_nobitw8buffer")) {
91+
if (is_bitw8_shader(shader)) {
8492
uint32_t buffer_len = graph.get_staging(out_staging)->numel() / 4;
8593
global_wg_size = {buffer_len, 1, 1};
8694
ubos.append({graph.numel_ubo(in_tensor)});

0 commit comments

Comments
 (0)