Skip to content

Commit ac68e33

Browse files
committed
sync with dawn
1 parent ff55f0b commit ac68e33

37 files changed

+422
-143
lines changed

DEPS

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ gclient_gn_args = [
88

99
vars = {
1010
'chromium_git': 'https://chromium.googlesource.com',
11-
'dawn_git': 'https://github.com/fujunwei',
11+
# 'dawn_git': 'https://github.com/fujunwei',
12+
'dawn_git': 'https://github.com/lisa0314',
1213
'github_git': 'https://github.com',
1314

1415
'dawn_standalone': True,
@@ -45,9 +46,15 @@ deps = {
4546

4647
# Dependencies required for code generator and infrastructure code.
4748
'third_party/dawn': {
48-
'url': '{dawn_git}/dawn.git@f4c84e239bf8b5b2c4733d68ca38e1e9049fd895'
49+
# 'url': '{dawn_git}/dawn.git@f4c84e239bf8b5b2c4733d68ca38e1e9049fd895'
50+
'url': '{dawn_git}/dawn.git@671e50d30c4e8e912fbc39865aa9fac9955101fa'
4951
},
5052

53+
'third_party/abseil-cpp': {
54+
'url': '{chromium_git}/chromium/src/third_party/abseil-cpp@789af048b388657987c59d4da406859034fe310f',
55+
'condition': 'dawn_standalone',
56+
},
57+
5158
# Dependencies required for backends.
5259
'third_party/DirectML': {
5360
'url': '{github_git}/microsoft/DirectML.git@c3f16a701beeeefc9ce5b67c71b554a6903c0f67',
@@ -136,7 +143,7 @@ deps = {
136143

137144
# Jinja2 and MarkupSafe for the code generator
138145
'third_party/jinja2': {
139-
'url': '{chromium_git}/chromium/src/third_party/jinja2@a82a4944a7f2496639f34a89c9923be5908b80aa',
146+
'url': '{chromium_git}/chromium/src/third_party/jinja2@ee69aa00ee8536f61db6a451f3858745cf587de6',
140147
'condition': 'dawn_standalone',
141148
},
142149
'third_party/markupsafe': {

examples/MobileNetV2/Main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ int main(int argc, const char* argv[]) {
3939
}
4040
},
4141
&mobilevetv2);
42+
4243
wnn::GraphBuilder builder = utils::CreateGraphBuilder(context);
43-
wnn::Operand output = mobilevetv2.mLayout == "nchw" ? mobilevetv2.LoadNCHW(builder)
44-
: mobilevetv2.LoadNHWC(builder);
44+
wnn::Operand output = mobilevetv2.mLayout == "nchw" ? mobilevetv2.LoadNchw(builder)
45+
: mobilevetv2.LoadNhwc(builder);
4546

4647
// Build the graph.
4748
const std::chrono::time_point<std::chrono::high_resolution_clock> compilationStartTime =

examples/SampleUtils.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ wnn::Context CreateCppContext(wnn::ContextOptions const* options) {
6262
// Choose whether to use the backend procs and context directly, or set up the wire.
6363
WNNContext context = nullptr;
6464
WebnnProcTable procs;
65+
WNNInstance wnnInstance;
66+
6567

6668
switch (cmdBufType) {
6769
case CmdBufType::None:
6870
procs = backendProcs;
6971
context = backendContext;
70-
instance = wnn::Instance(nativeInstance->Get());
72+
wnnInstance = nativeInstance->Get();
7173
break;
7274

7375
case CmdBufType::Terrible: {
@@ -100,14 +102,16 @@ wnn::Context CreateCppContext(wnn::ContextOptions const* options) {
100102
instanceReservation.generation);
101103
// Keep the reference instread of using Acquire.
102104
// TODO:: make the instance in the client as singleton object.
103-
instance = wnn::Instance(instanceReservation.instance);
105+
wnnInstance = instanceReservation.instance;
106+
break;
104107
#endif
105108
}
106109
default:
107110
dawn::ErrorLog() << "Invaild CmdBufType";
108111
DAWN_ASSERT(0);
109112
}
110113
webnnProcSetProcs(&procs);
114+
instance = wnn::Instance(wnnInstance);
111115
return instance.CreateContext(options);
112116
;
113117
}

generator/webnn_generator.gni

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ template("webnn_generator") {
9494
deps = [ "${dawn_root}/generator:remove_stale_autogen_files" ]
9595

9696
template_dir = "${dawn_root}/generator/templates"
97+
9798
}
9899
}
99100

@@ -121,5 +122,6 @@ template("webnn_json_generator") {
121122
]
122123

123124
forward_variables_from(invoker, "*", [ "target" ])
125+
124126
}
125127
}

include/webnn/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ config("public") {
6666
include_dirs = [
6767
"${target_gen_dir}/../../include",
6868
"${webnn_root}/include",
69+
"${dawn_root}/include",
70+
"${dawn_gen_root}/include",
6971
]
7072

7173
if (build_with_chromium) {

include/webnn/wire/Wire.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ namespace webnn::wire {
2626

2727
class WEBNN_WIRE_EXPORT CommandSerializer {
2828
public:
29-
virtual ~CommandSerializer() = default;
29+
CommandSerializer();
30+
virtual ~CommandSerializer();
31+
CommandSerializer(const CommandSerializer& rhs) = delete;
32+
CommandSerializer& operator=(const CommandSerializer& rhs) = delete;
3033

3134
// Get space for serializing commands.
3235
// GetCmdSpace will never be called with a value larger than
@@ -35,6 +38,7 @@ namespace webnn::wire {
3538
virtual void* GetCmdSpace(size_t size) = 0;
3639
virtual bool Flush() = 0;
3740
virtual size_t GetMaximumAllocationSize() const = 0;
41+
virtual void OnSerializeError();
3842
};
3943

4044
class WEBNN_WIRE_EXPORT CommandHandler {

src/webnn/common/BUILD.gn

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ config("internal_config") {
127127
"-Wshadow-field",
128128
"-Wstrict-prototypes",
129129
"-Wtautological-unsigned-zero-compare",
130+
"-Wno-unused-function",
130131
]
131132

132133
# Allow comparison against type limits that might be tautological on 32bit
@@ -184,6 +185,14 @@ config("internal_config") {
184185
"-Wno-c++17-extensions",
185186
]
186187
}
188+
189+
190+
if (is_clang && webnn_enable_wire) {
191+
cflags += [
192+
"-Wno-unused-function",
193+
]
194+
}
195+
187196
}
188197

189198
###############################################################################

src/webnn/native/ops/Conv2d.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,23 @@ namespace webnn::native::op {
3232
if (options != nullptr && options->bias != nullptr) {
3333
mInputs.push_back(options->bias);
3434
}
35-
if (options == nullptr || options->padding == nullptr) {
35+
if (options == nullptr || options->paddingCount == 0) {
3636
mPadding = std::vector<int32_t>(4, 0);
3737
} else {
3838
mPadding.assign(options->padding, options->padding + options->paddingCount);
3939
}
4040
mOptions.padding = mPadding.data();
4141
mOptions.paddingCount = mPadding.size();
4242

43-
if (options == nullptr || options->strides == nullptr) {
43+
if (options == nullptr || options->stridesCount == 0) {
4444
mStride = std::vector<int32_t>(2, 1);
4545
} else {
4646
mStride.assign(options->strides, options->strides + options->stridesCount);
4747
}
4848
mOptions.strides = mStride.data();
4949
mOptions.stridesCount = mStride.size();
5050

51-
if (options == nullptr || options->dilations == nullptr) {
51+
if (options == nullptr || options->dilationsCount == 0) {
5252
mDilations = std::vector<int32_t>(2, 1);
5353
} else {
5454
mDilations.assign(options->dilations, options->dilations + options->dilationsCount);

src/webnn/native/ops/ConvTranspose2d.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace webnn::native::op {
2525
OperandBase* filter,
2626
ConvTranspose2dOptions const* options)
2727
: Conv2dBase(builder, input, filter, options) {
28-
if (options == nullptr || options->outputPadding == nullptr) {
28+
if (options == nullptr || options->outputPaddingCount == 0) {
2929
mOutputPadding = std::vector<int32_t>(2, 0);
3030
} else {
3131
mOutputPadding.assign(options->outputPadding,
@@ -34,7 +34,7 @@ namespace webnn::native::op {
3434
mOptions.outputPadding = mOutputPadding.data();
3535
mOptions.outputPaddingCount = mOutputPadding.size();
3636

37-
if (options != nullptr && options->outputSizes != nullptr) {
37+
if (options != nullptr && options->outputSizesCount != 0) {
3838
mOutputSizes.assign(options->outputSizes,
3939
options->outputSizes + options->outputSizesCount);
4040
mOptions.outputSizes = mOutputSizes.data();
@@ -113,7 +113,7 @@ namespace webnn::native::op {
113113
}
114114

115115
int32_t outputHeight, outputWidth;
116-
if (mOptions.outputSizes != nullptr) {
116+
if (mOptions.outputSizesCount != 0) {
117117
outputHeight = mOptions.outputSizes[0];
118118
outputWidth = mOptions.outputSizes[1];
119119
} else {

src/webnn/native/ops/Pool2d.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,30 @@ namespace webnn::native::op {
2626
OperandBase* input,
2727
Pool2dOptions const* options)
2828
: OperatorBase(builder, {input}), mOpType(opType) {
29-
if (options != nullptr && options->windowDimensions != nullptr) {
29+
if (options != nullptr && options->windowDimensionsCount != 0) {
3030
mWindowDimensions.assign(options->windowDimensions,
3131
options->windowDimensions + options->windowDimensionsCount);
3232
mOptions.windowDimensions = mWindowDimensions.data();
3333
mOptions.windowDimensionsCount = mWindowDimensions.size();
3434
}
3535

36-
if (options == nullptr || options->padding == nullptr) {
36+
if (options == nullptr || options->paddingCount == 0) {
3737
mPadding = std::vector<int32_t>(4, 0);
3838
} else {
3939
mPadding.assign(options->padding, options->padding + options->paddingCount);
4040
}
4141
mOptions.padding = mPadding.data();
4242
mOptions.paddingCount = mPadding.size();
4343

44-
if (options == nullptr || options->strides == nullptr) {
44+
if (options == nullptr || options->stridesCount == 0) {
4545
mStride = std::vector<int32_t>(2, 1);
4646
} else {
4747
mStride.assign(options->strides, options->strides + options->stridesCount);
4848
}
4949
mOptions.strides = mStride.data();
5050
mOptions.stridesCount = mStride.size();
5151

52-
if (options == nullptr || options->dilations == nullptr) {
52+
if (options == nullptr || options->dilationsCount == 0) {
5353
mDilations = std::vector<int32_t>(2, 1);
5454
} else {
5555
mDilations.assign(options->dilations, options->dilations + options->dilationsCount);
@@ -62,7 +62,7 @@ namespace webnn::native::op {
6262
mOptions.roundingType =
6363
options == nullptr ? wnn::RoundingType::Floor : options->roundingType;
6464

65-
if (options != nullptr && options->outputSizes != nullptr) {
65+
if (options != nullptr && options->outputSizesCount != 0) {
6666
mOutputSizes.assign(options->outputSizes,
6767
options->outputSizes + options->outputSizesCount);
6868
mOptions.outputSizes = mOutputSizes.data();

0 commit comments

Comments
 (0)