@@ -43,11 +43,11 @@ using namespace dnnl::ukernel;
43
43
using tag = memory::format_tag;
44
44
using dt = memory::data_type;
45
45
46
- void brgemm_example (dnnl::engine::kind engine_kind ) {
46
+ void brgemm_example () {
47
47
48
48
// Create execution dnnl::engine. Needed for reorders to operate over input
49
49
// data.
50
- dnnl::engine engine (engine_kind , 0 );
50
+ dnnl::engine engine (engine::kind::cpu , 0 );
51
51
52
52
// Create dnnl::stream. Needed for reorders for the same reason.
53
53
dnnl::stream engine_stream (engine);
@@ -177,16 +177,34 @@ void brgemm_example(dnnl::engine::kind engine_kind) {
177
177
// zeroing the correspondent piece of accumulation buffer.
178
178
brgemm brg, brg_po;
179
179
if (batch_size > 0 ) {
180
- brg = brgemm (M, N, K_k, batch_size, lda, ldb, ldc, a_dt, b_dt, c_dt,
181
- /* alpha = */ 1 .f , /* beta = */ 1 .f );
182
- // Generate the executable JIT code for the objects.
183
- brg.generate ();
180
+ try {
181
+ brg = brgemm (M, N, K_k, batch_size, lda, ldb, ldc, a_dt, b_dt, c_dt,
182
+ /* alpha = */ 1 .f , /* beta = */ 1 .f );
183
+ // Generate the executable JIT code for the objects.
184
+ brg.generate ();
185
+ } catch (error &e) {
186
+ if (e.status == dnnl_unimplemented)
187
+ throw example_allows_unimplemented {
188
+ " Kernel is not supported on this platform.\n " };
189
+
190
+ // on any other error just re-throw
191
+ throw ;
192
+ }
184
193
}
185
194
186
- brg_po = brgemm (M, N, K_k, 1 , lda, ldb, ldc, ldd, a_dt, b_dt, c_dt, d_dt,
187
- 1 .f , 1 .f , brgemm_attr);
188
- // Generate the executable JIT code for the objects.
189
- brg_po.generate ();
195
+ try {
196
+ brg_po = brgemm (M, N, K_k, 1 , lda, ldb, ldc, ldd, a_dt, b_dt, c_dt,
197
+ d_dt, 1 .f , 1 .f , brgemm_attr);
198
+ // Generate the executable JIT code for the objects.
199
+ brg_po.generate ();
200
+ } catch (error &e) {
201
+ if (e.status == dnnl_unimplemented)
202
+ throw example_allows_unimplemented {
203
+ " Kernel is not supported on this platform.\n " };
204
+
205
+ // on any other error just re-throw
206
+ throw ;
207
+ }
190
208
191
209
// Query a scratchpad size and initialize a scratchpad buffer if the ukernel
192
210
// is expecting it. This is a service space needed, has nothing in common
@@ -310,5 +328,5 @@ void brgemm_example(dnnl::engine::kind engine_kind) {
310
328
}
311
329
312
330
int main (int argc, char **argv) {
313
- return handle_example_errors (brgemm_example, dnnl::engine::kind::cpu);
331
+ return handle_example_errors ({ dnnl::engine::kind::cpu}, brgemm_example );
314
332
}
0 commit comments