Skip to content

Commit cdfe64e

Browse files
committed
Create and initialize Device object: the first PR for rewriting DML backend
1 parent 6b27f08 commit cdfe64e

File tree

14 files changed

+289
-3486
lines changed

14 files changed

+289
-3486
lines changed

src/webnn/native/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ source_set("sources") {
218218
"dml/ContextDML.h",
219219
"dml/GraphDML.cpp",
220220
"dml/GraphDML.h",
221-
"dml/DMLUtils.cpp",
222-
"dml/DMLUtils.h",
221+
"dml/DeviceDML.cpp",
222+
"dml/DeviceDML.h",
223223
]
224224
}
225225

src/webnn/native/dml/BackendDML.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2019 The Dawn Authors
2+
// Copyright 2022 The WebNN-native Authors
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -31,12 +32,6 @@ namespace webnn::native::dml {
3132
return new Context(options);
3233
}
3334

34-
#if defined(WEBNN_ENABLE_GPU_BUFFER)
35-
ContextBase* Backend::CreateContextWithGpuDevice(WGPUDevice device) {
36-
return new Context(device);
37-
}
38-
#endif
39-
4035
BackendConnection* Connect(InstanceBase* instance) {
4136
Backend* backend = new Backend(instance);
4237

src/webnn/native/dml/BackendDML.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright 2019 The Dawn Authors
2+
// Copyright 2022 The WebNN-native Authors
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
45
// you may not use this file except in compliance with the License.
@@ -12,18 +13,14 @@
1213
// See the License for the specific language governing permissions and
1314
// limitations under the License.
1415

15-
#ifndef WEBNN_NATIVE_DML_BACKENDDML_H_
16-
#define WEBNN_NATIVE_DML_BACKENDDML_H_
16+
#ifndef WEBNN_NATIVE_DML_BACKEND_DML_H_
17+
#define WEBNN_NATIVE_DML_BACKEND_DML_H_
1718

19+
#include <memory>
1820
#include "webnn/native/BackendConnection.h"
1921
#include "webnn/native/Context.h"
2022
#include "webnn/native/Error.h"
2123

22-
#if defined(WEBNN_ENABLE_GPU_BUFFER)
23-
# include <webgpu/webgpu.h>
24-
#endif
25-
#include <memory>
26-
2724
namespace webnn::native::dml {
2825

2926
class Backend : public BackendConnection {
@@ -33,13 +30,9 @@ namespace webnn::native::dml {
3330
MaybeError Initialize();
3431
ContextBase* CreateContext(ContextOptions const* options = nullptr) override;
3532

36-
#if defined(WEBNN_ENABLE_GPU_BUFFER)
37-
ContextBase* CreateContextWithGpuDevice(WGPUDevice device) override;
38-
#endif
39-
4033
private:
4134
};
4235

4336
} // namespace webnn::native::dml
4437

45-
#endif // WEBNN_NATIVE_DML_BACKENDDML_H_
38+
#endif // WEBNN_NATIVE_DML_BACKEND_DML_H_

src/webnn/native/dml/ContextDML.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The WebNN-native Authors
1+
// Copyright 2022 The WebNN-native Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -22,11 +22,6 @@ namespace webnn::native::dml {
2222
Context::Context(ContextOptions const* options) : ContextBase(options) {
2323
}
2424

25-
#if defined(WEBNN_ENABLE_GPU_BUFFER)
26-
Context::Context(WGPUDevice device) : ContextBase(device) {
27-
}
28-
#endif
29-
3025
GraphBase* Context::CreateGraphImpl() {
3126
return new Graph(this);
3227
}

src/webnn/native/dml/ContextDML.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2021 The WebNN-native Authors
1+
// Copyright 2022 The WebNN-native Authors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -18,18 +18,11 @@
1818
#include "webnn/native/Context.h"
1919
#include "webnn/native/Graph.h"
2020

21-
#if defined(WEBNN_ENABLE_GPU_BUFFER)
22-
# include <webgpu/webgpu.h>
23-
#endif
24-
2521
namespace webnn::native::dml {
2622

2723
class Context : public ContextBase {
2824
public:
2925
explicit Context(ContextOptions const* options);
30-
#if defined(WEBNN_ENABLE_GPU_BUFFER)
31-
explicit Context(WGPUDevice device);
32-
#endif
3326
~Context() override = default;
3427

3528
private:

src/webnn/native/dml/DMLUtils.cpp

Lines changed: 0 additions & 93 deletions
This file was deleted.

src/webnn/native/dml/DMLUtils.h

Lines changed: 0 additions & 175 deletions
This file was deleted.

0 commit comments

Comments
 (0)