Skip to content

Commit

Permalink
Create and initialize Device object: the first PR for rewriting DML b…
Browse files Browse the repository at this point in the history
…ackend
  • Loading branch information
mingmingtasd committed Aug 3, 2022
1 parent 6b27f08 commit cdfe64e
Show file tree
Hide file tree
Showing 14 changed files with 289 additions and 3,486 deletions.
4 changes: 2 additions & 2 deletions src/webnn/native/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ source_set("sources") {
"dml/ContextDML.h",
"dml/GraphDML.cpp",
"dml/GraphDML.h",
"dml/DMLUtils.cpp",
"dml/DMLUtils.h",
"dml/DeviceDML.cpp",
"dml/DeviceDML.h",
]
}

Expand Down
7 changes: 1 addition & 6 deletions src/webnn/native/dml/BackendDML.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2019 The Dawn Authors
// Copyright 2022 The WebNN-native Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,12 +32,6 @@ namespace webnn::native::dml {
return new Context(options);
}

#if defined(WEBNN_ENABLE_GPU_BUFFER)
ContextBase* Backend::CreateContextWithGpuDevice(WGPUDevice device) {
return new Context(device);
}
#endif

BackendConnection* Connect(InstanceBase* instance) {
Backend* backend = new Backend(instance);

Expand Down
17 changes: 5 additions & 12 deletions src/webnn/native/dml/BackendDML.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2019 The Dawn Authors
// Copyright 2022 The WebNN-native Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -12,18 +13,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef WEBNN_NATIVE_DML_BACKENDDML_H_
#define WEBNN_NATIVE_DML_BACKENDDML_H_
#ifndef WEBNN_NATIVE_DML_BACKEND_DML_H_
#define WEBNN_NATIVE_DML_BACKEND_DML_H_

#include <memory>
#include "webnn/native/BackendConnection.h"
#include "webnn/native/Context.h"
#include "webnn/native/Error.h"

#if defined(WEBNN_ENABLE_GPU_BUFFER)
# include <webgpu/webgpu.h>
#endif
#include <memory>

namespace webnn::native::dml {

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

#if defined(WEBNN_ENABLE_GPU_BUFFER)
ContextBase* CreateContextWithGpuDevice(WGPUDevice device) override;
#endif

private:
};

} // namespace webnn::native::dml

#endif // WEBNN_NATIVE_DML_BACKENDDML_H_
#endif // WEBNN_NATIVE_DML_BACKEND_DML_H_
7 changes: 1 addition & 6 deletions src/webnn/native/dml/ContextDML.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The WebNN-native Authors
// Copyright 2022 The WebNN-native Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -22,11 +22,6 @@ namespace webnn::native::dml {
Context::Context(ContextOptions const* options) : ContextBase(options) {
}

#if defined(WEBNN_ENABLE_GPU_BUFFER)
Context::Context(WGPUDevice device) : ContextBase(device) {
}
#endif

GraphBase* Context::CreateGraphImpl() {
return new Graph(this);
}
Expand Down
9 changes: 1 addition & 8 deletions src/webnn/native/dml/ContextDML.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 The WebNN-native Authors
// Copyright 2022 The WebNN-native Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,18 +18,11 @@
#include "webnn/native/Context.h"
#include "webnn/native/Graph.h"

#if defined(WEBNN_ENABLE_GPU_BUFFER)
# include <webgpu/webgpu.h>
#endif

namespace webnn::native::dml {

class Context : public ContextBase {
public:
explicit Context(ContextOptions const* options);
#if defined(WEBNN_ENABLE_GPU_BUFFER)
explicit Context(WGPUDevice device);
#endif
~Context() override = default;

private:
Expand Down
93 changes: 0 additions & 93 deletions src/webnn/native/dml/DMLUtils.cpp

This file was deleted.

175 changes: 0 additions & 175 deletions src/webnn/native/dml/DMLUtils.h

This file was deleted.

Loading

0 comments on commit cdfe64e

Please sign in to comment.