Skip to content

Commit d690303

Browse files
committed
Update usage of StringView
1 parent d1b0ffe commit d690303

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

ggml/src/ggml-webgpu/ggml-webgpu.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static void ggml_backend_webgpu_wait_on_submission(webgpu_context & ctx) {
236236
wgpu::CallbackMode::AllowSpontaneous,
237237
[](wgpu::QueueWorkDoneStatus status, wgpu::StringView message) {
238238
if (status != wgpu::QueueWorkDoneStatus::Success) {
239-
GGML_LOG_ERROR("ggml_webgpu: Failed to submit commands: %s\n", message.data);
239+
GGML_LOG_ERROR("ggml_webgpu: Failed to submit commands: %s\n", std::string(message).c_str());
240240
}
241241
}),
242242
UINT64_MAX);
@@ -276,7 +276,7 @@ static void ggml_backend_webgpu_submit_queue(webgpu_context & ctx) {
276276
wgpu::CallbackMode::AllowSpontaneous,
277277
[ctx, staged_param_bufs](wgpu::QueueWorkDoneStatus status, wgpu::StringView message) {
278278
if (status != wgpu::QueueWorkDoneStatus::Success) {
279-
GGML_LOG_ERROR("ggml_webgpu: Failed to submit commands: %s\n", message.data);
279+
GGML_LOG_ERROR("ggml_webgpu: Failed to submit commands: %s\n", std::string(message).c_str());
280280
}
281281
// Free the staged buffers
282282
ctx->param_buf_pool.free_bufs(staged_param_bufs);
@@ -292,7 +292,7 @@ static void ggml_backend_webgpu_submit_queue(webgpu_context & ctx) {
292292
wgpu::CallbackMode::AllowSpontaneous,
293293
[ctx, error_bufs](wgpu::MapAsyncStatus status, wgpu::StringView message) {
294294
if (status != wgpu::MapAsyncStatus::Success) {
295-
GGML_LOG_ERROR("ggml_webgpu: Failed to map error buffer: %s\n", message.data);
295+
GGML_LOG_ERROR("ggml_webgpu: Failed to map error buffer: %s\n", std::string(message).c_str());
296296
} else {
297297
const uint32_t * error_data = (const uint32_t *) error_bufs.host_buf.GetConstMappedRange();
298298
if (*error_data) {
@@ -1180,20 +1180,20 @@ static ggml_backend_dev_t ggml_backend_webgpu_reg_get_device(ggml_backend_reg_t
11801180
[](const wgpu::Device & device, wgpu::DeviceLostReason reason, wgpu::StringView message) {
11811181
GGML_UNUSED(device);
11821182
GGML_LOG_ERROR(
1183-
"ggml_webgpu: Device lost! Reason: %d, Message: %s\n", static_cast<int>(reason), message.data);
1183+
"ggml_webgpu: Device lost! Reason: %d, Message: %s\n", static_cast<int>(reason), std::string(message).c_str());
11841184
});
11851185
dev_desc.SetUncapturedErrorCallback(
11861186
[](const wgpu::Device & device, wgpu::ErrorType reason, wgpu::StringView message) {
11871187
GGML_UNUSED(device);
11881188
GGML_LOG_ERROR(
1189-
"ggml_webgpu: Device error! Reason: %d, Message: %s\n", static_cast<int>(reason), message.data);
1189+
"ggml_webgpu: Device error! Reason: %d, Message: %s\n", static_cast<int>(reason), std::string(message).c_str());
11901190
});
11911191
ctx->instance.WaitAny(ctx->adapter.RequestDevice(
11921192
&dev_desc,
11931193
wgpu::CallbackMode::AllowSpontaneous,
11941194
[ctx](wgpu::RequestDeviceStatus status, wgpu::Device device, wgpu::StringView message) {
11951195
if (status != wgpu::RequestDeviceStatus::Success) {
1196-
GGML_LOG_ERROR("ggml_webgpu: Failed to get a device: %s\n", message.data);
1196+
GGML_LOG_ERROR("ggml_webgpu: Failed to get a device: %s\n", std::string(message).c_str());
11971197
return;
11981198
}
11991199
ctx->device = std::move(device);
@@ -1238,17 +1238,17 @@ static ggml_backend_dev_t ggml_backend_webgpu_reg_get_device(ggml_backend_reg_t
12381238
static ggml_backend_webgpu_device_context device_ctx;
12391239
device_ctx.webgpu_ctx = ctx;
12401240
device_ctx.device_name = GGML_WEBGPU_NAME;
1241-
device_ctx.device_desc = std::string(info.description.data);
1241+
device_ctx.device_desc = info.description;
12421242

12431243
GGML_LOG_INFO(
12441244
"ggml_webgpu: adapter_info: vendor_id: %u | vendor: %s | architecture: %s | device_id: %u | name: %s | "
12451245
"device_desc: %s\n",
12461246
info.vendorID,
1247-
info.vendor.data,
1248-
info.architecture.data,
1247+
std::string(info.vendor).c_str(),
1248+
std::string(info.architecture).c_str(),
12491249
info.deviceID,
1250-
info.device.data,
1251-
info.description.data);
1250+
std::string(info.device).c_str(),
1251+
std::string(info.description).c_str());
12521252

12531253
// See GGML Backend Device Interface section
12541254
static ggml_backend_device device = {

0 commit comments

Comments
 (0)