oneAPI Deep Neural Network Library (oneDNN)
Performance library for Deep Learning
1.96.0
dnnl.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright 2016-2020 Intel Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *******************************************************************************/
16 
19 
20 #ifndef ONEAPI_DNNL_DNNL_HPP
21 #define ONEAPI_DNNL_DNNL_HPP
22 
23 #include "oneapi/dnnl/dnnl_config.h"
24 
26 #include <algorithm>
27 #include <cstdlib>
28 #include <iterator>
29 #include <memory>
30 #include <string>
31 #include <vector>
32 #include <unordered_map>
33 
34 #include "oneapi/dnnl/dnnl.h"
35 
37 
38 // __cpp_exceptions is referred from
39 // https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html
40 // gcc < 5 does not define __cpp_exceptions but __EXCEPTIONS,
41 // Microsoft C++ Compiler does not provide an option to disable exceptions
42 #ifndef DNNL_ENABLE_EXCEPTIONS
43 #if __cpp_exceptions || __EXCEPTIONS \
44  || (defined(_MSC_VER) && !defined(__clang__))
45 #define DNNL_ENABLE_EXCEPTIONS 1
46 #else
47 #define DNNL_ENABLE_EXCEPTIONS 0
48 #endif
49 #endif
50 
51 #if defined(__GNUC__) || defined(__clang__)
52 #define DNNL_TRAP() __builtin_trap()
53 #elif defined(__INTEL_COMPILER) || defined(_MSC_VER)
54 #define DNNL_TRAP() __debugbreak()
55 #else
56 #error "unknown compiler"
57 #endif
58 
59 #if DNNL_ENABLE_EXCEPTIONS
60 #define DNNL_THROW_ERROR(status, msg) throw error(status, msg)
61 #else
62 #include <cstdio>
63 #define DNNL_THROW_ERROR(status, msg) \
64  do { \
65  fputs(msg, stderr); \
66  DNNL_TRAP(); \
67  } while (0)
68 #endif
69 
72 
74 namespace dnnl {
75 
79 
84 struct error : public std::exception {
86  const char *message;
87 
92  error(dnnl_status_t status, const char *message)
93  : status(status), message(message) {}
94 
96  const char *what() const noexcept override { return message; }
97 
103  static void wrap_c_api(dnnl_status_t status, const char *message) {
104  if (status != dnnl_success) DNNL_THROW_ERROR(status, message);
105  }
106 };
107 
109 template <typename T>
110 void validate_container_size(const T &v, const char *error_message,
111  int min_size = 1, int max_size = -1) {
112  const int size = (int)v.size();
113  if (size < min_size || (max_size >= 0 && size > max_size))
114  DNNL_THROW_ERROR(dnnl_invalid_arguments, error_message);
115 }
117 
119 template <typename T>
120 struct handle_traits {};
121 
135 template <typename T, typename traits = handle_traits<T>>
136 struct handle {
137 private:
138  static dnnl_status_t dummy_destructor(T) { return dnnl_success; }
139  std::shared_ptr<typename std::remove_pointer<T>::type> data_ {0};
140 
141 protected:
142  bool operator==(const T other) const { return other == data_.get(); }
143  bool operator!=(const T other) const { return !(*this == other); }
144 
145 public:
153  handle() = default;
154 
156  handle(const handle<T, traits> &) = default;
158  handle<T, traits> &operator=(const handle<T, traits> &) = default;
160  handle(handle<T, traits> &&) = default;
163 
169  explicit handle(T t, bool weak = false) { reset(t, weak); }
170 
176  void reset(T t, bool weak = false) {
177  data_.reset(t, weak ? &dummy_destructor : traits::destructor);
178  }
179 
185  T get(bool allow_empty = false) const {
186  T result = data_.get();
187  if (allow_empty == false && result == nullptr)
188  DNNL_THROW_ERROR(
189  dnnl_invalid_arguments, "object is not initialized");
190  return result;
191  }
192 
197  explicit operator T() const { return get(true); }
198 
202  explicit operator bool() const { return get(true) != nullptr; }
203 
210  bool operator==(const handle<T, traits> &other) const {
211  return other.data_.get() == data_.get();
212  }
213 
220  bool operator!=(const handle &other) const { return !(*this == other); }
221 };
222 
224 template <>
225 struct handle_traits<dnnl_memory_t> {
226  static dnnl_status_t destructor(dnnl_memory_t p) {
227  return dnnl_memory_destroy(p);
228  }
229 };
230 
231 template <>
232 struct handle_traits<dnnl_primitive_desc_t> {
233  static dnnl_status_t destructor(dnnl_primitive_desc_t p) {
234  return dnnl_primitive_desc_destroy(p);
235  }
236 };
237 
238 template <>
239 struct handle_traits<dnnl_primitive_t> {
240  static dnnl_status_t destructor(dnnl_primitive_t p) {
241  return dnnl_primitive_destroy(p);
242  }
243 };
244 
245 template <>
246 struct handle_traits<dnnl_primitive_desc_iterator_t> {
247  static dnnl_status_t destructor(dnnl_primitive_desc_iterator_t p) {
249  }
250 };
252 
254 
255 struct stream;
256 struct memory;
257 struct primitive_desc;
258 
263 
267 
269 struct primitive : public handle<dnnl_primitive_t> {
271  enum class kind {
281  sum = dnnl_sum,
293  lrn = dnnl_lrn,
301  rnn = dnnl_rnn,
315  prelu = dnnl_prelu,
316  };
317 
318  using handle::handle;
319 
321  primitive() = default;
322 
327 
331  primitive(const primitive_desc &pd);
332 
338 
342  inline kind get_kind() const;
343 
356  void execute(const stream &astream,
357  const std::unordered_map<int, memory> &args) const;
358 };
359 
365  return static_cast<dnnl_primitive_kind_t>(akind);
366 }
367 
371  "could not get a primitive descriptor from a primitive");
372  return pd;
373 }
374 
377  // TODO (Roma): the code below is only needed because get_primitive_desc
378  // returns a C type.
381  pd, dnnl_query_primitive_kind, 0, (void *)&kind),
382  "could not get a primitive kind from a primitive descriptor");
383  return static_cast<dnnl::primitive::kind>(kind);
384 }
385 
387 
399 
401 enum class scratchpad_mode {
424 };
425 
431  return static_cast<dnnl_scratchpad_mode_t>(mode);
432 }
433 
435 enum class prop_kind {
459 };
460 
466  return static_cast<dnnl_prop_kind_t>(akind);
467 }
468 
470 enum class algorithm {
472  undef = dnnl_alg_kind_undef,
594 };
595 
600  return static_cast<dnnl_alg_kind_t>(aalgorithm);
601 }
602 
604 
607 
609 enum class normalization_flags : unsigned {
615 
624 
631 
637 };
638 
643  return static_cast<dnnl_normalization_flags_t>(flags);
644 }
645 
647 
650 
652 enum class rnn_flags : unsigned {
655 };
656 
661  return static_cast<dnnl_rnn_flags_t>(flags);
662 }
663 
664 #define DNNL_DEFINE_BITMASK_OPS(enum_name) \
665  inline enum_name operator|(enum_name lhs, enum_name rhs) { \
666  return static_cast<enum_name>( \
667  static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); \
668  } \
669 \
670  inline enum_name operator&(enum_name lhs, enum_name rhs) { \
671  return static_cast<enum_name>( \
672  static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); \
673  } \
674 \
675  inline enum_name operator^(enum_name lhs, enum_name rhs) { \
676  return static_cast<enum_name>( \
677  static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); \
678  } \
679 \
680  inline enum_name &operator|=(enum_name &lhs, enum_name rhs) { \
681  lhs = static_cast<enum_name>( \
682  static_cast<unsigned>(lhs) | static_cast<unsigned>(rhs)); \
683  return lhs; \
684  } \
685 \
686  inline enum_name &operator&=(enum_name &lhs, enum_name rhs) { \
687  lhs = static_cast<enum_name>( \
688  static_cast<unsigned>(lhs) & static_cast<unsigned>(rhs)); \
689  return lhs; \
690  } \
691 \
692  inline enum_name &operator^=(enum_name &lhs, enum_name rhs) { \
693  lhs = static_cast<enum_name>( \
694  static_cast<unsigned>(lhs) ^ static_cast<unsigned>(rhs)); \
695  return lhs; \
696  } \
697 \
698  inline enum_name operator~(enum_name rhs) { \
699  return static_cast<enum_name>(~static_cast<unsigned>(rhs)); \
700  }
701 
702 DNNL_DEFINE_BITMASK_OPS(normalization_flags)
703 DNNL_DEFINE_BITMASK_OPS(rnn_flags)
704 
705 enum class rnn_direction {
719 };
720 
725  return static_cast<dnnl_rnn_direction_t>(dir);
726 }
727 
729 
732 
739 enum class query {
742 
747 
752 
759 
764 
769 
772 
775 
810 
829 };
830 
835  return static_cast<dnnl_query_t>(aquery);
836 }
837 
839 
841 
852 
854 template <>
855 struct handle_traits<dnnl_engine_t> {
856  static dnnl_status_t destructor(dnnl_engine_t p) {
857  return dnnl_engine_destroy(p);
858  }
859 };
861 
863 struct engine : public handle<dnnl_engine_t> {
864  friend struct primitive;
865  friend struct reorder;
866 
868  enum class kind {
872  cpu = dnnl_cpu,
874  gpu = dnnl_gpu,
875  };
876 
877  using handle::handle;
878 
881  engine() = default;
882 
887  static size_t get_count(kind akind) {
888  return dnnl_engine_get_count(convert_to_c(akind));
889  }
890 
896  engine(kind akind, size_t index) {
899  dnnl_engine_create(&engine, convert_to_c(akind), index),
900  "could not create an engine");
901  reset(engine);
902  }
903 
909  dnnl_engine_t c_engine;
912  dnnl::convert_to_c(dnnl::query::engine), 0, &c_engine),
913  "could not get an engine from a primitive_desc");
914  reset(c_engine, true);
915  }
916 
919  kind get_kind() const {
922  "could not get kind of an engine");
923  return static_cast<engine::kind>(kind);
924  }
925 
931  template <typename primitive_desc>
932  static engine query(const primitive_desc &pd) {
933  return query(pd, dnnl::query::engine);
934  }
935 
936 private:
937  static dnnl_engine_kind_t convert_to_c(kind akind) {
938  return static_cast<dnnl_engine_kind_t>(akind);
939  }
940 
941  template <typename primitive_desc>
942  static engine query(const primitive_desc &pd, dnnl::query what) {
943  dnnl_engine_t c_engine;
945  dnnl::convert_to_c(what), 0, &c_engine),
946  "could not get an engine from a primitive_desc");
947  return engine(c_engine, true);
948  }
949 };
950 
956  return static_cast<dnnl_engine_kind_t>(akind);
957 }
958 
960 
968 
970 template <>
971 struct handle_traits<dnnl_stream_t> {
972  static dnnl_status_t destructor(dnnl_stream_t p) {
973  return dnnl_stream_destroy(p);
974  }
975 };
977 
979 struct stream : public handle<dnnl_stream_t> {
980  using handle::handle;
981 
983  enum class flags : unsigned {
985  in_order = dnnl_stream_in_order,
990  };
991 
994  stream() = default;
995 
1001  stream(const engine &aengine, flags aflags = flags::default_flags) {
1004  static_cast<dnnl_stream_flags_t>(aflags)),
1005  "could not create a stream");
1006  reset(stream);
1007  }
1008 
1010  engine get_engine() const {
1011  dnnl_engine_t c_engine;
1012  error::wrap_c_api(dnnl_stream_get_engine(get(), &c_engine),
1013  "could not get an engine from a stream object");
1014  return engine(c_engine, true);
1015  }
1016 
1021  dnnl_stream_wait(get()), "could not wait on a stream");
1022  return *this;
1023  }
1024 };
1025 
1026 DNNL_DEFINE_BITMASK_OPS(stream::flags)
1027 
1028 
1095 
1102 struct memory : public handle<dnnl_memory_t> {
1103  using handle::handle;
1104 
1106  typedef dnnl_dim_t dim;
1109  typedef std::vector<dim> dims;
1110 
1117  template <typename T>
1118  static void validate_dims(const std::vector<T> &v, int min_size = 0) {
1119  validate_container_size(
1120  v, "dimensions are invalid", min_size, DNNL_MAX_NDIMS);
1121  }
1122 
1124  enum class data_type {
1128  f16 = dnnl_f16,
1131  bf16 = dnnl_bf16,
1133  f32 = dnnl_f32,
1135  s32 = dnnl_s32,
1137  s8 = dnnl_s8,
1139  u8 = dnnl_u8,
1140  };
1141 
1143  enum class format_kind {
1148  any = dnnl_format_kind_any,
1152  blocked = dnnl_blocked,
1154  wino = dnnl_format_kind_wino,
1156  packed = dnnl_format_kind_rnn_packed,
1157  };
1158 
1199  enum class format_tag {
1204  any = dnnl_format_tag_any,
1205 
1207  a = dnnl_a,
1208 
1210  ab = dnnl_ab,
1212  ba = dnnl_ba,
1213 
1215  abc = dnnl_abc,
1217  acb = dnnl_acb,
1219  bac = dnnl_bac,
1221  bca = dnnl_bca,
1223  cba = dnnl_cba,
1224 
1226  abcd = dnnl_abcd,
1228  abdc = dnnl_abdc,
1230  acdb = dnnl_acdb,
1232  bacd = dnnl_bacd,
1234  bcda = dnnl_bcda,
1236  cdba = dnnl_cdba,
1238  dcab = dnnl_dcab,
1239 
1241  abcde = dnnl_abcde,
1243  abdec = dnnl_abdec,
1245  acbde = dnnl_acbde,
1247  acdeb = dnnl_acdeb,
1249  bacde = dnnl_bacde,
1251  bcdea = dnnl_bcdea,
1253  cdeba = dnnl_cdeba,
1255  decab = dnnl_decab,
1257  abced = dnnl_abced,
1258 
1260  abcdef = dnnl_abcdef,
1262  abdfce = dnnl_abdfce,
1264  acbdef = dnnl_acbdef,
1266  abdefc = dnnl_abdefc,
1268  defcab = dnnl_defcab,
1270  abcdfe = dnnl_abcdfe,
1271 
1273  abcdefg = dnnl_abcdefg,
1275  abcdegf = dnnl_abcdegf,
1276 
1278  abcdefgh = dnnl_abcdefgh,
1280  abcdefhg = dnnl_abcdefhg,
1281 
1283  abcdefghi = dnnl_abcdefghi,
1285  abcdefgih = dnnl_abcdefgih,
1286 
1288  abcdefghij = dnnl_abcdefghij,
1290  abcdefghji = dnnl_abcdefghji,
1291 
1293  abcdefghijk = dnnl_abcdefghijk,
1295  abcdefghikj = dnnl_abcdefghikj,
1296 
1298  abcdefghijkl = dnnl_abcdefghijkl,
1300  abcdefghijlk = dnnl_abcdefghijlk,
1301 
1303  x = a,
1305  nc = ab,
1307  cn = ba,
1309  tn = ab,
1311  nt = ba,
1313  ncw = abc,
1315  nwc = acb,
1317  nchw = abcd,
1319  nhwc = acdb,
1321  chwn = bcda,
1323  ncdhw = abcde,
1325  ndhwc = acdeb,
1326 
1328  oi = ab,
1330  io = ba,
1332  oiw = abc,
1334  owi = acb,
1336  wio = cba,
1338  iwo = bca,
1340  oihw = abcd,
1342  hwio = cdba,
1344  ohwi = acdb,
1346  ihwo = bcda,
1348  iohw = bacd,
1350  oidhw = abcde,
1352  dhwio = cdeba,
1354  odhwi = acdeb,
1356  iodhw = bacde,
1358  idhwo = bcdea,
1359 
1361  goiw = abcd,
1363  gowi = abdc,
1365  wigo = dcab,
1367  gohwi = abdec,
1369  goihw = abcde,
1371  hwigo = decab,
1373  giohw = acbde,
1375  goidhw = abcdef,
1377  giodhw = acbdef,
1379  godhwi = abdefc,
1381  dhwigo = defcab,
1382 
1384  tnc = abc,
1386  ntc = bac,
1389  ldnc = abcd,
1396  ldigo = abcde,
1403  ldgoi = abdec,
1406  ldio = abcd,
1409  ldoi = abdc,
1416  ldgo = abcd,
1417 
1418  // Opaque blocked formats
1419 
1420  AB16b16a = dnnl_AB16b16a,
1421  AB16b32a = dnnl_AB16b32a,
1422  AB16b64a = dnnl_AB16b64a,
1423  AB8b16a2b = dnnl_AB8b16a2b,
1424  AB8b32a2b = dnnl_AB8b32a2b,
1425  AB8b64a2b = dnnl_AB8b64a2b,
1426  AB4b16a4b = dnnl_AB4b16a4b,
1427  AB4b32a4b = dnnl_AB4b32a4b,
1428  AB4b64a4b = dnnl_AB4b64a4b,
1429  Abc16a = dnnl_Abc16a,
1430  ABc16a16b = dnnl_ABc16a16b,
1431  ABc4a4b = dnnl_ABc4a4b,
1432  aBc16b = dnnl_aBc16b,
1433  aBc32b = dnnl_aBc32b,
1434  ABc16b16a = dnnl_ABc16b16a,
1435  ABc16b32a = dnnl_ABc16b32a,
1436  ABc16b64a = dnnl_ABc16b64a,
1437  Abc4a = dnnl_Abc4a,
1438  aBc4b = dnnl_aBc4b,
1439  ABc4b16a4b = dnnl_ABc4b16a4b,
1440  ABc4b32a4b = dnnl_ABc4b32a4b,
1441  ABc4b64a4b = dnnl_ABc4b64a4b,
1442  ABc2b8a4b = dnnl_ABc2b8a4b,
1443  ABc16b16a4b = dnnl_ABc16b16a4b,
1444  ABc16b16a2b = dnnl_ABc16b16a2b,
1445  ABc4b4a = dnnl_ABc4b4a,
1446  ABc8a16b2a = dnnl_ABc8a16b2a,
1447  ABc8a8b = dnnl_ABc8a8b,
1448  ABc8a4b = dnnl_ABc8a4b,
1449  aBc8b = dnnl_aBc8b,
1450  ABc8b16a2b = dnnl_ABc8b16a2b,
1451  ABc8b32a2b = dnnl_ABc8b32a2b,
1452  ABc8b64a2b = dnnl_ABc8b64a2b,
1453  ABc8b8a = dnnl_ABc8b8a,
1454  Abcd8a = dnnl_Abcd8a,
1455  Abcd16a = dnnl_Abcd16a,
1456  Abcd32a = dnnl_Abcd32a,
1457  ABcd16a16b = dnnl_ABcd16a16b,
1458  aBcd16b = dnnl_aBcd16b,
1459  aBcd32b = dnnl_aBcd32b,
1460  ABcd16b16a = dnnl_ABcd16b16a,
1461  ABcd16b32a = dnnl_ABcd16b32a,
1462  ABcd16b64a = dnnl_ABcd16b64a,
1463  aBCd16b16c = dnnl_aBCd16b16c,
1464  aBCd16c16b = dnnl_aBCd16c16b,
1465  Abcd4a = dnnl_Abcd4a,
1466  aBcd4b = dnnl_aBcd4b,
1467  ABcd4b16a4b = dnnl_ABcd4b16a4b,
1468  ABcd4b32a4b = dnnl_ABcd4b32a4b,
1469  ABcd4b64a4b = dnnl_ABcd4b64a4b,
1470  ABcd2b8a4b = dnnl_ABcd2b8a4b,
1471  ABcd4b4a = dnnl_ABcd4b4a,
1472  ABcd4a4b = dnnl_ABcd4a4b,
1473  aBCd4c16b4c = dnnl_aBCd4c16b4c,
1474  aBCd2c8b4c = dnnl_aBCd2c8b4c,
1475  ABcd16b16a4b = dnnl_ABcd16b16a4b,
1476  ABcd16b16a2b = dnnl_ABcd16b16a2b,
1477  aBCd16c16b4c = dnnl_aBCd16c16b4c,
1478  aBCd16c16b2c = dnnl_aBCd16c16b2c,
1479  aBCd4c4b = dnnl_aBCd4c4b,
1480  aBCd4b4c = dnnl_aBCd4b4c,
1481  ABcd8a16b2a = dnnl_ABcd8a16b2a,
1482  ABcd8a8b = dnnl_ABcd8a8b,
1483  ABcd8a4b = dnnl_ABcd8a4b,
1485  aBcd8b = dnnl_aBcd8b,
1486  ABcd8b16a2b = dnnl_ABcd8b16a2b,
1487  ABcd8b32a2b = dnnl_ABcd8b32a2b,
1488  ABcd8b64a2b = dnnl_ABcd8b64a2b,
1489  aBCd8b16c2b = dnnl_aBCd8b16c2b,
1491  ABcd8b8a = dnnl_ABcd8b8a,
1492  aBCd8b8c = dnnl_aBCd8b8c,
1493  aBCd8b4c = dnnl_aBCd8b4c,
1494  aBCd8c16b2c = dnnl_aBCd8c16b2c,
1495  aBCd8c8b = dnnl_aBCd8c8b,
1496  Abcde16a = dnnl_Abcde16a,
1497  Abcde32a = dnnl_Abcde32a,
1498  ABcde16a16b = dnnl_ABcde16a16b,
1499  aBcde16b = dnnl_aBcde16b,
1500  aBcde32b = dnnl_aBcde32b,
1501  ABcde16b16a = dnnl_ABcde16b16a,
1502  ABcde16b32a = dnnl_ABcde16b32a,
1503  ABcde16b64a = dnnl_ABcde16b64a,
1504  aBCde16b16c = dnnl_aBCde16b16c,
1505  aBCde16c16b = dnnl_aBCde16c16b,
1506  aBCde2c8b4c = dnnl_aBCde2c8b4c,
1507  Abcde4a = dnnl_Abcde4a,
1508  aBcde4b = dnnl_aBcde4b,
1509  ABcde4b4a = dnnl_ABcde4b4a,
1510  ABcde4a4b = dnnl_ABcde4a4b,
1511  aBCde4b4c = dnnl_aBCde4b4c,
1512  aBCde4c16b4c = dnnl_aBCde4c16b4c,
1513  aBCde16c16b4c = dnnl_aBCde16c16b4c,
1514  aBCde16c16b2c = dnnl_aBCde16c16b2c,
1515  aBCde4c4b = dnnl_aBCde4c4b,
1516  Abcde8a = dnnl_Abcde8a,
1517  ABcde8a8b = dnnl_ABcde8a8b,
1518  ABcde8a4b = dnnl_ABcde8a4b,
1519  aBcde8b = dnnl_aBcde8b,
1520  ABcde8b16a2b = dnnl_ABcde8b16a2b,
1521  ABcde8b32a2b = dnnl_ABcde8b32a2b,
1522  ABcde8b64a2b = dnnl_ABcde8b64a2b,
1523  ABcde4b16a4b = dnnl_ABcde4b16a4b,
1524  ABcde4b32a4b = dnnl_ABcde4b32a4b,
1525  ABcde4b64a4b = dnnl_ABcde4b64a4b,
1526  ABcde2b8a4b = dnnl_ABcde2b8a4b,
1527  aBCde8b16c2b = dnnl_aBCde8b16c2b,
1528  ABcde8b8a = dnnl_ABcde8b8a,
1529  aBCde8b8c = dnnl_aBCde8b8c,
1530  aBCde8b4c = dnnl_aBCde8b4c,
1531  ABcd4a8b8a4b = dnnl_ABcd4a8b8a4b,
1532  ABcd2a8b8a2b = dnnl_ABcd2a8b8a2b,
1533  aBCde4b8c8b4c = dnnl_aBCde4b8c8b4c,
1534  aBCde2b8c8b2c = dnnl_aBCde2b8c8b2c,
1535  aBCde8c16b2c = dnnl_aBCde8c16b2c,
1536  aBCde8c8b = dnnl_aBCde8c8b,
1537  aBcdef16b = dnnl_aBcdef16b,
1538  aBCdef16b16c = dnnl_aBCdef16b16c,
1539  aBCdef16c16b = dnnl_aBCdef16c16b,
1540  aBcdef4b = dnnl_aBcdef4b,
1541  aBCdef2c8b4c = dnnl_aBCdef2c8b4c,
1542  aBCdef4c4b = dnnl_aBCdef4c4b,
1543  aBCdef4b4c = dnnl_aBCdef4b4c,
1544  aBCdef8b8c = dnnl_aBCdef8b8c,
1545  aBCdef8b4c = dnnl_aBCdef8b4c,
1546  aBCdef8c16b2c = dnnl_aBCdef8c16b2c,
1547  aBCdef4c16b4c = dnnl_aBCdef4c16b4c,
1548  aBCdef8c8b = dnnl_aBCdef8c8b,
1549  aBdc16b = dnnl_aBdc16b,
1550  aBdc4b = dnnl_aBdc4b,
1551  aBdc8b = dnnl_aBdc8b,
1552  aBdec16b = dnnl_aBdec16b,
1553  aBdec4b = dnnl_aBdec4b,
1554  aBdec8b = dnnl_aBdec8b,
1555  aBdefc16b = dnnl_aBdefc16b,
1556  aCBdef16c16b = dnnl_aCBdef16c16b,
1557  aCBdef16b16c = dnnl_aCBdef16b16c,
1558  aBdefc4b = dnnl_aBdefc4b,
1559  aBdefc8b = dnnl_aBdefc8b,
1560  Acb16a = dnnl_Acb16a,
1561  Acb4a = dnnl_Acb4a,
1562  Acb8a = dnnl_Acb8a,
1563  aCBd16b16c = dnnl_aCBd16b16c,
1564  aCBd16c16b = dnnl_aCBd16c16b,
1565  aCBde16b16c = dnnl_aCBde16b16c,
1566  aCBde16c16b = dnnl_aCBde16c16b,
1567  Acdb16a = dnnl_Acdb16a,
1568  Acdb4a = dnnl_Acdb4a,
1569  Acdb8a = dnnl_Acdb8a,
1570  Acdeb16a = dnnl_Acdeb16a,
1571  Acdeb4a = dnnl_Acdeb4a,
1572  Acdeb8a = dnnl_Acdeb8a,
1573  BAc16a16b = dnnl_BAc16a16b,
1574  BAc16b16a = dnnl_BAc16b16a,
1575  BAcd16a16b = dnnl_BAcd16a16b,
1576  BAcd16b16a = dnnl_BAcd16b16a,
1577  ABcd32a32b = dnnl_ABcd32a32b,
1578  BAcde16b16a = dnnl_BAcde16b16a,
1579  BAcde16a16b = dnnl_BAcde16a16b,
1580  aBdec32b = dnnl_aBdec32b,
1581  Abcdef16a = dnnl_Abcdef16a,
1582  Abcdef32a = dnnl_Abcdef32a,
1583  Acdb32a = dnnl_Acdb32a,
1584  aBCd2b4c2b = dnnl_aBCd2b4c2b,
1585  aBCde2b4c2b = dnnl_aBCde2b4c2b,
1586  aBCdef2b4c2b = dnnl_aBCdef2b4c2b,
1587  aBCd2c4b2c = dnnl_aBCd2c4b2c,
1588  aBCde2c4b2c = dnnl_aBCde2c4b2c,
1589  aBCdef2c4b2c = dnnl_aBCdef2c4b2c,
1590  aBCd4b8c2b = dnnl_aBCd4b8c2b,
1591  aBCde4b8c2b = dnnl_aBCde4b8c2b,
1592  aBCdef4b8c2b = dnnl_aBCdef4b8c2b,
1593  aBCd4c8b2c = dnnl_aBCd4c8b2c,
1594  aBCde4c8b2c = dnnl_aBCde4c8b2c,
1595  aBCdef4c8b2c = dnnl_aBCdef4c8b2c,
1596  AB32a32b8a4b = dnnl_AB32a32b8a4b,
1597  AB32a32b8a2b = dnnl_AB32a32b8a2b,
1598  AB8a4b = dnnl_AB8a4b,
1599  AB8a2b = dnnl_AB8a2b,
1600  abDc32d = dnnl_abDc32d,
1601  abDC32d4c = dnnl_abDC32d4c,
1602  abdEc32e = dnnl_abdEc32e,
1603  abdEC32e2c = dnnl_abdEC32e2c,
1604  abdEC32e4c = dnnl_abdEC32e4c,
1605 
1606  format_tag_last = dnnl_format_tag_last,
1607 
1608  nCdhw16c = dnnl_nCdhw16c,
1609  nCdhw4c = dnnl_nCdhw4c,
1610  nCdhw8c = dnnl_nCdhw8c,
1611  nChw16c = dnnl_nChw16c,
1612  nChw4c = dnnl_nChw4c,
1613  nChw8c = dnnl_nChw8c,
1614  nCw16c = dnnl_nCw16c,
1615  nCw4c = dnnl_nCw4c,
1616  nCw8c = dnnl_nCw8c,
1617  NCw16n16c = dnnl_NCw16n16c,
1618  NChw16n16c = dnnl_NChw16n16c,
1619  NCdhw16n16c = dnnl_NCdhw16n16c,
1620  NCdhw32n32c = dnnl_NCdhw32n32c,
1621  NChw32n32c = dnnl_NChw32n32c,
1622  IOhw16i16o = dnnl_IOhw16i16o,
1623  OI16i16o = dnnl_OI16i16o,
1624  OI16i32o = dnnl_OI16i32o,
1625  OI16i64o = dnnl_OI16i64o,
1626  OI8i16o2i = dnnl_OI8i16o2i,
1627  OI8i32o2i = dnnl_OI8i32o2i,
1628  OI8i64o2i = dnnl_OI8i64o2i,
1629  OI4i16o4i = dnnl_OI4i16o4i,
1630  OI4i32o4i = dnnl_OI4i32o4i,
1631  OI4i64o4i = dnnl_OI4i64o4i,
1632  Ohwi32o = dnnl_Ohwi32o,
1633  IOdhw16i16o = dnnl_IOdhw16i16o,
1634  gIOhw16i16o = dnnl_gIOhw16i16o,
1635  gOhwi32o = dnnl_gOhwi32o,
1636  Goidhw16g = dnnl_Goidhw16g,
1637  IOw16o16i = dnnl_IOw16o16i,
1638  OIw16i16o = dnnl_OIw16i16o,
1639  OIw16i32o = dnnl_OIw16i32o,
1640  OIw16i64o = dnnl_OIw16i64o,
1641  IOw16i16o = dnnl_IOw16i16o,
1642  gIOw16i16o = dnnl_gIOw16i16o,
1643  OIw16o16i = dnnl_OIw16o16i,
1644  Oiw16o = dnnl_Oiw16o,
1645  OIw4i16o4i = dnnl_OIw4i16o4i,
1646  OIw4i32o4i = dnnl_OIw4i32o4i,
1647  OIw4i64o4i = dnnl_OIw4i64o4i,
1648  OIw2i8o4i = dnnl_OIw2i8o4i,
1649  OIw4i4o = dnnl_OIw4i4o,
1650  OIw4o4i = dnnl_OIw4o4i,
1651  Oiw4o = dnnl_Oiw4o,
1652  OIw8i16o2i = dnnl_OIw8i16o2i,
1653  OIw8i32o2i = dnnl_OIw8i32o2i,
1654  OIw8i64o2i = dnnl_OIw8i64o2i,
1655  OIw8i8o = dnnl_OIw8i8o,
1656  OIw8o16i2o = dnnl_OIw8o16i2o,
1657  OIw8o8i = dnnl_OIw8o8i,
1658  OIw8o4i = dnnl_OIw8o4i,
1659  Owi16o = dnnl_Owi16o,
1660  OwI16o2i = dnnl_OwI16o2i,
1661  Owi4o = dnnl_Owi4o,
1662  Owi8o = dnnl_Owi8o,
1663  IOhw16o16i = dnnl_IOhw16o16i,
1664  Ohwi16o = dnnl_Ohwi16o,
1665  OhwI16o2i = dnnl_OhwI16o2i,
1666  Ohwi4o = dnnl_Ohwi4o,
1667  Ohwi8o = dnnl_Ohwi8o,
1668  OIhw16i16o = dnnl_OIhw16i16o,
1669  OIhw16i32o = dnnl_OIhw16i32o,
1670  OIhw16i64o = dnnl_OIhw16i64o,
1671  OIhw16o16i = dnnl_OIhw16o16i,
1672  Oihw16o = dnnl_Oihw16o,
1673  OIhw4i16o4i = dnnl_OIhw4i16o4i,
1674  OIhw4i32o4i = dnnl_OIhw4i32o4i,
1675  OIhw4i64o4i = dnnl_OIhw4i64o4i,
1676  OIhw4i4o = dnnl_OIhw4i4o,
1677  OIhw4o4i = dnnl_OIhw4o4i,
1678  Oihw4o = dnnl_Oihw4o,
1679  OIhw8i16o2i = dnnl_OIhw8i16o2i,
1680  OIhw8i32o2i = dnnl_OIhw8i32o2i,
1681  OIhw8i64o2i = dnnl_OIhw8i64o2i,
1682  OIhw8i8o = dnnl_OIhw8i8o,
1683  OIhw8o16i2o = dnnl_OIhw8o16i2o,
1684  OIhw8o8i = dnnl_OIhw8o8i,
1685  OIhw8o4i = dnnl_OIhw8o4i,
1686  OIhw2i8o4i = dnnl_OIhw2i8o4i,
1687  IOdhw16o16i = dnnl_IOdhw16o16i,
1688  Odhwi16o = dnnl_Odhwi16o,
1689  OdhwI16o2i = dnnl_OdhwI16o2i,
1690  Odhwi4o = dnnl_Odhwi4o,
1691  Odhwi8o = dnnl_Odhwi8o,
1692  OIdhw16i16o = dnnl_OIdhw16i16o,
1693  OIdhw16i32o = dnnl_OIdhw16i32o,
1694  OIdhw16i64o = dnnl_OIdhw16i64o,
1695  OIdhw16o16i = dnnl_OIdhw16o16i,
1696  Oidhw16o = dnnl_Oidhw16o,
1697  OIdhw4i4o = dnnl_OIdhw4i4o,
1698  OIdhw4o4i = dnnl_OIdhw4o4i,
1699  Oidhw4o = dnnl_Oidhw4o,
1700  OIdhw8i16o2i = dnnl_OIdhw8i16o2i,
1701  OIdhw8i32o2i = dnnl_OIdhw8i32o2i,
1702  OIdhw8i64o2i = dnnl_OIdhw8i64o2i,
1703  OIdhw4i16o4i = dnnl_OIdhw4i16o4i,
1704  OIdhw4i32o4i = dnnl_OIdhw4i32o4i,
1705  OIdhw4i64o4i = dnnl_OIdhw4i64o4i,
1706  OIdhw2i8o4i = dnnl_OIdhw2i8o4i,
1707  OIdhw8i8o = dnnl_OIdhw8i8o,
1708  OIdhw8o8i = dnnl_OIdhw8o8i,
1709  OIdhw8o4i = dnnl_OIdhw8o4i,
1710  gIOw16o16i = dnnl_gIOw16o16i,
1711  gOIw16i16o = dnnl_gOIw16i16o,
1712  gOIw16o16i = dnnl_gOIw16o16i,
1713  gOiw16o = dnnl_gOiw16o,
1714  gOIw4i16o4i = dnnl_gOIw4i16o4i,
1715  gOIw2i8o4i = dnnl_gOIw2i8o4i,
1716  gOIw4i4o = dnnl_gOIw4i4o,
1717  gOIw4o4i = dnnl_gOIw4o4i,
1718  gOiw4o = dnnl_gOiw4o,
1719  gOIw8i16o2i = dnnl_gOIw8i16o2i,
1720  gOIw8i8o = dnnl_gOIw8i8o,
1721  gOIw8o16i2o = dnnl_gOIw8o16i2o,
1722  gOIw8o8i = dnnl_gOIw8o8i,
1723  gOIw8o4i = dnnl_gOIw8o4i,
1724  gOwi16o = dnnl_gOwi16o,
1725  gOwI16o2i = dnnl_gOwI16o2i,
1726  gOwi4o = dnnl_gOwi4o,
1727  gOwi8o = dnnl_gOwi8o,
1728  Goiw8g = dnnl_Goiw8g,
1729  Goiw16g = dnnl_Goiw16g,
1730  gIOhw16o16i = dnnl_gIOhw16o16i,
1731  gOhwi16o = dnnl_gOhwi16o,
1732  gOhwI16o2i = dnnl_gOhwI16o2i,
1733  gOhwi4o = dnnl_gOhwi4o,
1734  gOhwi8o = dnnl_gOhwi8o,
1735  Goihw16g = dnnl_Goihw16g,
1736  gOIhw16i16o = dnnl_gOIhw16i16o,
1737  gOIhw16o16i = dnnl_gOIhw16o16i,
1738  gOihw16o = dnnl_gOihw16o,
1739  gOIhw4i16o4i = dnnl_gOIhw4i16o4i,
1740  gOIhw2i8o4i = dnnl_gOIhw2i8o4i,
1741  gOIhw4i4o = dnnl_gOIhw4i4o,
1742  gOIhw4o4i = dnnl_gOIhw4o4i,
1743  gOihw4o = dnnl_gOihw4o,
1744  Goihw8g = dnnl_Goihw8g,
1745  gOIhw8i16o2i = dnnl_gOIhw8i16o2i,
1746  gOIhw8i8o = dnnl_gOIhw8i8o,
1747  gOIhw8o16i2o = dnnl_gOIhw8o16i2o,
1748  OIw4o8i8o4i = dnnl_OIw4o8i8o4i,
1749  OIdhw4o8i8o4i = dnnl_OIdhw4o8i8o4i,
1750  OIhw4o8i8o4i = dnnl_OIhw4o8i8o4i,
1751  OIhw2o8i8o2i = dnnl_OIhw2o8i8o2i,
1752  gOIw4o8i8o4i = dnnl_gOIw4o8i8o4i,
1753  gOIdhw4o8i8o4i = dnnl_gOIdhw4o8i8o4i,
1754  gOIhw4o8i8o4i = dnnl_gOIhw4o8i8o4i,
1755  gOIhw2o8i8o2i = dnnl_gOIhw2o8i8o2i,
1756  OIhw16i16o4i = dnnl_OIhw16i16o4i,
1757  OIhw16i16o2i = dnnl_OIhw16i16o2i,
1758  gOIhw16i16o4i = dnnl_gOIhw16i16o4i,
1759  gOIhw16i16o2i = dnnl_gOIhw16i16o2i,
1760  gOIhw8o8i = dnnl_gOIhw8o8i,
1761  gOIhw8o4i = dnnl_gOIhw8o4i,
1762  gIOdhw16i16o = dnnl_gIOdhw16i16o,
1763  gIOdhw16o16i = dnnl_gIOdhw16o16i,
1764  gOdhwi16o = dnnl_gOdhwi16o,
1765  gOdhwI16o2i = dnnl_gOdhwI16o2i,
1766  gOdhwi4o = dnnl_gOdhwi4o,
1767  gOdhwi8o = dnnl_gOdhwi8o,
1768  gOIdhw16i16o = dnnl_gOIdhw16i16o,
1769  gOIdhw16o16i = dnnl_gOIdhw16o16i,
1770  gOidhw16o = dnnl_gOidhw16o,
1771  gOIdhw4i4o = dnnl_gOIdhw4i4o,
1772  gOIdhw4o4i = dnnl_gOIdhw4o4i,
1773  gOidhw4o = dnnl_gOidhw4o,
1774  gOIdhw8i16o2i = dnnl_gOIdhw8i16o2i,
1775  gOIdhw4i16o4i = dnnl_gOIdhw4i16o4i,
1776  gOIdhw2i8o4i = dnnl_gOIdhw2i8o4i,
1777  gOIdhw8i8o = dnnl_gOIdhw8i8o,
1778  gOIdhw8o8i = dnnl_gOIdhw8o8i,
1779  gOIdhw8o4i = dnnl_gOIdhw8o4i,
1780  gOIw2i4o2i = dnnl_gOIw2i4o2i,
1781  gOIhw2i4o2i = dnnl_gOIhw2i4o2i,
1782  gOIdhw2i4o2i = dnnl_gOIdhw2i4o2i,
1783  gOIw2o4i2o = dnnl_gOIw2o4i2o,
1784  gOIhw2o4i2o = dnnl_gOIhw2o4i2o,
1785  gOIdhw2o4i2o = dnnl_gOIdhw2o4i2o,
1786  gOIw4i8o2i = dnnl_gOIw4i8o2i,
1787  gOIhw4i8o2i = dnnl_gOIhw4i8o2i,
1788  gOIdhw4i8o2i = dnnl_gOIdhw4i8o2i,
1789  gOIw4o8i2o = dnnl_gOIw4o8i2o,
1790  gOIhw4o8i2o = dnnl_gOIhw4o8i2o,
1791  gOIdhw4o8i2o = dnnl_gOIdhw4o8i2o,
1792  ldOi32o = abDc32d,
1793  ldOI32o4i = abDC32d4c,
1794  ldgOi32o = abdEc32e,
1795  ldgOI32o2i = abdEC32e2c,
1796  ldgOI32o4i = abdEC32e4c,
1797  };
1798 
1800  struct desc {
1801  friend struct memory;
1804 
1807  desc() : data() {}
1808 
1824  desc(const dims &adims, data_type adata_type, format_tag aformat_tag,
1825  bool allow_empty = false)
1826  : data() {
1827  validate_dims(adims);
1829  (int)adims.size(), adims.data(), convert_to_c(adata_type),
1830  convert_to_c(aformat_tag));
1831  if (!allow_empty)
1833  "could not construct a memory descriptor using a "
1834  "format tag");
1835  }
1836 
1852  desc(const dims &adims, data_type adata_type, const dims &strides,
1853  bool allow_empty = false)
1854  : data() {
1855  validate_dims(adims);
1856  if (!strides.empty()) validate_dims(strides, (int)adims.size());
1858  (int)adims.size(), adims.data(), convert_to_c(adata_type),
1859  strides.empty() ? nullptr : &strides[0]);
1860  if (!allow_empty)
1862  "could not construct a memory descriptor using "
1863  "strides");
1864  }
1865 
1869  desc(const dnnl_memory_desc_t &data) : data(data) {}
1870 
1873  //
1882  desc submemory_desc(const dims &adims, const dims &offsets,
1883  bool allow_empty = false) const {
1884  validate_dims(adims, data.ndims);
1885  validate_dims(offsets, data.ndims);
1888  &sub_md, &data, adims.data(), offsets.data());
1889  if (!allow_empty)
1890  error::wrap_c_api(status, "could not construct a sub-memory");
1891  return desc(sub_md);
1892  }
1893 
1938  desc reshape(const dims &adims, bool allow_empty = false) const {
1939  if (data.ndims) validate_dims(adims, 1);
1942  &out_md, &data, (int)adims.size(), adims.data());
1943  if (!allow_empty)
1945  status, "could not reshape a memory descriptor");
1946  return desc(out_md);
1947  }
1948 
1986  desc permute_axes(const std::vector<int> &permutation,
1987  bool allow_empty = false) const {
1988  validate_dims(permutation, data.ndims);
1991  &out_md, &data, permutation.data());
1992  if (!allow_empty)
1994  "could not permute axes of a memory descriptor");
1995  return desc(out_md);
1996  }
1997 
2002  memory::dims dims() const {
2003  return memory::dims(data.dims, data.dims + data.ndims);
2004  }
2005 
2009  return static_cast<memory::data_type>(data.data_type);
2010  }
2011 
2016  size_t get_size() const { return dnnl_memory_desc_get_size(&data); }
2017 
2021  bool is_zero() const { return data.ndims == 0; }
2022 
2027  bool operator==(const desc &other) const {
2028  return dnnl_memory_desc_equal(&data, &other.data) != 0;
2029  }
2030 
2035  bool operator!=(const desc &other) const { return !operator==(other); }
2036 
2040  explicit operator bool() const { return data.ndims != 0; }
2041  };
2042 
2047  memory() = default;
2048 
2068  memory(const desc &md, const engine &aengine, void *handle) {
2069  dnnl_memory_t result;
2071  dnnl_memory_create(&result, &md.data, aengine.get(), handle),
2072  "could not create a memory object");
2073  reset(result);
2074  }
2075 
2082  memory(const desc &md, const engine &aengine)
2083  : memory(md, aengine, DNNL_MEMORY_ALLOCATE) {}
2084 
2086  desc get_desc() const {
2087  const dnnl_memory_desc_t *cdesc;
2089  "could not get a memory descriptor from a memory object");
2090  return desc(*cdesc);
2091  }
2092 
2094  engine get_engine() const {
2095  dnnl_engine_t c_engine;
2096  error::wrap_c_api(dnnl_memory_get_engine(get(), &c_engine),
2097  "could not get an engine from a memory object");
2098  return engine(c_engine, true);
2099  }
2100 
2105  void *get_data_handle() const {
2106  void *handle;
2108  "could not get a native handle from a memory object");
2109  return handle;
2110  }
2111 
2140  void set_data_handle(void *handle, const stream &astream) const {
2142  get(), handle, astream.get(true)),
2143  "could not set native handle of a memory object");
2144  }
2145 
2156  void set_data_handle(void *handle) const {
2158  dnnl_memory_set_data_handle_v2(get(), handle, nullptr),
2159  "could not set native handle of a memory object");
2160  }
2161 
2183  template <typename T = void>
2184  T *map_data() const {
2185  void *mapped_ptr;
2186  error::wrap_c_api(dnnl_memory_map_data(get(), &mapped_ptr),
2187  "could not map memory object data");
2188  return static_cast<T *>(mapped_ptr);
2189  }
2190 
2201  void unmap_data(void *mapped_ptr) const {
2202  error::wrap_c_api(dnnl_memory_unmap_data(get(), mapped_ptr),
2203  "could not unmap memory object data");
2204  }
2205 
2206  static dnnl_data_type_t convert_to_c(data_type adata_type) {
2207  return static_cast<dnnl_data_type_t>(adata_type);
2208  }
2209  static dnnl_format_tag_t convert_to_c(format_tag format) {
2210  return static_cast<dnnl_format_tag_t>(format);
2211  }
2212 };
2213 
2214 inline bool operator==(dnnl_data_type_t a, memory::data_type b) {
2215  return a == memory::convert_to_c(b);
2216 }
2217 inline bool operator!=(dnnl_data_type_t a, memory::data_type b) {
2218  return !(a == b);
2219 }
2220 inline bool operator==(memory::data_type a, dnnl_data_type_t b) {
2221  return b == a;
2222 }
2223 inline bool operator!=(memory::data_type a, dnnl_data_type_t b) {
2224  return !(a == b);
2225 }
2226 
2227 inline bool operator==(dnnl_format_tag_t a, memory::format_tag b) {
2228  return a == memory::convert_to_c(b);
2229 }
2230 inline bool operator!=(dnnl_format_tag_t a, memory::format_tag b) {
2231  return !(a == b);
2232 }
2233 inline bool operator==(memory::format_tag a, dnnl_format_tag_t b) {
2234  return b == a;
2235 }
2236 inline bool operator!=(memory::format_tag a, dnnl_format_tag_t b) {
2237  return !(a == b);
2238 }
2239 
2241 
2249 
2251 template <>
2252 struct handle_traits<dnnl_post_ops_t> {
2253  static dnnl_status_t destructor(dnnl_post_ops_t p) {
2254  return dnnl_post_ops_destroy(p);
2255  }
2256 };
2258 
2266 struct post_ops : public handle<dnnl_post_ops_t> {
2268 
2271  dnnl_post_ops_t result;
2273  dnnl_post_ops_create(&result), "could not create post-ops");
2274  reset(result);
2275  }
2276 
2278  int len() const { return dnnl_post_ops_len(get()); }
2279 
2283  primitive::kind kind(int index) const {
2285  "post-ops index is out of range");
2286  return static_cast<primitive::kind>(
2287  dnnl_post_ops_get_kind(get(), index));
2288  }
2289 
2318  void append_sum(float scale = 1.f,
2320  if (data_type == memory::data_type::undef)
2322  "could not append a sum post-op");
2323  else
2325  memory::convert_to_c(data_type)),
2326  "could not append a sum post-op");
2327  }
2328 
2333  void get_params_sum(int index, float &scale) const {
2334  error::wrap_c_api(dnnl_post_ops_get_params_sum(get(), index, &scale),
2335  "could not get parameters of a sum post-op");
2336  }
2337 
2344  int index, float &scale, memory::data_type &data_type) const {
2345  dnnl_data_type_t c_data_type;
2347  get(), index, &scale, &c_data_type),
2348  "could not get parameters of a sum post-op");
2349  data_type = static_cast<memory::data_type>(c_data_type);
2350  }
2351 
2366  float scale, algorithm aalgorithm, float alpha, float beta) {
2368  convert_to_c(aalgorithm), alpha, beta),
2369  "could not append an elementwise post-op");
2370  }
2371 
2379  void get_params_eltwise(int index, float &scale, algorithm &aalgorithm,
2380  float &alpha, float &beta) const {
2381  dnnl_alg_kind_t c_alg;
2383  get(), index, &scale, &c_alg, &alpha, &beta),
2384  "could not get parameters of an elementwise post-op");
2385  aalgorithm = static_cast<dnnl::algorithm>(c_alg);
2386  }
2387 
2416  void append_dw_k3s1p1(memory::data_type weights_data_type,
2417  memory::data_type bias_data_type, memory::data_type dst_data_type,
2418  int mask, const std::vector<float> &scales) {
2419 
2421  memory::convert_to_c(weights_data_type),
2422  memory::convert_to_c(bias_data_type),
2423  memory::convert_to_c(dst_data_type),
2424  scales.size(), mask, &scales[0]),
2425  "could not append depthwise post-op");
2426  }
2427 
2442  void get_params_dw_k3s1p1(int index, memory::data_type &weights_data_type,
2443  memory::data_type &bias_data_type, memory::data_type &dst_data_type,
2444  int &mask, std::vector<float> &scales) const {
2445 
2446  dnnl_data_type_t c_weights_data_type;
2447  dnnl_data_type_t c_bias_data_type;
2448  dnnl_data_type_t c_dst_data_type;
2449  dnnl_dim_t count;
2450  int c_mask;
2451  const float *c_scales;
2453  &c_weights_data_type, &c_bias_data_type,
2454  &c_dst_data_type, &count, &c_mask, &c_scales),
2455  "could not get parameters of depthwise post-op");
2456 
2457  weights_data_type = static_cast<memory::data_type>(c_weights_data_type);
2458  bias_data_type = static_cast<memory::data_type>(c_bias_data_type);
2459  dst_data_type = static_cast<memory::data_type>(c_dst_data_type);
2460  scales.resize(count);
2461 
2462  mask = c_mask;
2463  for (dnnl_dim_t c = 0; c < count; ++c)
2464  scales[c] = c_scales[c];
2465  return;
2466  }
2467 
2501  void append_dw_k3s2p1(memory::data_type weights_data_type,
2502  memory::data_type bias_data_type, memory::data_type dst_data_type,
2503  int mask, const std::vector<float> &scales) {
2504 
2506  memory::convert_to_c(weights_data_type),
2507  memory::convert_to_c(bias_data_type),
2508  memory::convert_to_c(dst_data_type),
2509  scales.size(), mask, &scales[0]),
2510  "could not append depthwise post-op");
2511  }
2512 
2527  void get_params_dw_k3s2p1(int index, memory::data_type &weights_data_type,
2528  memory::data_type &bias_data_type, memory::data_type &dst_data_type,
2529  int &mask, std::vector<float> &scales) const {
2530 
2531  dnnl_data_type_t c_weights_data_type;
2532  dnnl_data_type_t c_bias_data_type;
2533  dnnl_data_type_t c_dst_data_type;
2534  dnnl_dim_t count;
2535  int c_mask;
2536  const float *c_scales;
2538  &c_weights_data_type, &c_bias_data_type,
2539  &c_dst_data_type, &count, &c_mask, &c_scales),
2540  "could not get parameters of depthwise post-op");
2541 
2542  weights_data_type = static_cast<memory::data_type>(c_weights_data_type);
2543  bias_data_type = static_cast<memory::data_type>(c_bias_data_type);
2544  dst_data_type = static_cast<memory::data_type>(c_dst_data_type);
2545  scales.resize(count);
2546 
2547  mask = c_mask;
2548  for (dnnl_dim_t c = 0; c < count; ++c)
2549  scales[c] = c_scales[c];
2550  return;
2551  }
2552 
2567  void append_binary(algorithm aalgorithm, const memory::desc &src1_desc) {
2569  convert_to_c(aalgorithm), &src1_desc.data),
2570  "could not append a binary post-op");
2571  }
2572 
2579  int index, algorithm &aalgorithm, memory::desc &src1_desc) const {
2580  dnnl_alg_kind_t c_alg;
2581  const dnnl_memory_desc_t *data;
2583  dnnl_post_ops_get_params_binary(get(), index, &c_alg, &data),
2584  "could not get parameters of a binary post-op");
2585  aalgorithm = static_cast<dnnl::algorithm>(c_alg);
2586  src1_desc.data = *data;
2587  }
2588 };
2589 
2591 template <>
2592 struct handle_traits<dnnl_primitive_attr_t> {
2593  static dnnl_status_t destructor(dnnl_primitive_attr_t p) {
2594  return dnnl_primitive_attr_destroy(p);
2595  }
2596 };
2598 
2602 struct primitive_attr : public handle<dnnl_primitive_attr_t> {
2604 
2607  dnnl_primitive_attr_t result;
2609  "could not create primitive attribute");
2610  reset(result);
2611  }
2612 
2619  : handle<dnnl_primitive_attr_t>(attr) {}
2620 
2623  dnnl_scratchpad_mode_t result;
2626  "could not get scratchpad mode primitive attribute");
2627  return scratchpad_mode(result);
2628  }
2629 
2635  get(), dnnl::convert_to_c(mode)),
2636  "could not set scratchpad mode primitive attribute");
2637  }
2638 
2648  void get_output_scales(int &mask, std::vector<float> &scales) const {
2649  dnnl_dim_t count;
2650  int c_mask;
2651  const float *c_scales;
2653  get(), &count, &c_mask, &c_scales),
2654  "could not get output scales primitive attribute");
2655  scales.resize(count);
2656 
2657  mask = c_mask;
2658  for (dnnl_dim_t c = 0; c < count; ++c)
2659  scales[c] = c_scales[c];
2660  }
2661 
2704  void set_output_scales(int mask, const std::vector<float> &scales) {
2707  get(), (dnnl_dim_t)scales.size(), mask, scales.data()),
2708  "could not set output scales primitive attribute");
2709  }
2710 
2722  void get_scales(int arg, int &mask, std::vector<float> &scales) const {
2723  dnnl_dim_t count;
2724  int c_mask;
2725  const float *c_scales;
2727  get(), arg, &count, &c_mask, &c_scales),
2728  "could not get scales primitive attributes");
2729  scales.resize(count);
2730 
2731  mask = c_mask;
2732  for (dnnl_dim_t c = 0; c < count; ++c)
2733  scales[c] = c_scales[c];
2734  }
2735 
2752  void set_scales(int arg, int mask, const std::vector<float> &scales) {
2754  dnnl_primitive_attr_set_scales(get(), arg,
2755  (dnnl_dim_t)scales.size(), mask, scales.data()),
2756  "could not set scales primitive attribute");
2757  }
2758 
2770  int arg, int &mask, std::vector<int32_t> &zero_points) const {
2771  dnnl_dim_t count;
2772  int c_mask;
2773  const int32_t *c_zero_points;
2775  get(), arg, &count, &c_mask, &c_zero_points),
2776  "could not get zero points primitive attribute");
2777  zero_points.resize(count);
2778 
2779  mask = c_mask;
2780  for (dnnl_dim_t c = 0; c < count; ++c)
2781  zero_points[c] = c_zero_points[c];
2782  }
2783 
2805  int arg, int mask, const std::vector<int32_t> &zero_points) {
2807  (dnnl_dim_t)zero_points.size(), mask,
2808  zero_points.data()),
2809  "could not set zero points primitive attribute");
2810  }
2811 
2815  const post_ops get_post_ops() const {
2816  post_ops result;
2817  const_dnnl_post_ops_t c_result;
2819  "could not get post-ops primitive attribute");
2820  result.reset(const_cast<dnnl_post_ops_t>(c_result), true);
2821  return result;
2822  }
2823 
2832  void set_post_ops(const post_ops ops) {
2834  "could not set post-ops primitive attribute");
2835  }
2836 
2870  void set_rnn_data_qparams(float scale, float shift) {
2872  dnnl_primitive_attr_set_rnn_data_qparams(get(), scale, shift),
2873  "could not set RNN data quantization parameters primitive "
2874  "attribute");
2875  }
2876 
2886  void get_rnn_data_qparams(float &scale, float &shift) {
2887  float c_scale, c_shift;
2889  get(), &c_scale, &c_shift),
2890  "could not set RNN data quantization parameters primitive "
2891  "attribute");
2892  scale = c_scale;
2893  shift = c_shift;
2894  }
2895 
2922  void set_rnn_weights_qparams(int mask, const std::vector<float> &scales) {
2924  (int)scales.size(), mask, scales.data()),
2925  "could not set RNN weights quantization parameters primitive "
2926  "attribute");
2927  }
2928 
2948  void get_rnn_weights_qparams(int &mask, std::vector<float> &scales) {
2949  dnnl_dim_t count;
2950  int c_mask;
2951  const float *c_scales;
2953  get(), &count, &c_mask, &c_scales),
2954  "could not get primitive RNN weights quantization "
2955  "parameters attributes");
2956  scales.resize(count);
2957 
2958  mask = c_mask;
2959  for (dnnl_dim_t c = 0; c < count; c++)
2960  scales[c] = c_scales[c];
2961  }
2962 
2964  // The low-precision configuration of the RNN primitives expect input
2965  // weights to use the signed 8-bit integer data type. The scaling factors
2966  // are used to quantize floating-point data to signed integer and must be
2990  int mask, const std::vector<float> &scales) {
2993  get(), (int)scales.size(), mask, scales.data()),
2994  "could not set primitive RNN weights projection quantization "
2995  "parameters attributes");
2996  }
2997 
3018  int &mask, std::vector<float> &scales) {
3019  dnnl_dim_t count;
3020  int c_mask;
3021  const float *c_scales;
3024  get(), &count, &c_mask, &c_scales),
3025  "could not get primitive RNN weights projection quantization "
3026  "parameters attributes");
3027  scales.resize(count);
3028 
3029  mask = c_mask;
3030  for (dnnl_dim_t c = 0; c < count; c++)
3031  scales[c] = c_scales[c];
3032  }
3033 };
3034 
3036 
3039 
3041 struct primitive_desc_base : public handle<dnnl_primitive_desc_t> {
3043 
3045  primitive_desc_base() = default;
3046 
3049  engine get_engine() const { return engine::query(*this); }
3050 
3053  const char *impl_info_str() const {
3054  const char *res;
3056  get(), dnnl_query_impl_info_str, 0, &res),
3057  "could not retrieve implementation info string from a "
3058  "primitive descriptor");
3059  return res;
3060  }
3061 
3066  memory::dim res;
3068  get(), dnnl::convert_to_c(what), 0, &res);
3069  return status == dnnl_success ? res : 0;
3070  }
3071 
3086  memory::desc query_md(query what, int idx = 0) const {
3087  std::vector<query> valid_q {query::src_md, query::diff_src_md,
3091  if (!std::any_of(valid_q.cbegin(), valid_q.cend(),
3092  [=](query q) { return what == q; }))
3093  DNNL_THROW_ERROR(dnnl_invalid_arguments,
3094  "memory descriptor query is invalid");
3095 
3097  get(), dnnl::convert_to_c(what), idx);
3098  return cdesc ? memory::desc(*cdesc) : memory::desc();
3099  }
3100 
3106  memory::desc src_desc(int idx) const {
3107  return query_md(query::src_md, idx);
3108  }
3109 
3115  memory::desc dst_desc(int idx) const {
3116  return query_md(query::dst_md, idx);
3117  }
3118 
3124  memory::desc weights_desc(int idx) const {
3125  return query_md(query::weights_md, idx);
3126  }
3127 
3133  memory::desc diff_src_desc(int idx) const {
3134  return query_md(query::diff_src_md, idx);
3135  }
3136 
3142  memory::desc diff_dst_desc(int idx) const {
3143  return query_md(query::diff_dst_md, idx);
3144  }
3145 
3152  return query_md(query::diff_weights_md, idx);
3153  }
3154 
3155  // Separate versions without the index argument for documentation
3156  // purposes.
3157 
3162  memory::desc src_desc() const { return src_desc(0); }
3163 
3168  memory::desc dst_desc() const { return dst_desc(0); }
3169 
3174  memory::desc weights_desc() const { return weights_desc(0); }
3175 
3181 
3187 
3193 
3199  return query_md(query::workspace_md, 0);
3200  }
3201 
3208  return query_md(query::scratchpad_md, 0);
3209  }
3210 
3214  dnnl_engine_t c_engine;
3217  0, &c_engine),
3218  "could not retrieve scratchpad engine from a primitive "
3219  "descriptor");
3220  return engine(c_engine, true);
3221  }
3222 
3226  const_dnnl_primitive_attr_t const_c_attr;
3227  error::wrap_c_api(dnnl_primitive_desc_get_attr(get(), &const_c_attr),
3228  "could not get attributes from a primitive descriptor");
3229  dnnl_primitive_attr_t c_attr;
3230  error::wrap_c_api(dnnl_primitive_attr_clone(&c_attr, const_c_attr),
3231  "could not clone primitive attributes");
3232  return primitive_attr(c_attr);
3233  }
3234 
3238  dnnl_primitive_kind_t kind;
3240  dnnl_query_primitive_kind, 0, (void *)&kind),
3241  "could not get primitive kind from a primitive descriptor");
3242  return static_cast<dnnl::primitive::kind>(kind);
3243  }
3244 
3245 protected:
3250  dnnl_primitive_desc_t new_pd;
3252  "could not clone a primitive descriptor");
3253  reset(new_pd);
3254  }
3255 
3271  : primitive_desc_base(pd, prim_kind, dnnl::prop_kind::undef) {}
3272 
3285  dnnl::primitive::kind prim_kind, dnnl::prop_kind aprop_kind)
3286  : primitive_desc_base(pd, prim_kind, aprop_kind, aprop_kind) {}
3287 
3302  dnnl::primitive::kind prim_kind, dnnl::prop_kind prop_kind1,
3303  dnnl::prop_kind prop_kind2) {
3304  // It is OK to pass an empty primitive descriptor
3305  if (pd == nullptr) return;
3306 
3307  dnnl_status_t rc;
3308 
3309  dnnl_primitive_kind_t c_prim_kind = convert_to_c(prim_kind);
3310  dnnl_prop_kind_t c_prop_kind1 = convert_to_c(prop_kind1);
3311  dnnl_prop_kind_t c_prop_kind2 = convert_to_c(prop_kind2);
3312 
3313  // Check that primitive kind matches
3314  dnnl_primitive_kind_t pd_kind;
3316  pd, dnnl_query_primitive_kind, 0, (void *)&pd_kind);
3318  rc, "could not get primitive kind from a primitive descriptor");
3319  if (pd_kind != c_prim_kind)
3320  DNNL_THROW_ERROR(dnnl_invalid_arguments,
3321  "primitive descriptor operation kind mismatch");
3322 
3323  // Check that propagation kind matches
3324  dnnl_prop_kind_t pd_prop_kind;
3326  pd, dnnl_query_prop_kind, 0, (void *)&pd_prop_kind);
3327 
3328  // Something went wrong
3329  if (rc != dnnl_success && rc != dnnl_unimplemented)
3330  DNNL_THROW_ERROR(dnnl_invalid_arguments,
3331  "could not get propagation kind from the primitive "
3332  "descriptor");
3333 
3334  // Everything is fine
3335  if ((rc == dnnl_unimplemented && c_prop_kind1 == dnnl_prop_kind_undef)
3336  || (rc == dnnl_success
3337  && (pd_prop_kind == c_prop_kind1
3338  || pd_prop_kind == c_prop_kind2))) {
3339  reset_with_clone(pd);
3340  return;
3341  }
3342 
3343  // We could get the propagation kind but there is a mismatch
3344  DNNL_THROW_ERROR(dnnl_invalid_arguments,
3345  "primitive descriptor propagation kind mismatch");
3346  }
3347 
3348  using base = primitive_desc_base;
3349 };
3350 
3352 
3361 
3363 struct reorder : public primitive {
3367 
3369  primitive_desc() = default;
3370 
3388  primitive_desc(const engine &src_engine, const memory::desc &src_md,
3389  const engine &dst_engine, const memory::desc &dst_md,
3390  const primitive_attr &attr = primitive_attr(),
3391  bool allow_empty = false) {
3392  dnnl_primitive_desc_t result;
3394  &src_md.data, src_engine.get(), &dst_md.data,
3395  dst_engine.get(), attr.get());
3396  if (!allow_empty)
3398  "could not create a primitive descriptor for a reorder "
3399  "primitive");
3401  }
3402 
3414  primitive_desc(const memory &src, const memory &dst,
3415  const primitive_attr &attr = primitive_attr(),
3416  bool allow_empty = false) {
3417  dnnl_primitive_desc_t result;
3418  auto src_md = src.get_desc();
3419  auto dst_md = dst.get_desc();
3421  &src_md.data, src.get_engine().get(), &dst_md.data,
3422  dst.get_engine().get(), attr.get());
3423  if (!allow_empty)
3425  "could not create a primitive descriptor for a reorder "
3426  "primitive");
3428  }
3429 
3436 
3441  }
3442 
3447  }
3448 
3450  memory::desc src_desc() const { return base::src_desc(0); }
3451 
3453  memory::desc dst_desc() const { return base::dst_desc(0); }
3454  };
3455 
3457  reorder() = default;
3458 
3461  reorder(const primitive_desc &pd) : primitive(pd.get()) {}
3462 
3470  reorder(const memory &src, const memory &dst,
3471  const primitive_attr &attr = primitive_attr())
3472  : primitive(primitive_desc(src, dst, attr).get()) {}
3473 
3474  using primitive::execute;
3475 
3482  void execute(const stream &astream, memory &src, memory &dst) const {
3483  primitive::execute(astream, {{DNNL_ARG_FROM, src}, {DNNL_ARG_TO, dst}});
3484  }
3485 };
3486 
3488 
3496 
3498 inline std::vector<dnnl_memory_desc_t> convert_to_c(
3499  const std::vector<memory::desc> &mems) {
3500  std::vector<dnnl_memory_desc_t> c_mems;
3501  c_mems.reserve(mems.size());
3502  for (const auto &s : mems)
3503  c_mems.push_back(s.data);
3504  return c_mems;
3505 }
3507 
3509 struct concat : public primitive {
3513 
3515  primitive_desc() = default;
3516 
3527  primitive_desc(const memory::desc &dst, int concat_dimension,
3528  const std::vector<memory::desc> &srcs, const engine &aengine,
3529  const primitive_attr &attr = primitive_attr()) {
3530  auto c_srcs = convert_to_c(srcs);
3531 
3532  dnnl_primitive_desc_t result;
3535  (int)c_srcs.size(), concat_dimension, c_srcs.data(),
3536  attr.get(), aengine.get()),
3537  "could not create a primitive descriptor for a concat "
3538  "primitive");
3539  reset(result);
3540  }
3541 
3554  primitive_desc(int concat_dimension,
3555  const std::vector<memory::desc> &srcs, const engine &aengine,
3556  const primitive_attr &attr = primitive_attr()) {
3557  auto c_api_srcs = convert_to_c(srcs);
3558 
3559  dnnl_primitive_desc_t result;
3561  dnnl_concat_primitive_desc_create(&result, nullptr,
3562  (int)c_api_srcs.size(), concat_dimension,
3563  c_api_srcs.data(), attr.get(), aengine.get()),
3564  "could not create a primitive descriptor for a concat "
3565  "primitive");
3566  reset(result);
3567  }
3568 
3575 
3577  memory::desc src_desc(int idx = 0) const { return base::src_desc(idx); }
3578 
3580  memory::desc dst_desc() const { return base::dst_desc(0); }
3581  };
3582 
3584  concat() = default;
3585 
3588  concat(const primitive_desc &pd) : primitive(pd.get()) {}
3589 };
3590 
3592 
3600 
3602 struct sum : public primitive {
3606 
3608  primitive_desc() = default;
3609 
3619  const std::vector<float> &scales,
3620  const std::vector<memory::desc> &srcs, const engine &aengine,
3621  const primitive_attr &attr = primitive_attr()) {
3622  validate_container_size(scales,
3623  "counts of scales and sources are not equal",
3624  (int)srcs.size(), (int)srcs.size());
3625 
3626  auto c_api_srcs = convert_to_c(srcs);
3627 
3628  dnnl_primitive_desc_t result;
3630  dnnl_sum_primitive_desc_create(&result, &dst.data,
3631  (int)c_api_srcs.size(), scales.data(),
3632  c_api_srcs.data(), attr.get(), aengine.get()),
3633  "could not create a primitive descriptor for a sum "
3634  "primitive");
3635  reset(result);
3636  }
3637 
3648  primitive_desc(const std::vector<float> &scales,
3649  const std::vector<memory::desc> &srcs, const engine &aengine,
3650  const primitive_attr &attr = primitive_attr()) {
3651  validate_container_size(scales,
3652  "counts of scales and sources are not equal",
3653  (int)srcs.size(), (int)srcs.size());
3654 
3655  auto c_api_srcs = convert_to_c(srcs);
3656  dnnl_primitive_desc_t result;
3658  dnnl_sum_primitive_desc_create(&result, nullptr,
3659  (int)c_api_srcs.size(), scales.data(),
3660  c_api_srcs.data(), attr.get(), aengine.get()),
3661  "could not create a primitive descriptor for a sum "
3662  "primitive");
3663  reset(result);
3664  }
3665 
3672 
3674  memory::desc src_desc(int idx = 0) const { return base::src_desc(idx); }
3675 
3677  memory::desc dst_desc() const { return base::dst_desc(0); }
3678  };
3679 
3681  sum() = default;
3682 
3685  sum(const primitive_desc &pd) : primitive(pd.get()) {}
3686 };
3687 
3689 
3692 
3697 
3698  primitive_desc() = default;
3699 
3723  const engine &aengine, const_dnnl_primitive_desc_t hint_fwd_pd,
3724  bool allow_empty = false)
3725  : allow_empty_(allow_empty) {
3726  dnnl_primitive_desc_iterator_t iterator = nullptr;
3728  desc, attr ? attr->get() : nullptr, aengine.get(), hint_fwd_pd);
3729  if (!allow_empty)
3731  status, "could not create a primitive descriptor iterator");
3732  pd_iterator.reset(iterator);
3733  fetch_impl();
3734  }
3735 
3740  bool next_impl() {
3742  = dnnl_primitive_desc_iterator_next(pd_iterator.get());
3743  if (status == dnnl_iterator_ends) return false;
3745  status, "could not advance a primitive descriptor iterator");
3746  fetch_impl();
3747  return true;
3748  }
3749 
3750 private:
3751  bool allow_empty_ = false;
3753  void fetch_impl() {
3755  pd_iterator.get(allow_empty_));
3756  error::wrap_c_api(pd != nullptr || allow_empty_ ? dnnl_success
3758  "could not fetch a primitive descriptor from a primitive "
3759  "descriptor iterator");
3760  reset(pd);
3761  }
3762 };
3763 
3765 
3775 
3779  struct desc {
3781 
3812  desc(prop_kind aprop_kind, algorithm aalgorithm,
3813  const memory::desc &src_desc, const memory::desc &weights_desc,
3814  const memory::desc &bias_desc, const memory::desc &dst_desc,
3815  const memory::dims &strides, const memory::dims &padding_l,
3816  const memory::dims &padding_r) {
3817  memory::validate_dims(strides, src_desc.data.ndims - 2);
3818  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
3819  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
3822  dnnl::convert_to_c(aprop_kind),
3823  convert_to_c(aalgorithm), &src_desc.data,
3824  &weights_desc.data, &bias_desc.data, &dst_desc.data,
3825  &strides[0], &padding_l[0], &padding_r[0]),
3826  "could not create a descriptor for a convolution forward "
3827  "propagation primitive");
3828  }
3829 
3858  desc(prop_kind aprop_kind, algorithm aalgorithm,
3859  const memory::desc &src_desc, const memory::desc &weights_desc,
3860  const memory::desc &dst_desc, const memory::dims &strides,
3861  const memory::dims &padding_l, const memory::dims &padding_r) {
3862  memory::validate_dims(strides, src_desc.data.ndims - 2);
3863  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
3864  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
3867  dnnl::convert_to_c(aprop_kind),
3868  convert_to_c(aalgorithm), &src_desc.data,
3869  &weights_desc.data, nullptr, &dst_desc.data,
3870  &strides[0], &padding_l[0], &padding_r[0]),
3871  "could not create a descriptor for a convolution forward "
3872  "propagation primitive");
3873  }
3874 
3907  desc(prop_kind aprop_kind, algorithm aalgorithm,
3908  const memory::desc &src_desc, const memory::desc &weights_desc,
3909  const memory::desc &bias_desc, const memory::desc &dst_desc,
3910  const memory::dims &strides, const memory::dims &dilates,
3911  const memory::dims &padding_l, const memory::dims &padding_r) {
3912  memory::validate_dims(strides, src_desc.data.ndims - 2);
3913  memory::validate_dims(dilates, src_desc.data.ndims - 2);
3914  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
3915  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
3917  dnnl::convert_to_c(aprop_kind),
3918  convert_to_c(aalgorithm), &src_desc.data,
3919  &weights_desc.data, &bias_desc.data,
3920  &dst_desc.data, &strides[0], &dilates[0],
3921  &padding_l[0], &padding_r[0]),
3922  "could not create a descriptor for a dilated convolution "
3923  "forward propagation primitive");
3924  }
3925 
3956  desc(prop_kind aprop_kind, algorithm aalgorithm,
3957  const memory::desc &src_desc, const memory::desc &weights_desc,
3958  const memory::desc &dst_desc, const memory::dims &strides,
3959  const memory::dims &dilates, const memory::dims &padding_l,
3960  const memory::dims &padding_r) {
3961  memory::validate_dims(strides, src_desc.data.ndims - 2);
3962  memory::validate_dims(dilates, src_desc.data.ndims - 2);
3963  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
3964  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
3966  dnnl::convert_to_c(aprop_kind),
3967  convert_to_c(aalgorithm), &src_desc.data,
3968  &weights_desc.data, nullptr,
3969  &dst_desc.data, &strides[0], &dilates[0],
3970  &padding_l[0], &padding_r[0]),
3971  "could not create a descriptor for a dilated convolution "
3972  "forward propagation primitive");
3973  }
3974  };
3975 
3979  primitive_desc() = default;
3980 
3991  primitive_desc(const desc &adesc, const engine &aengine,
3992  bool allow_empty = false)
3993  : dnnl::primitive_desc(
3994  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
3995 
4007  primitive_desc(const desc &adesc, const primitive_attr &attr,
4008  const engine &aengine, bool allow_empty = false)
4009  : dnnl::primitive_desc(
4010  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
4011 
4019  : dnnl::primitive_desc(pd, dnnl::primitive::kind::convolution,
4022 
4024  memory::desc src_desc() const { return base::src_desc(0); }
4025 
4028 
4030  memory::desc dst_desc() const { return base::dst_desc(0); }
4031 
4037  };
4038 
4040  convolution_forward() = default;
4041 
4046 };
4047 
4050 
4052  struct desc {
4054 
4080  desc(algorithm aalgorithm, const memory::desc &diff_src_desc,
4081  const memory::desc &weights_desc,
4082  const memory::desc &diff_dst_desc, const memory::dims &strides,
4083  const memory::dims &padding_l, const memory::dims &padding_r) {
4084  memory::validate_dims(strides, diff_src_desc.data.ndims - 2);
4085  memory::validate_dims(padding_l, diff_src_desc.data.ndims - 2);
4086  memory::validate_dims(padding_r, diff_src_desc.data.ndims - 2);
4089  convert_to_c(aalgorithm), &diff_src_desc.data,
4090  &weights_desc.data, &diff_dst_desc.data,
4091  &strides[0], &padding_l[0], &padding_r[0]),
4092  "could not create a descriptor for a convolution backward "
4093  "propagation primitive");
4094  }
4095 
4123  desc(algorithm aalgorithm, const memory::desc &diff_src_desc,
4124  const memory::desc &weights_desc,
4125  const memory::desc &diff_dst_desc, const memory::dims &strides,
4126  const memory::dims &dilates, const memory::dims &padding_l,
4127  const memory::dims &padding_r) {
4128  memory::validate_dims(strides, diff_src_desc.data.ndims - 2);
4129  memory::validate_dims(dilates, diff_src_desc.data.ndims - 2);
4130  memory::validate_dims(padding_l, diff_src_desc.data.ndims - 2);
4131  memory::validate_dims(padding_r, diff_src_desc.data.ndims - 2);
4134  convert_to_c(aalgorithm), &diff_src_desc.data,
4135  &weights_desc.data, &diff_dst_desc.data,
4136  &strides[0], &dilates[0], &padding_l[0],
4137  &padding_r[0]),
4138  "could not create a descriptor for a dilated convolution "
4139  "backward propagation primitive");
4140  }
4141  };
4142 
4146  primitive_desc() = default;
4147 
4161  primitive_desc(const desc &adesc, const engine &aengine,
4162  const convolution_forward::primitive_desc &hint_fwd_pd,
4163  bool allow_empty = false)
4164  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
4165  hint_fwd_pd.get(), allow_empty) {}
4166 
4181  primitive_desc(const desc &adesc, const primitive_attr &attr,
4182  const engine &aengine,
4183  const convolution_forward::primitive_desc &hint_fwd_pd,
4184  bool allow_empty = false)
4185  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
4186  hint_fwd_pd.get(), allow_empty) {}
4187 
4195  : dnnl::primitive_desc(pd, dnnl::primitive::kind::convolution,
4197 
4200 
4203 
4206  };
4207 
4209  convolution_backward_data() = default;
4210 
4215 };
4216 
4220  struct desc {
4222 
4250  desc(algorithm aalgorithm, const memory::desc &src_desc,
4251  const memory::desc &diff_weights_desc,
4252  const memory::desc &diff_bias_desc,
4253  const memory::desc &diff_dst_desc, const memory::dims &strides,
4254  const memory::dims &padding_l, const memory::dims &padding_r) {
4255  memory::validate_dims(strides, src_desc.data.ndims - 2);
4256  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4257  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4260  convert_to_c(aalgorithm), &src_desc.data,
4261  &diff_weights_desc.data, &diff_bias_desc.data,
4262  &diff_dst_desc.data, &strides[0], &padding_l[0],
4263  &padding_r[0]),
4264  "could not create a descriptor for a convolution weights "
4265  "update primitive");
4266  }
4267 
4293  desc(algorithm aalgorithm, const memory::desc &src_desc,
4294  const memory::desc &diff_weights_desc,
4295  const memory::desc &diff_dst_desc, const memory::dims &strides,
4296  const memory::dims &padding_l, const memory::dims &padding_r) {
4297  memory::validate_dims(strides, src_desc.data.ndims - 2);
4298  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4299  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4301  convert_to_c(aalgorithm), &src_desc.data,
4302  &diff_weights_desc.data, nullptr,
4303  &diff_dst_desc.data, &strides[0],
4304  &padding_l[0], &padding_r[0]),
4305  "could not create a descriptor for a convolution weights "
4306  "update primitive");
4307  }
4308 
4338  desc(algorithm aalgorithm, const memory::desc &src_desc,
4339  const memory::desc &diff_weights_desc,
4340  const memory::desc &diff_bias_desc,
4341  const memory::desc &diff_dst_desc, const memory::dims &strides,
4342  const memory::dims &dilates, const memory::dims &padding_l,
4343  const memory::dims &padding_r) {
4344  memory::validate_dims(strides, src_desc.data.ndims - 2);
4345  memory::validate_dims(dilates, src_desc.data.ndims - 2);
4346  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4347  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4350  convert_to_c(aalgorithm), &src_desc.data,
4351  &diff_weights_desc.data, &diff_bias_desc.data,
4352  &diff_dst_desc.data, &strides[0], &dilates[0],
4353  &padding_l[0], &padding_r[0]),
4354  "could not create a descriptor for a dilated convolution "
4355  "weights gradient primitive");
4356  }
4357 
4385  desc(algorithm aalgorithm, const memory::desc &src_desc,
4386  const memory::desc &diff_weights_desc,
4387  const memory::desc &diff_dst_desc, const memory::dims &strides,
4388  const memory::dims &dilates, const memory::dims &padding_l,
4389  const memory::dims &padding_r) {
4390  memory::validate_dims(strides, src_desc.data.ndims - 2);
4391  memory::validate_dims(dilates, src_desc.data.ndims - 2);
4392  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4393  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4396  convert_to_c(aalgorithm), &src_desc.data,
4397  &diff_weights_desc.data, nullptr,
4398  &diff_dst_desc.data, &strides[0], &dilates[0],
4399  &padding_l[0], &padding_r[0]),
4400  "could not create a descriptor for a dilated convolution "
4401  "weights gradient primitive");
4402  }
4403  };
4404 
4408  primitive_desc() = default;
4409 
4422  primitive_desc(const desc &adesc, const engine &aengine,
4423  const convolution_forward::primitive_desc &hint_fwd_pd,
4424  bool allow_empty = false)
4425  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
4426  hint_fwd_pd.get(), allow_empty) {}
4427 
4441  primitive_desc(const desc &adesc, const primitive_attr &attr,
4442  const engine &aengine,
4443  const convolution_forward::primitive_desc &hint_fwd_pd,
4444  bool allow_empty = false)
4445  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
4446  hint_fwd_pd.get(), allow_empty) {}
4447 
4455  : dnnl::primitive_desc(pd, dnnl::primitive::kind::convolution,
4457 
4459  memory::desc src_desc() const { return base::src_desc(0); }
4460 
4463  return base::diff_weights_desc(0);
4464  }
4465 
4468 
4474  return base::diff_weights_desc(1);
4475  }
4476  };
4477 
4479  convolution_backward_weights() = default;
4480 
4485 };
4486 
4488 //
4496 
4500  struct desc {
4502 
4532  desc(prop_kind aprop_kind, algorithm aalgorithm,
4533  const memory::desc &src_desc, const memory::desc &weights_desc,
4534  const memory::desc &bias_desc, const memory::desc &dst_desc,
4535  const memory::dims &strides, const memory::dims &padding_l,
4536  const memory::dims &padding_r) {
4537  memory::validate_dims(strides, src_desc.data.ndims - 2);
4538  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4539  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4542  dnnl::convert_to_c(aprop_kind),
4543  convert_to_c(aalgorithm), &src_desc.data,
4544  &weights_desc.data, &bias_desc.data, &dst_desc.data,
4545  &strides[0], &padding_l[0], &padding_r[0]),
4546  "could not create a descriptor for a deconvolution forward "
4547  "propagation primitive");
4548  }
4549 
4577  desc(prop_kind aprop_kind, algorithm aalgorithm,
4578  const memory::desc &src_desc, const memory::desc &weights_desc,
4579  const memory::desc &dst_desc, const memory::dims &strides,
4580  const memory::dims &padding_l, const memory::dims &padding_r) {
4581  memory::validate_dims(strides, src_desc.data.ndims - 2);
4582  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4583  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4586  dnnl::convert_to_c(aprop_kind),
4587  convert_to_c(aalgorithm), &src_desc.data,
4588  &weights_desc.data, nullptr, &dst_desc.data,
4589  &strides[0], &padding_l[0], &padding_r[0]),
4590  "could not create a descriptor for a deconvolution forward "
4591  "propagation primitive");
4592  }
4593 
4625  desc(prop_kind aprop_kind, algorithm aalgorithm,
4626  const memory::desc &src_desc, const memory::desc &weights_desc,
4627  const memory::desc &bias_desc, const memory::desc &dst_desc,
4628  const memory::dims &strides, const memory::dims &dilates,
4629  const memory::dims &padding_l, const memory::dims &padding_r) {
4630  memory::validate_dims(strides, src_desc.data.ndims - 2);
4631  memory::validate_dims(dilates, src_desc.data.ndims - 2);
4632  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4633  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4635  &data, dnnl::convert_to_c(aprop_kind),
4636  convert_to_c(aalgorithm), &src_desc.data,
4637  &weights_desc.data, &bias_desc.data,
4638  &dst_desc.data, &strides[0], &dilates[0],
4639  &padding_l[0], &padding_r[0]),
4640  "could not create a descriptor for a dilated deconvolution "
4641  "forward propagation primitive");
4642  }
4643 
4673  desc(prop_kind aprop_kind, algorithm aalgorithm,
4674  const memory::desc &src_desc, const memory::desc &weights_desc,
4675  const memory::desc &dst_desc, const memory::dims &strides,
4676  const memory::dims &dilates, const memory::dims &padding_l,
4677  const memory::dims &padding_r) {
4678  memory::validate_dims(strides, src_desc.data.ndims - 2);
4679  memory::validate_dims(dilates, src_desc.data.ndims - 2);
4680  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4681  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4683  &data, dnnl::convert_to_c(aprop_kind),
4684  convert_to_c(aalgorithm), &src_desc.data,
4685  &weights_desc.data, nullptr,
4686  &dst_desc.data, &strides[0], &dilates[0],
4687  &padding_l[0], &padding_r[0]),
4688  "could not create a descriptor for a dilated deconvolution "
4689  "forward propagation primitive");
4690  }
4691  };
4692 
4696  primitive_desc() = default;
4697 
4708  primitive_desc(const desc &adesc, const engine &aengine,
4709  bool allow_empty = false)
4710  : dnnl::primitive_desc(
4711  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
4712 
4724  primitive_desc(const desc &adesc, const primitive_attr &attr,
4725  const engine &aengine, bool allow_empty = false)
4726  : dnnl::primitive_desc(
4727  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
4728 
4736  : dnnl::primitive_desc(pd, dnnl::primitive::kind::deconvolution,
4739 
4741  memory::desc src_desc() const { return base::src_desc(0); }
4742 
4745 
4747  memory::desc dst_desc() const { return base::dst_desc(0); }
4748 
4751  };
4752 
4754  deconvolution_forward() = default;
4755 
4760 };
4761 
4765  struct desc {
4767 
4792  desc(algorithm aalgorithm, const memory::desc &diff_src_desc,
4793  const memory::desc &weights_desc,
4794  const memory::desc &diff_dst_desc, const memory::dims &strides,
4795  const memory::dims &padding_l, const memory::dims &padding_r) {
4796  memory::validate_dims(strides, diff_src_desc.data.ndims - 2);
4797  memory::validate_dims(padding_l, diff_src_desc.data.ndims - 2);
4798  memory::validate_dims(padding_r, diff_src_desc.data.ndims - 2);
4801  convert_to_c(aalgorithm), &diff_src_desc.data,
4802  &weights_desc.data, &diff_dst_desc.data,
4803  &strides[0], &padding_l[0], &padding_r[0]),
4804  "could not create a descriptor for a deconvolution "
4805  "backward propagation primitive");
4806  }
4807 
4834  desc(algorithm aalgorithm, const memory::desc &diff_src_desc,
4835  const memory::desc &weights_desc,
4836  const memory::desc &diff_dst_desc, const memory::dims &strides,
4837  const memory::dims &dilates, const memory::dims &padding_l,
4838  const memory::dims &padding_r) {
4839  memory::validate_dims(strides, diff_src_desc.data.ndims - 2);
4840  memory::validate_dims(dilates, diff_src_desc.data.ndims - 2);
4841  memory::validate_dims(padding_l, diff_src_desc.data.ndims - 2);
4842  memory::validate_dims(padding_r, diff_src_desc.data.ndims - 2);
4845  convert_to_c(aalgorithm), &diff_src_desc.data,
4846  &weights_desc.data, &diff_dst_desc.data,
4847  &strides[0], &dilates[0], &padding_l[0],
4848  &padding_r[0]),
4849  "could not create a descriptor for a dilated deconvolution "
4850  "backward propagation primitive");
4851  }
4852  };
4853 
4857  primitive_desc() = default;
4858 
4872  primitive_desc(const desc &adesc, const engine &aengine,
4873  const deconvolution_forward::primitive_desc &hint_fwd_pd,
4874  bool allow_empty = false)
4875  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
4876  hint_fwd_pd.get(), allow_empty) {}
4877 
4892  primitive_desc(const desc &adesc, const primitive_attr &attr,
4893  const engine &aengine,
4894  const deconvolution_forward::primitive_desc &hint_fwd_pd,
4895  bool allow_empty = false)
4896  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
4897  hint_fwd_pd.get(), allow_empty) {}
4898 
4906  : dnnl::primitive_desc(pd, dnnl::primitive::kind::deconvolution,
4908 
4911 
4914 
4917  };
4918 
4920  deconvolution_backward_data() = default;
4921 
4926 };
4927 
4931  struct desc {
4933 
4960  desc(algorithm aalgorithm, const memory::desc &src_desc,
4961  const memory::desc &diff_weights_desc,
4962  const memory::desc &diff_bias_desc,
4963  const memory::desc &diff_dst_desc, const memory::dims &strides,
4964  const memory::dims &padding_l, const memory::dims &padding_r) {
4965  memory::validate_dims(strides, src_desc.data.ndims - 2);
4966  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
4967  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
4970  convert_to_c(aalgorithm), &src_desc.data,
4971  &diff_weights_desc.data, &diff_bias_desc.data,
4972  &diff_dst_desc.data, &strides[0], &padding_l[0],
4973  &padding_r[0]),
4974  "could not create a descriptor for a deconvolution weights "
4975  "update primitive");
4976  }
4977 
5002  desc(algorithm aalgorithm, const memory::desc &src_desc,
5003  const memory::desc &diff_weights_desc,
5004  const memory::desc &diff_dst_desc, const memory::dims &strides,
5005  const memory::dims &padding_l, const memory::dims &padding_r) {
5006  memory::validate_dims(strides, src_desc.data.ndims - 2);
5007  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
5008  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
5010  &data, convert_to_c(aalgorithm),
5011  &src_desc.data, &diff_weights_desc.data,
5012  nullptr, &diff_dst_desc.data, &strides[0],
5013  &padding_l[0], &padding_r[0]),
5014  "could not create a descriptor for a deconvolution weights "
5015  "update primitive");
5016  }
5017 
5046  desc(algorithm aalgorithm, const memory::desc &src_desc,
5047  const memory::desc &diff_weights_desc,
5048  const memory::desc &diff_bias_desc,
5049  const memory::desc &diff_dst_desc, const memory::dims &strides,
5050  const memory::dims &dilates, const memory::dims &padding_l,
5051  const memory::dims &padding_r) {
5052  memory::validate_dims(strides, src_desc.data.ndims - 2);
5053  memory::validate_dims(dilates, src_desc.data.ndims - 2);
5054  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
5055  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
5058  convert_to_c(aalgorithm), &src_desc.data,
5059  &diff_weights_desc.data, &diff_bias_desc.data,
5060  &diff_dst_desc.data, &strides[0], &dilates[0],
5061  &padding_l[0], &padding_r[0]),
5062  "could not create a descriptor for a dilated deconvolution "
5063  "weights gradient primitive");
5064  }
5065 
5092  desc(algorithm aalgorithm, const memory::desc &src_desc,
5093  const memory::desc &diff_weights_desc,
5094  const memory::desc &diff_dst_desc, const memory::dims &strides,
5095  const memory::dims &dilates, const memory::dims &padding_l,
5096  const memory::dims &padding_r) {
5097  memory::validate_dims(strides, src_desc.data.ndims - 2);
5098  memory::validate_dims(dilates, src_desc.data.ndims - 2);
5099  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
5100  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
5103  convert_to_c(aalgorithm), &src_desc.data,
5104  &diff_weights_desc.data, nullptr,
5105  &diff_dst_desc.data, &strides[0], &dilates[0],
5106  &padding_l[0], &padding_r[0]),
5107  "could not create a descriptor for a dilated deconvolution "
5108  "weights gradient primitive");
5109  }
5110  };
5111 
5115  primitive_desc() = default;
5116 
5130  primitive_desc(const desc &adesc, const engine &aengine,
5131  const deconvolution_forward::primitive_desc &hint_fwd_pd,
5132  bool allow_empty = false)
5133  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
5134  hint_fwd_pd.get(), allow_empty) {}
5135 
5150  primitive_desc(const desc &adesc, const primitive_attr &attr,
5151  const engine &aengine,
5152  const deconvolution_forward::primitive_desc &hint_fwd_pd,
5153  bool allow_empty = false)
5154  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
5155  hint_fwd_pd.get(), allow_empty) {}
5156 
5164  : dnnl::primitive_desc(pd, dnnl::primitive::kind::deconvolution,
5166 
5168  memory::desc src_desc() const { return base::src_desc(0); }
5169 
5172  return base::diff_weights_desc(0);
5173  }
5174 
5177 
5180  return base::diff_weights_desc(1);
5181  }
5182  };
5183 
5185  deconvolution_backward_weights() = default;
5186 
5191 };
5192 
5194 
5203 
5205 struct lrn_forward : public primitive {
5207  struct desc {
5208  dnnl_lrn_desc_t data;
5209 
5223  desc(prop_kind aprop_kind, algorithm aalgorithm,
5224  const memory::desc &data_desc, memory::dim local_size,
5225  float alpha, float beta, float k = 1.f) {
5227  dnnl::convert_to_c(aprop_kind),
5228  convert_to_c(aalgorithm), &data_desc.data,
5229  local_size, alpha, beta, k),
5230  "could not create a descriptor for a lrn forward "
5231  "propagation primitive");
5232  }
5233  };
5234 
5238  primitive_desc() = default;
5239 
5249  primitive_desc(const desc &adesc, const engine &aengine,
5250  bool allow_empty = false)
5251  : dnnl::primitive_desc(
5252  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
5253 
5264  primitive_desc(const desc &adesc, const primitive_attr &attr,
5265  const engine &aengine, bool allow_empty = false)
5266  : dnnl::primitive_desc(
5267  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
5268 
5276  : dnnl::primitive_desc(pd, dnnl::primitive::kind::lrn,
5279 
5281  memory::desc src_desc() const { return base::src_desc(0); }
5282 
5284  memory::desc dst_desc() const { return base::dst_desc(0); }
5285 
5288  };
5289 
5291  lrn_forward() = default;
5292 
5297 };
5298 
5300 struct lrn_backward : public primitive {
5302  struct desc {
5303  dnnl_lrn_desc_t data;
5304 
5317  desc(algorithm aalgorithm, const memory::desc &data_desc,
5318  const memory::desc &diff_data_desc, memory::dim local_size,
5319  float alpha, float beta, float k = 1.f) {
5321  dnnl_lrn_backward_desc_init(&data, convert_to_c(aalgorithm),
5322  &diff_data_desc.data, &data_desc.data, local_size,
5323  alpha, beta, k),
5324  "could not create a descriptor for a lrn backward "
5325  "propagation primitive");
5326  }
5327  };
5328 
5332  primitive_desc() = default;
5333 
5346  primitive_desc(const desc &adesc, const engine &aengine,
5347  const lrn_forward::primitive_desc &hint_fwd_pd,
5348  bool allow_empty = false)
5349  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
5350  hint_fwd_pd.get(), allow_empty) {}
5351 
5365  primitive_desc(const desc &adesc, const primitive_attr &attr,
5366  const engine &aengine,
5367  const lrn_forward::primitive_desc &hint_fwd_pd,
5368  bool allow_empty = false)
5369  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
5370  hint_fwd_pd.get(), allow_empty) {}
5371 
5379  : dnnl::primitive_desc(pd, dnnl::primitive::kind::lrn,
5381 
5384 
5387 
5390  };
5391 
5393  lrn_backward() = default;
5394 
5399 };
5400 
5402 
5410 
5412 struct pooling_forward : public primitive {
5414  struct desc {
5415  dnnl_pooling_desc_t data;
5416 
5441  desc(prop_kind aprop_kind, algorithm aalgorithm,
5442  const memory::desc &src_desc, const memory::desc &dst_desc,
5443  const memory::dims &strides, const memory::dims &kernel,
5444  const memory::dims &padding_l, const memory::dims &padding_r) {
5445  memory::validate_dims(strides, src_desc.data.ndims - 2);
5446  memory::validate_dims(kernel, src_desc.data.ndims - 2);
5447  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
5448  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
5450  dnnl::convert_to_c(aprop_kind),
5451  convert_to_c(aalgorithm), &src_desc.data,
5452  &dst_desc.data, &strides[0], &kernel[0],
5453  &padding_l[0], &padding_r[0]),
5454  "could not create a descriptor for a pooling forward "
5455  "propagation primitive");
5456  }
5457  };
5458 
5462  primitive_desc() = default;
5463 
5473  primitive_desc(const desc &adesc, const engine &aengine,
5474  bool allow_empty = false)
5475  : dnnl::primitive_desc(
5476  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
5477 
5488  primitive_desc(const desc &adesc, const primitive_attr &attr,
5489  const engine &aengine, bool allow_empty = false)
5490  : dnnl::primitive_desc(
5491  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
5492 
5500  : dnnl::primitive_desc(pd, dnnl::primitive::kind::pooling,
5503 
5505  memory::desc src_desc() const { return base::src_desc(0); }
5506 
5508  memory::desc dst_desc() const { return base::dst_desc(0); }
5509 
5512  };
5513 
5515  pooling_forward() = default;
5516 
5521 };
5522 
5524 struct pooling_backward : public primitive {
5526  struct desc {
5527  dnnl_pooling_desc_t data;
5528 
5550  desc(algorithm aalgorithm, const memory::desc &diff_src_desc,
5551  const memory::desc &diff_dst_desc, const memory::dims &strides,
5552  const memory::dims &kernel, const memory::dims &padding_l,
5553  const memory::dims &padding_r) {
5554  memory::validate_dims(strides, diff_src_desc.data.ndims - 2);
5555  memory::validate_dims(kernel, diff_src_desc.data.ndims - 2);
5556  memory::validate_dims(padding_l, diff_src_desc.data.ndims - 2);
5557  memory::validate_dims(padding_r, diff_src_desc.data.ndims - 2);
5560  convert_to_c(aalgorithm), &diff_src_desc.data,
5561  &diff_dst_desc.data, &strides[0], &kernel[0],
5562  &padding_l[0], &padding_r[0]),
5563  "could not create a descriptor for a pooling backward "
5564  "propagation primitive");
5565  }
5566  };
5567 
5571  primitive_desc() = default;
5572 
5585  primitive_desc(const desc &adesc, const engine &aengine,
5586  const pooling_forward::primitive_desc &hint_fwd_pd,
5587  bool allow_empty = false)
5588  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
5589  hint_fwd_pd.get(), allow_empty) {}
5590 
5604  primitive_desc(const desc &adesc, const primitive_attr &attr,
5605  const engine &aengine,
5606  const pooling_forward::primitive_desc &hint_fwd_pd,
5607  bool allow_empty = false)
5608  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
5609  hint_fwd_pd.get(), allow_empty) {}
5610 
5618  : dnnl::primitive_desc(pd, dnnl::primitive::kind::pooling,
5620 
5623 
5626 
5629  };
5630 
5632  pooling_backward() = default;
5633 
5638 };
5639 
5641 
5662 
5664 struct eltwise_forward : public primitive {
5666  struct desc {
5667  dnnl_eltwise_desc_t data;
5668 
5681  desc(prop_kind aprop_kind, algorithm aalgorithm,
5682  const memory::desc &data_desc, float alpha = 0,
5683  float beta = 0) {
5685  dnnl::convert_to_c(aprop_kind),
5686  dnnl::convert_to_c(aalgorithm),
5687  &data_desc.data, alpha, beta),
5688  "could not create a descriptor for an eltwise forward "
5689  "propagation primitive");
5690  }
5691  };
5692 
5696  primitive_desc() = default;
5697 
5708  primitive_desc(const desc &adesc, const engine &aengine,
5709  bool allow_empty = false)
5710  : dnnl::primitive_desc(
5711  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
5712 
5724  primitive_desc(const desc &adesc, const primitive_attr &attr,
5725  const engine &aengine, bool allow_empty = false)
5726  : dnnl::primitive_desc(
5727  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
5728 
5736  : dnnl::primitive_desc(pd, dnnl::primitive::kind::eltwise,
5739 
5741  memory::desc src_desc() const { return base::src_desc(0); }
5742 
5744  memory::desc dst_desc() const { return base::dst_desc(0); }
5745  };
5746 
5748  eltwise_forward() = default;
5749 
5754 };
5755 
5757 struct eltwise_backward : public primitive {
5759  struct desc {
5760  dnnl_eltwise_desc_t data;
5761 
5773  desc(algorithm aalgorithm, const memory::desc &diff_data_desc,
5774  const memory::desc &data_desc, float alpha = 0,
5775  float beta = 0) {
5778  dnnl::convert_to_c(aalgorithm),
5779  &diff_data_desc.data, &data_desc.data, alpha, beta),
5780  "could not create a descriptor for an eltwise backward "
5781  "propagation primitive");
5782  }
5783  };
5784 
5788  primitive_desc() = default;
5789 
5803  primitive_desc(const desc &adesc, const engine &aengine,
5804  const eltwise_forward::primitive_desc &hint_fwd_pd,
5805  bool allow_empty = false)
5806  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
5807  hint_fwd_pd.get(), allow_empty) {}
5808 
5823  primitive_desc(const desc &adesc, const primitive_attr &attr,
5824  const engine &aengine,
5825  const eltwise_forward::primitive_desc &hint_fwd_pd,
5826  bool allow_empty = false)
5827  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
5828  hint_fwd_pd.get(), allow_empty) {}
5829 
5837  : dnnl::primitive_desc(pd, dnnl::primitive::kind::eltwise,
5839 
5841  memory::desc src_desc() const { return base::src_desc(0); }
5842 
5845 
5848  };
5849 
5851  eltwise_backward() = default;
5852 
5857 };
5858 
5860 
5868 
5870 struct softmax_forward : public primitive {
5872  struct desc {
5873  dnnl_softmax_desc_t data;
5874 
5876  desc() = default;
5877 
5886  desc(prop_kind aprop_kind, const memory::desc &data_desc,
5887  int softmax_axis) {
5889  dnnl::convert_to_c(aprop_kind),
5890  &data_desc.data, softmax_axis),
5891  "could not create a descriptor for a softmax forward "
5892  "propagation primitive");
5893  }
5894  };
5895 
5899  primitive_desc() = default;
5900 
5911  primitive_desc(const desc &adesc, const engine &aengine,
5912  bool allow_empty = false)
5913  : dnnl::primitive_desc(
5914  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
5915 
5927  primitive_desc(const desc &adesc, const primitive_attr &attr,
5928  const engine &aengine, bool allow_empty = false)
5929  : dnnl::primitive_desc(
5930  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
5931 
5939  : dnnl::primitive_desc(pd, dnnl::primitive::kind::softmax,
5942 
5944  memory::desc src_desc() const { return base::src_desc(0); }
5945 
5947  memory::desc dst_desc() const { return base::dst_desc(0); }
5948  };
5949 
5951  softmax_forward() = default;
5952 
5957 };
5958 
5960 struct softmax_backward : public primitive {
5962  struct desc {
5963  dnnl_softmax_desc_t data;
5964 
5966  desc() = default;
5967 
5975  desc(const memory::desc &diff_data_desc, const memory::desc &data_desc,
5976  int softmax_axis) {
5978  dnnl_softmax_backward_desc_init(&data, &diff_data_desc.data,
5979  &data_desc.data, softmax_axis),
5980  "could not create a descriptor for a softmax backward "
5981  "propagation primitive");
5982  }
5983  };
5984 
5988  primitive_desc() = default;
5989 
6003  primitive_desc(const desc &adesc, const engine &aengine,
6004  const softmax_forward::primitive_desc &hint_fwd_pd,
6005  bool allow_empty = false)
6006  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
6007  hint_fwd_pd.get(), allow_empty) {}
6008 
6023  primitive_desc(const desc &adesc, const primitive_attr &attr,
6024  const engine &aengine,
6025  const softmax_forward::primitive_desc &hint_fwd_pd,
6026  bool allow_empty = false)
6027  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
6028  hint_fwd_pd.get(), allow_empty) {}
6029 
6037  : dnnl::primitive_desc(pd, dnnl::primitive::kind::softmax,
6039 
6041  memory::desc dst_desc() const { return base::dst_desc(0); }
6042 
6045 
6048  };
6049 
6051  softmax_backward() = default;
6052 
6057 };
6058 
6060 
6068 
6072  struct desc {
6074 
6076  desc() = default;
6077 
6086  desc(prop_kind aprop_kind, const memory::desc &data_desc,
6087  int logsoftmax_axis) {
6089  dnnl::convert_to_c(aprop_kind),
6090  &data_desc.data, logsoftmax_axis),
6091  "could not create a descriptor for a logsoftmax forward "
6092  "propagation primitive");
6093  }
6094  };
6095 
6099  primitive_desc() = default;
6100 
6111  primitive_desc(const desc &adesc, const engine &aengine,
6112  bool allow_empty = false)
6113  : dnnl::primitive_desc(
6114  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
6115 
6127  primitive_desc(const desc &adesc, const primitive_attr &attr,
6128  const engine &aengine, bool allow_empty = false)
6129  : dnnl::primitive_desc(
6130  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
6131 
6139  : dnnl::primitive_desc(pd,
6140  // Logsoftmax and softmax share the implementation and
6141  // currently report the same primitive kind. Hence this
6142  // must be softmax and not logsoftmax.
6143  dnnl::primitive::kind::softmax,
6146 
6148  memory::desc src_desc() const { return base::src_desc(0); }
6149 
6151  memory::desc dst_desc() const { return base::dst_desc(0); }
6152  };
6153 
6155  logsoftmax_forward() = default;
6156 
6161 };
6162 
6166  struct desc {
6168 
6170  desc() = default;
6171 
6179  desc(const memory::desc &diff_data_desc, const memory::desc &data_desc,
6180  int logsoftmax_axis) {
6182  &diff_data_desc.data, &data_desc.data,
6183  logsoftmax_axis),
6184  "could not create a descriptor for a logsoftmax backward "
6185  "propagation primitive");
6186  }
6187  };
6188 
6192  primitive_desc() = default;
6193 
6207  primitive_desc(const desc &adesc, const engine &aengine,
6208  const logsoftmax_forward::primitive_desc &hint_fwd_pd,
6209  bool allow_empty = false)
6210  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
6211  hint_fwd_pd.get(), allow_empty) {}
6212 
6227  primitive_desc(const desc &adesc, const primitive_attr &attr,
6228  const engine &aengine,
6229  const logsoftmax_forward::primitive_desc &hint_fwd_pd,
6230  bool allow_empty = false)
6231  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
6232  hint_fwd_pd.get(), allow_empty) {}
6233 
6241  : dnnl::primitive_desc(pd,
6242  // Logsoftmax and softmax share the implementation and
6243  // currently report the same primitive kind. Hence this
6244  // must be softmax and not logsoftmax.
6245  dnnl::primitive::kind::softmax,
6247 
6249  memory::desc dst_desc() const { return base::dst_desc(0); }
6250 
6253 
6256  };
6257 
6259  logsoftmax_backward() = default;
6260 
6265 };
6266 
6268 
6288 
6292  struct desc {
6294 
6309  desc(prop_kind aprop_kind, const memory::desc &data_desc, float epsilon,
6310  normalization_flags flags) {
6313  dnnl::convert_to_c(aprop_kind), &data_desc.data,
6314  epsilon, convert_to_c(flags)),
6315  "could not create a descriptor for a batch normalization "
6316  "forward propagation primitive");
6317  }
6318  };
6319 
6324  primitive_desc() = default;
6325 
6336  primitive_desc(const desc &adesc, const engine &aengine,
6337  bool allow_empty = false)
6338  : dnnl::primitive_desc(
6339  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
6340 
6352  primitive_desc(const desc &adesc, const primitive_attr &attr,
6353  const engine &aengine, bool allow_empty = false)
6354  : dnnl::primitive_desc(
6355  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
6356 
6364  : dnnl::primitive_desc(pd,
6365  dnnl::primitive::kind::batch_normalization,
6368 
6370  memory::desc src_desc() const { return base::src_desc(0); }
6371 
6373  memory::desc dst_desc() const { return base::dst_desc(0); }
6374 
6377 
6380 
6383  memory::desc mean_desc() const { return stat_desc(mean); }
6384 
6387  memory::desc variance_desc() const { return stat_desc(var); }
6388 
6389  private:
6390  enum {
6391  mean = 1,
6392  var = 2,
6393  };
6394  memory::desc stat_desc(int kind) const {
6399  &p),
6400  "could not retrieve a descriptor from a primitive "
6401  "descriptor for batch normalization forward propagation "
6402  "primitive");
6403  return query_md(p->flags & dnnl_use_global_stats ? query::src_md
6404  : query::dst_md,
6405  kind);
6406  }
6407  };
6408 
6410  batch_normalization_forward() = default;
6411 
6416 };
6417 
6421  struct desc {
6423 
6436  desc(prop_kind aprop_kind, const memory::desc &diff_data_desc,
6437  const memory::desc &data_desc, float epsilon,
6438  normalization_flags flags) {
6440  dnnl::convert_to_c(aprop_kind),
6441  &diff_data_desc.data, &data_desc.data,
6442  epsilon, convert_to_c(flags)),
6443  "could not create a descriptor for a batch normalization "
6444  "backward propagation primitive");
6445  }
6446  };
6447 
6452  primitive_desc() = default;
6453 
6467  primitive_desc(const desc &adesc, const engine &aengine,
6469  bool allow_empty = false)
6470  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
6471  hint_fwd_pd.get(), allow_empty) {}
6472 
6487  primitive_desc(const desc &adesc, const primitive_attr &attr,
6488  const engine &aengine,
6490  bool allow_empty = false)
6491  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
6492  hint_fwd_pd.get(), allow_empty) {}
6493 
6501  : dnnl::primitive_desc(pd,
6502  dnnl::primitive::kind::batch_normalization,
6504  }
6505 
6507  memory::desc src_desc() const { return base::src_desc(0); }
6508 
6511 
6513  memory::desc dst_desc() const { return base::dst_desc(0); }
6514 
6517 
6520 
6523  return base::diff_weights_desc(0);
6524  }
6525 
6528 
6531  return query_md(query::src_md, 2);
6532  }
6533 
6536  };
6537 
6539  batch_normalization_backward() = default;
6540 
6545 };
6546 
6548 
6570 
6574  struct desc {
6576 
6588  desc(prop_kind aprop_kind, const memory::desc &data_desc,
6589  const memory::desc &stat_desc, float epsilon,
6590  normalization_flags flags) {
6593  dnnl::convert_to_c(aprop_kind), &data_desc.data,
6594  &stat_desc.data, epsilon, convert_to_c(flags)),
6595  "could not create a descriptor for a layer normalization "
6596  "forward propagation primitive");
6597  }
6598 
6609  desc(prop_kind aprop_kind, const memory::desc &data_desc, float epsilon,
6610  normalization_flags flags) {
6613  dnnl::convert_to_c(aprop_kind), &data_desc.data,
6614  nullptr, epsilon, convert_to_c(flags)),
6615  "could not create a descriptor for a layer normalization "
6616  "forward propagation primitive");
6617  }
6618  };
6619 
6624  primitive_desc() = default;
6625 
6636  primitive_desc(const desc &adesc, const engine &aengine,
6637  bool allow_empty = false)
6638  : dnnl::primitive_desc(
6639  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
6640 
6652  primitive_desc(const desc &adesc, const primitive_attr &attr,
6653  const engine &aengine, bool allow_empty = false)
6654  : dnnl::primitive_desc(
6655  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
6656 
6664  : dnnl::primitive_desc(pd,
6665  dnnl::primitive::kind::layer_normalization,
6668 
6670  memory::desc src_desc() const { return base::src_desc(0); }
6671 
6673  memory::desc dst_desc() const { return base::dst_desc(0); }
6674 
6677 
6680 
6682  memory::desc mean_desc() const { return stat_desc(mean); }
6683 
6685  memory::desc variance_desc() const { return stat_desc(var); }
6686 
6687  private:
6688  enum {
6689  mean = 1,
6690  var = 2,
6691  };
6692  memory::desc stat_desc(int kind) const {
6697  &p),
6698  "could not retrieve a descriptor from a primitive "
6699  "descriptor for layer normalization forward propagation "
6700  "primitive");
6701  return query_md(p->flags & dnnl_use_global_stats ? query::src_md
6702  : query::dst_md,
6703  kind);
6704  }
6705  };
6706 
6708  layer_normalization_forward() = default;
6709 
6714 };
6715 
6719  struct desc {
6721 
6735  desc(prop_kind aprop_kind, const memory::desc &diff_data_desc,
6736  const memory::desc &data_desc, const memory::desc &stat_desc,
6737  float epsilon, normalization_flags flags) {
6740  dnnl::convert_to_c(aprop_kind),
6741  &diff_data_desc.data, &data_desc.data,
6742  &stat_desc.data, epsilon, convert_to_c(flags)),
6743  "could not create a descriptor for a batch normalization "
6744  "backward propagation primitive");
6745  }
6746 
6759  desc(prop_kind aprop_kind, const memory::desc &diff_data_desc,
6760  const memory::desc &data_desc, float epsilon,
6761  normalization_flags flags) {
6763  dnnl::convert_to_c(aprop_kind),
6764  &diff_data_desc.data, &data_desc.data,
6765  nullptr, epsilon, convert_to_c(flags)),
6766  "could not create a descriptor for a batch normalization "
6767  "backward propagation primitive");
6768  }
6769  };
6770 
6775  primitive_desc() = default;
6776 
6790  primitive_desc(const desc &adesc, const engine &aengine,
6792  bool allow_empty = false)
6793  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
6794  hint_fwd_pd.get(), allow_empty) {}
6795 
6810  primitive_desc(const desc &adesc, const primitive_attr &attr,
6811  const engine &aengine,
6813  bool allow_empty = false)
6814  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
6815  hint_fwd_pd.get(), allow_empty) {}
6816 
6824  : dnnl::primitive_desc(pd,
6825  dnnl::primitive::kind::layer_normalization,
6827  }
6828 
6830  memory::desc src_desc() const { return base::src_desc(0); }
6831 
6834 
6836  memory::desc dst_desc() const { return base::dst_desc(0); }
6837 
6840 
6843 
6846  return base::diff_weights_desc(0);
6847  }
6848 
6851 
6854  return query_md(query::src_md, 2);
6855  }
6856 
6859  };
6860 
6862  layer_normalization_backward() = default;
6863 
6868 };
6869 
6871 
6879 
6883  struct desc {
6885 
6900  desc(prop_kind aprop_kind, const memory::desc &src_desc,
6901  const memory::desc &weights_desc, const memory::desc &bias_desc,
6902  const memory::desc &dst_desc) {
6904  dnnl::convert_to_c(aprop_kind),
6905  &src_desc.data, &weights_desc.data,
6906  &bias_desc.data, &dst_desc.data),
6907  "could not create a descriptor for an inner product "
6908  "forward propagation primitive");
6909  }
6910 
6924  desc(prop_kind aprop_kind, const memory::desc &src_desc,
6925  const memory::desc &weights_desc,
6926  const memory::desc &dst_desc) {
6929  dnnl::convert_to_c(aprop_kind), &src_desc.data,
6930  &weights_desc.data, nullptr, &dst_desc.data),
6931  "could not create a descriptor for an inner product "
6932  "forward propagation primitive");
6933  }
6934  };
6935 
6939  primitive_desc() = default;
6940 
6951  primitive_desc(const desc &adesc, const engine &aengine,
6952  bool allow_empty = false)
6953  : dnnl::primitive_desc(
6954  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
6955 
6967  primitive_desc(const desc &adesc, const primitive_attr &attr,
6968  const engine &aengine, bool allow_empty = false)
6969  : dnnl::primitive_desc(
6970  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
6971 
6979  : dnnl::primitive_desc(pd, dnnl::primitive::kind::inner_product,
6982 
6984  memory::desc src_desc() const { return base::src_desc(0); }
6985 
6988 
6990  memory::desc dst_desc() const { return base::dst_desc(0); }
6991 
6994  };
6995 
6997  inner_product_forward() = default;
6998 
7003 };
7004 
7008  struct desc {
7010 
7021  desc(const memory::desc &diff_src_desc,
7022  const memory::desc &weights_desc,
7023  const memory::desc &diff_dst_desc) {
7025  &diff_src_desc.data, &weights_desc.data,
7026  &diff_dst_desc.data),
7027  "could not create a descriptor for an inner product "
7028  "backward propagation primitive");
7029  }
7030  };
7031 
7036  primitive_desc() = default;
7037 
7051  primitive_desc(const desc &adesc, const engine &aengine,
7052  const inner_product_forward::primitive_desc &hint_fwd_pd,
7053  bool allow_empty = false)
7054  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
7055  hint_fwd_pd.get(), allow_empty) {}
7056 
7071  primitive_desc(const desc &adesc, const primitive_attr &attr,
7072  const engine &aengine,
7073  const inner_product_forward::primitive_desc &hint_fwd_pd,
7074  bool allow_empty = false)
7075  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
7076  hint_fwd_pd.get(), allow_empty) {}
7077 
7085  : dnnl::primitive_desc(pd, dnnl::primitive::kind::inner_product,
7087 
7090 
7093 
7096  };
7097 
7099  inner_product_backward_data() = default;
7100 
7105 };
7106 
7110  struct desc {
7112 
7124  desc(const memory::desc &src_desc,
7125  const memory::desc &diff_weights_desc,
7126  const memory::desc &diff_bias_desc,
7127  const memory::desc &diff_dst_desc) {
7130  &src_desc.data, &diff_weights_desc.data,
7131  &diff_bias_desc.data, &diff_dst_desc.data),
7132  "could not create a descriptor for an inner product "
7133  "weights gradient primitive");
7134  }
7135 
7146  desc(const memory::desc &src_desc,
7147  const memory::desc &diff_weights_desc,
7148  const memory::desc &diff_dst_desc) {
7151  &src_desc.data, &diff_weights_desc.data, nullptr,
7152  &diff_dst_desc.data),
7153  "could not create a descriptor for an inner product "
7154  "weights gradient primitive");
7155  }
7156  };
7157 
7161  primitive_desc() = default;
7162 
7176  primitive_desc(const desc &adesc, const engine &aengine,
7177  const inner_product_forward::primitive_desc &hint_fwd_pd,
7178  bool allow_empty = false)
7179  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
7180  hint_fwd_pd.get(), allow_empty) {}
7181 
7196  primitive_desc(const desc &adesc, const primitive_attr &attr,
7197  const engine &aengine,
7198  const inner_product_forward::primitive_desc &hint_fwd_pd,
7199  bool allow_empty = false)
7200  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
7201  hint_fwd_pd.get(), allow_empty) {}
7202 
7210  : dnnl::primitive_desc(pd, dnnl::primitive::kind::inner_product,
7212 
7214  memory::desc src_desc() const { return base::src_desc(0); }
7215 
7218  return base::diff_weights_desc(0);
7219  }
7220 
7223 
7226  return base::diff_weights_desc(1);
7227  }
7228  };
7229 
7231  inner_product_backward_weights() = default;
7232 
7237 };
7238 
7240 
7248 
7251  using primitive_desc::primitive_desc;
7252 
7254  rnn_primitive_desc_base() = default;
7255 
7264  dnnl::prop_kind aprop_kind, dnnl::algorithm cell_kind)
7265  : rnn_primitive_desc_base(pd, aprop_kind, aprop_kind, cell_kind) {}
7266 
7271  }
7272 
7279  }
7280 
7285  }
7286 
7291  }
7292 
7297  }
7298 
7303  }
7304 
7309  }
7310 
7317  }
7318 
7323  }
7324 
7331  }
7332 
7337  }
7338 
7343  }
7344 
7351  }
7352 
7357  }
7358 
7363  }
7364 
7369  }
7370 
7374  return base::query_md(
7376  }
7377 
7381  return base::query_md(
7383  }
7384 
7391  }
7392 
7397  }
7398 
7405  }
7406 
7411  }
7412 
7413 protected:
7414  using rnn_base = rnn_primitive_desc_base;
7415 
7416  // (Deliberately not using doxygen comments)
7417  //
7418  // Constructs an RNN primitive descriptor base from a C API primitive
7419  // descriptor while checking that it actually describes the expected
7420  // primitive by comparing propagation and primitive kinds. Caller can
7421  // pass two options propagation kinds. This is typically used to check
7422  // that propagation kind is inference or training forward propagation.
7423  //
7424  // @param pd C API primitive descriptor.
7425  // @param prop_kind1 Expected propagation kind.
7426  // @param prop_kind2 Expected propagation kind.
7427  // @param cell_kind Expected cell kind.
7429  dnnl::prop_kind prop_kind1, dnnl::prop_kind prop_kind2,
7430  dnnl::algorithm cell_kind) {
7432  dnnl_status_t rc;
7434  error::wrap_c_api(rc,
7435  "could not retrieve a descriptor from a primitive descriptor "
7436  "for an RNN primitive");
7437 
7438  dnnl_prop_kind_t c_prop_kind1 = convert_to_c(prop_kind1);
7439  dnnl_prop_kind_t c_prop_kind2 = convert_to_c(prop_kind2);
7440  dnnl_alg_kind_t c_cell_kind = convert_to_c(cell_kind);
7441 
7442  bool ok = rnn_d->primitive_kind == dnnl_rnn
7443  && (rnn_d->prop_kind == c_prop_kind1
7444  || rnn_d->prop_kind == c_prop_kind2)
7445  && rnn_d->cell_kind == c_cell_kind;
7446 
7447  if (!ok)
7448  DNNL_THROW_ERROR(dnnl_invalid_arguments,
7449  "mismatch between expected and provided descriptors for an "
7450  "RNN primitive");
7451 
7452  reset_with_clone(pd);
7453  }
7454 };
7455 
7459  struct desc {
7460  dnnl_rnn_desc_t data;
7461 
7502  desc(prop_kind aprop_kind, algorithm activation,
7503  rnn_direction direction, const memory::desc &src_layer_desc,
7504  const memory::desc &src_iter_desc,
7505  const memory::desc &weights_layer_desc,
7506  const memory::desc &weights_iter_desc,
7507  const memory::desc &bias_desc,
7508  const memory::desc &dst_layer_desc,
7509  const memory::desc &dst_iter_desc,
7510  rnn_flags flags = rnn_flags::undef, float alpha = 0.0f,
7511  float beta = 0.0f) {
7514  dnnl::convert_to_c(aprop_kind),
7515  dnnl::convert_to_c(activation),
7516  dnnl::convert_to_c(direction), &src_layer_desc.data,
7517  &src_iter_desc.data, &weights_layer_desc.data,
7518  &weights_iter_desc.data, &bias_desc.data,
7519  &dst_layer_desc.data, &dst_iter_desc.data,
7520  dnnl::convert_to_c(flags), alpha, beta),
7521  "could not create a descriptor for a vanilla RNN forward "
7522  "propagation primitive");
7523  }
7524  };
7525 
7529  primitive_desc() = default;
7530 
7541  primitive_desc(const desc &adesc, const engine &aengine,
7542  bool allow_empty = false)
7544  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
7545 
7557  primitive_desc(const desc &adesc, const primitive_attr &attr,
7558  const engine &aengine, bool allow_empty = false)
7560  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
7561 
7571  dnnl::algorithm::vanilla_rnn) {}
7572 
7575  return rnn_base::src_layer_desc();
7576  }
7577 
7580 
7584  }
7585 
7588  return rnn_base::weights_iter_desc();
7589  }
7590 
7593 
7596  return rnn_base::dst_layer_desc();
7597  }
7598 
7601 
7604  return rnn_base::workspace_desc();
7605  }
7606  };
7607 
7609  vanilla_rnn_forward() = default;
7610 
7615 };
7616 
7620  struct desc {
7621  dnnl_rnn_desc_t data;
7622 
7675  desc(prop_kind aprop_kind, algorithm activation,
7676  rnn_direction direction, const memory::desc &src_layer_desc,
7677  const memory::desc &src_iter_desc,
7678  const memory::desc &weights_layer_desc,
7679  const memory::desc &weights_iter_desc,
7680  const memory::desc &bias_desc,
7681  const memory::desc &dst_layer_desc,
7682  const memory::desc &dst_iter_desc,
7683  const memory::desc &diff_src_layer_desc,
7684  const memory::desc &diff_src_iter_desc,
7685  const memory::desc &diff_weights_layer_desc,
7686  const memory::desc &diff_weights_iter_desc,
7687  const memory::desc &diff_bias_desc,
7688  const memory::desc &diff_dst_layer_desc,
7689  const memory::desc &diff_dst_iter_desc,
7690  rnn_flags flags = rnn_flags::undef, float alpha = 0.0f,
7691  float beta = 0.0f) {
7694  dnnl::convert_to_c(aprop_kind),
7695  dnnl::convert_to_c(activation),
7696  dnnl::convert_to_c(direction), &src_layer_desc.data,
7697  &src_iter_desc.data, &weights_layer_desc.data,
7698  &weights_iter_desc.data, &bias_desc.data,
7699  &dst_layer_desc.data, &dst_iter_desc.data,
7700  &diff_src_layer_desc.data, &diff_src_iter_desc.data,
7701  &diff_weights_layer_desc.data,
7702  &diff_weights_iter_desc.data, &diff_bias_desc.data,
7703  &diff_dst_layer_desc.data, &diff_dst_iter_desc.data,
7704  dnnl::convert_to_c(flags), alpha, beta),
7705  "could not create a descriptor for a vanilla RNN backward "
7706  "propagation primitive");
7707  }
7708  };
7709 
7713  primitive_desc() = default;
7714 
7728  primitive_desc(const desc &adesc, const engine &aengine,
7729  const vanilla_rnn_forward::primitive_desc &hint_fwd_pd,
7730  bool allow_empty = false)
7731  : rnn_primitive_desc_base(&adesc.data, nullptr, aengine,
7732  hint_fwd_pd.get(), allow_empty) {}
7733 
7748  primitive_desc(const desc &adesc, const primitive_attr &attr,
7749  const engine &aengine,
7750  const vanilla_rnn_forward::primitive_desc &hint_fwd_pd,
7751  bool allow_empty = false)
7752  : rnn_primitive_desc_base(&adesc.data, &attr, aengine,
7753  hint_fwd_pd.get(), allow_empty) {}
7754 
7763  dnnl::algorithm::vanilla_rnn) {}
7764 
7767  return rnn_base::src_layer_desc();
7768  }
7769 
7772 
7776  }
7777 
7780  return rnn_base::weights_iter_desc();
7781  }
7782 
7785 
7788  return rnn_base::dst_layer_desc();
7789  }
7790 
7793 
7796  return rnn_base::workspace_desc();
7797  }
7798 
7802  }
7803 
7807  }
7808 
7812  }
7813 
7817  }
7818 
7821  return rnn_base::diff_bias_desc();
7822  }
7823 
7827  }
7828 
7832  }
7833  };
7834 
7836  vanilla_rnn_backward() = default;
7837 
7842 };
7843 
7845 struct lstm_forward : public primitive {
7847  struct desc {
7848  dnnl_rnn_desc_t data;
7849 
7898  desc(prop_kind aprop_kind, rnn_direction direction,
7899  const memory::desc &src_layer_desc,
7900  const memory::desc &src_iter_desc,
7901  const memory::desc &src_iter_c_desc,
7902  const memory::desc &weights_layer_desc,
7903  const memory::desc &weights_iter_desc,
7904  const memory::desc &weights_peephole_desc,
7905  const memory::desc &weights_projection_desc,
7906  const memory::desc &bias_desc,
7907  const memory::desc &dst_layer_desc,
7908  const memory::desc &dst_iter_desc,
7909  const memory::desc &dst_iter_c_desc,
7910  rnn_flags flags = rnn_flags::undef) {
7913  dnnl::convert_to_c(aprop_kind),
7914  dnnl::convert_to_c(direction), &src_layer_desc.data,
7915  &src_iter_desc.data, &src_iter_c_desc.data,
7916  &weights_layer_desc.data, &weights_iter_desc.data,
7917  &weights_peephole_desc.data,
7918  &weights_projection_desc.data, &bias_desc.data,
7919  &dst_layer_desc.data, &dst_iter_desc.data,
7920  &dst_iter_c_desc.data, dnnl::convert_to_c(flags)),
7921  "could not create a descriptor for an LSTM forward "
7922  "propagation primitive");
7923  }
7924 
7966  desc(prop_kind aprop_kind, rnn_direction direction,
7967  const memory::desc &src_layer_desc,
7968  const memory::desc &src_iter_desc,
7969  const memory::desc &src_iter_c_desc,
7970  const memory::desc &weights_layer_desc,
7971  const memory::desc &weights_iter_desc,
7972  const memory::desc &weights_peephole_desc,
7973  const memory::desc &bias_desc,
7974  const memory::desc &dst_layer_desc,
7975  const memory::desc &dst_iter_desc,
7976  const memory::desc &dst_iter_c_desc,
7977  rnn_flags flags = rnn_flags::undef) {
7980  dnnl::convert_to_c(aprop_kind),
7981  dnnl::convert_to_c(direction), &src_layer_desc.data,
7982  &src_iter_desc.data, &src_iter_c_desc.data,
7983  &weights_layer_desc.data, &weights_iter_desc.data,
7984  &weights_peephole_desc.data, &bias_desc.data,
7985  &dst_layer_desc.data, &dst_iter_desc.data,
7986  &dst_iter_c_desc.data, dnnl::convert_to_c(flags)),
7987  "could not create a descriptor for an LSTM forward "
7988  "propagation primitive");
7989  }
7990 
8027  desc(prop_kind aprop_kind, rnn_direction direction,
8028  const memory::desc &src_layer_desc,
8029  const memory::desc &src_iter_desc,
8030  const memory::desc &src_iter_c_desc,
8031  const memory::desc &weights_layer_desc,
8032  const memory::desc &weights_iter_desc,
8033  const memory::desc &bias_desc,
8034  const memory::desc &dst_layer_desc,
8035  const memory::desc &dst_iter_desc,
8036  const memory::desc &dst_iter_c_desc,
8037  rnn_flags flags = rnn_flags::undef) {
8040  dnnl::convert_to_c(aprop_kind),
8041  dnnl::convert_to_c(direction), &src_layer_desc.data,
8042  &src_iter_desc.data, &src_iter_c_desc.data,
8043  &weights_layer_desc.data, &weights_iter_desc.data,
8044  &bias_desc.data, &dst_layer_desc.data,
8045  &dst_iter_desc.data, &dst_iter_c_desc.data,
8046  dnnl::convert_to_c(flags)),
8047  "could not create a descriptor for an LSTM forward "
8048  "propagation primitive");
8049  }
8050  };
8051 
8055  primitive_desc() = default;
8056 
8066  primitive_desc(const desc &adesc, const engine &aengine,
8067  bool allow_empty = false)
8069  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
8070 
8081  primitive_desc(const desc &adesc, const primitive_attr &attr,
8082  const engine &aengine, bool allow_empty = false)
8084  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
8085 
8096 
8099  return rnn_base::src_layer_desc();
8100  }
8101 
8104 
8107  return rnn_base::src_iter_c_desc();
8108  }
8109 
8113  }
8114 
8117  return rnn_base::weights_iter_desc();
8118  }
8119 
8123  }
8124 
8128  }
8129 
8132 
8135  return rnn_base::dst_layer_desc();
8136  }
8137 
8140 
8143  return rnn_base::dst_iter_c_desc();
8144  }
8145 
8148  return rnn_base::workspace_desc();
8149  }
8150  };
8151 
8153  lstm_forward() = default;
8154 
8159 };
8160 
8162 struct lstm_backward : public primitive {
8164  struct desc {
8165  dnnl_rnn_desc_t data;
8166 
8242  desc(prop_kind aprop_kind, rnn_direction direction,
8243  const memory::desc &src_layer_desc,
8244  const memory::desc &src_iter_desc,
8245  const memory::desc &src_iter_c_desc,
8246  const memory::desc &weights_layer_desc,
8247  const memory::desc &weights_iter_desc,
8248  const memory::desc &weights_peephole_desc,
8249  const memory::desc &weights_projection_desc,
8250  const memory::desc &bias_desc,
8251  const memory::desc &dst_layer_desc,
8252  const memory::desc &dst_iter_desc,
8253  const memory::desc &dst_iter_c_desc,
8254  const memory::desc &diff_src_layer_desc,
8255  const memory::desc &diff_src_iter_desc,
8256  const memory::desc &diff_src_iter_c_desc,
8257  const memory::desc &diff_weights_layer_desc,
8258  const memory::desc &diff_weights_iter_desc,
8259  const memory::desc &diff_weights_peephole_desc,
8260  const memory::desc &diff_weights_projection_desc,
8261  const memory::desc &diff_bias_desc,
8262  const memory::desc &diff_dst_layer_desc,
8263  const memory::desc &diff_dst_iter_desc,
8264  const memory::desc &diff_dst_iter_c_desc,
8265  rnn_flags flags = rnn_flags::undef) {
8268  dnnl::convert_to_c(aprop_kind),
8269  dnnl::convert_to_c(direction), &src_layer_desc.data,
8270  &src_iter_desc.data, &src_iter_c_desc.data,
8271  &weights_layer_desc.data, &weights_iter_desc.data,
8272  &weights_peephole_desc.data,
8273  &weights_projection_desc.data, &bias_desc.data,
8274  &dst_layer_desc.data, &dst_iter_desc.data,
8275  &dst_iter_c_desc.data, &diff_src_layer_desc.data,
8276  &diff_src_iter_desc.data,
8277  &diff_src_iter_c_desc.data,
8278  &diff_weights_layer_desc.data,
8279  &diff_weights_iter_desc.data,
8280  &diff_weights_peephole_desc.data,
8281  &diff_weights_projection_desc.data,
8282  &diff_bias_desc.data, &diff_dst_layer_desc.data,
8283  &diff_dst_iter_desc.data,
8284  &diff_dst_iter_c_desc.data,
8285  dnnl::convert_to_c(flags)),
8286  "could not create a descriptor for an LSTM backward "
8287  "propagation primitive");
8288  }
8289 
8354  desc(prop_kind aprop_kind, rnn_direction direction,
8355  const memory::desc &src_layer_desc,
8356  const memory::desc &src_iter_desc,
8357  const memory::desc &src_iter_c_desc,
8358  const memory::desc &weights_layer_desc,
8359  const memory::desc &weights_iter_desc,
8360  const memory::desc &weights_peephole_desc,
8361  const memory::desc &bias_desc,
8362  const memory::desc &dst_layer_desc,
8363  const memory::desc &dst_iter_desc,
8364  const memory::desc &dst_iter_c_desc,
8365  const memory::desc &diff_src_layer_desc,
8366  const memory::desc &diff_src_iter_desc,
8367  const memory::desc &diff_src_iter_c_desc,
8368  const memory::desc &diff_weights_layer_desc,
8369  const memory::desc &diff_weights_iter_desc,
8370  const memory::desc &diff_weights_peephole_desc,
8371  const memory::desc &diff_bias_desc,
8372  const memory::desc &diff_dst_layer_desc,
8373  const memory::desc &diff_dst_iter_desc,
8374  const memory::desc &diff_dst_iter_c_desc,
8375  rnn_flags flags = rnn_flags::undef) {
8378  dnnl::convert_to_c(aprop_kind),
8379  dnnl::convert_to_c(direction), &src_layer_desc.data,
8380  &src_iter_desc.data, &src_iter_c_desc.data,
8381  &weights_layer_desc.data, &weights_iter_desc.data,
8382  &weights_peephole_desc.data, &bias_desc.data,
8383  &dst_layer_desc.data, &dst_iter_desc.data,
8384  &dst_iter_c_desc.data, &diff_src_layer_desc.data,
8385  &diff_src_iter_desc.data,
8386  &diff_src_iter_c_desc.data,
8387  &diff_weights_layer_desc.data,
8388  &diff_weights_iter_desc.data,
8389  &diff_weights_peephole_desc.data,
8390  &diff_bias_desc.data, &diff_dst_layer_desc.data,
8391  &diff_dst_iter_desc.data,
8392  &diff_dst_iter_c_desc.data,
8393  dnnl::convert_to_c(flags)),
8394  "could not create a descriptor for an LSTM backward "
8395  "propagation primitive");
8396  }
8397 
8453  desc(prop_kind aprop_kind, rnn_direction direction,
8454  const memory::desc &src_layer_desc,
8455  const memory::desc &src_iter_desc,
8456  const memory::desc &src_iter_c_desc,
8457  const memory::desc &weights_layer_desc,
8458  const memory::desc &weights_iter_desc,
8459  const memory::desc &bias_desc,
8460  const memory::desc &dst_layer_desc,
8461  const memory::desc &dst_iter_desc,
8462  const memory::desc &dst_iter_c_desc,
8463  const memory::desc &diff_src_layer_desc,
8464  const memory::desc &diff_src_iter_desc,
8465  const memory::desc &diff_src_iter_c_desc,
8466  const memory::desc &diff_weights_layer_desc,
8467  const memory::desc &diff_weights_iter_desc,
8468  const memory::desc &diff_bias_desc,
8469  const memory::desc &diff_dst_layer_desc,
8470  const memory::desc &diff_dst_iter_desc,
8471  const memory::desc &diff_dst_iter_c_desc,
8472  rnn_flags flags = rnn_flags::undef) {
8475  dnnl::convert_to_c(aprop_kind),
8476  dnnl::convert_to_c(direction), &src_layer_desc.data,
8477  &src_iter_desc.data, &src_iter_c_desc.data,
8478  &weights_layer_desc.data, &weights_iter_desc.data,
8479  &bias_desc.data, &dst_layer_desc.data,
8480  &dst_iter_desc.data, &dst_iter_c_desc.data,
8481  &diff_src_layer_desc.data, &diff_src_iter_desc.data,
8482  &diff_src_iter_c_desc.data,
8483  &diff_weights_layer_desc.data,
8484  &diff_weights_iter_desc.data, &diff_bias_desc.data,
8485  &diff_dst_layer_desc.data, &diff_dst_iter_desc.data,
8486  &diff_dst_iter_c_desc.data,
8487  dnnl::convert_to_c(flags)),
8488  "could not create a descriptor for an LSTM backward "
8489  "propagation primitive");
8490  }
8491  };
8492 
8496  primitive_desc() = default;
8497 
8510  primitive_desc(const desc &adesc, const engine &aengine,
8511  const lstm_forward::primitive_desc &hint_fwd_pd,
8512  bool allow_empty = false)
8513  : rnn_primitive_desc_base(&adesc.data, nullptr, aengine,
8514  hint_fwd_pd.get(), allow_empty) {}
8515 
8529  primitive_desc(const desc &adesc, const primitive_attr &attr,
8530  const engine &aengine,
8531  const lstm_forward::primitive_desc &hint_fwd_pd,
8532  bool allow_empty = false)
8533  : rnn_primitive_desc_base(&adesc.data, &attr, aengine,
8534  hint_fwd_pd.get(), allow_empty) {}
8535 
8545 
8548  return rnn_base::src_layer_desc();
8549  }
8550 
8553 
8556  return rnn_base::src_iter_c_desc();
8557  }
8558 
8562  }
8563 
8566  return rnn_base::weights_iter_desc();
8567  }
8568 
8572  }
8573 
8577  }
8578 
8581 
8584  return rnn_base::dst_layer_desc();
8585  }
8586 
8589 
8592  return rnn_base::dst_iter_c_desc();
8593  }
8594 
8597  return rnn_base::workspace_desc();
8598  }
8599 
8603  }
8604 
8608  }
8609 
8613  }
8614 
8618  }
8619 
8623  }
8624 
8628  }
8629 
8633  }
8634 
8637  return rnn_base::diff_bias_desc();
8638  }
8639 
8643  }
8644 
8648  }
8649 
8653  }
8654  };
8655 
8657  lstm_backward() = default;
8658 
8663 };
8664 
8666 struct gru_forward : public primitive {
8668  struct desc {
8669  dnnl_rnn_desc_t data;
8670 
8703  desc(prop_kind aprop_kind, rnn_direction direction,
8704  const memory::desc &src_layer_desc,
8705  const memory::desc &src_iter_desc,
8706  const memory::desc &weights_layer_desc,
8707  const memory::desc &weights_iter_desc,
8708  const memory::desc &bias_desc,
8709  const memory::desc &dst_layer_desc,
8710  const memory::desc &dst_iter_desc,
8711  rnn_flags flags = rnn_flags::undef) {
8714  dnnl::convert_to_c(aprop_kind),
8715  dnnl::convert_to_c(direction), &src_layer_desc.data,
8716  &src_iter_desc.data, &weights_layer_desc.data,
8717  &weights_iter_desc.data, &bias_desc.data,
8718  &dst_layer_desc.data, &dst_iter_desc.data,
8719  dnnl::convert_to_c(flags)),
8720  "could not create a descriptor for a GRU forward "
8721  "propagation primitive");
8722  }
8723  };
8724 
8728  primitive_desc() = default;
8729 
8739  primitive_desc(const desc &adesc, const engine &aengine,
8740  bool allow_empty = false)
8742  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
8743 
8754  primitive_desc(const desc &adesc, const primitive_attr &attr,
8755  const engine &aengine, bool allow_empty = false)
8757  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
8758 
8768  dnnl::algorithm::vanilla_gru) {}
8769 
8772  return rnn_base::src_layer_desc();
8773  }
8774 
8777 
8781  }
8782 
8785  return rnn_base::weights_iter_desc();
8786  }
8787 
8790 
8793  return rnn_base::dst_layer_desc();
8794  }
8795 
8798 
8801  return rnn_base::workspace_desc();
8802  }
8803  };
8804 
8806  gru_forward() = default;
8807 
8812 };
8813 
8815 struct gru_backward : public primitive {
8817  struct desc {
8818  dnnl_rnn_desc_t data;
8819 
8864  desc(prop_kind aprop_kind, rnn_direction direction,
8865  const memory::desc &src_layer_desc,
8866  const memory::desc &src_iter_desc,
8867  const memory::desc &weights_layer_desc,
8868  const memory::desc &weights_iter_desc,
8869  const memory::desc &bias_desc,
8870  const memory::desc &dst_layer_desc,
8871  const memory::desc &dst_iter_desc,
8872  const memory::desc &diff_src_layer_desc,
8873  const memory::desc &diff_src_iter_desc,
8874  const memory::desc &diff_weights_layer_desc,
8875  const memory::desc &diff_weights_iter_desc,
8876  const memory::desc &diff_bias_desc,
8877  const memory::desc &diff_dst_layer_desc,
8878  const memory::desc &diff_dst_iter_desc,
8879  rnn_flags flags = rnn_flags::undef) {
8882  dnnl::convert_to_c(aprop_kind),
8883  dnnl::convert_to_c(direction), &src_layer_desc.data,
8884  &src_iter_desc.data, &weights_layer_desc.data,
8885  &weights_iter_desc.data, &bias_desc.data,
8886  &dst_layer_desc.data, &dst_iter_desc.data,
8887  &diff_src_layer_desc.data, &diff_src_iter_desc.data,
8888  &diff_weights_layer_desc.data,
8889  &diff_weights_iter_desc.data, &diff_bias_desc.data,
8890  &diff_dst_layer_desc.data, &diff_dst_iter_desc.data,
8891  dnnl::convert_to_c(flags)),
8892  "could not create a descriptor for a GRU backward "
8893  "propagation primitive");
8894  }
8895  };
8896 
8900  primitive_desc() = default;
8901 
8914  primitive_desc(const desc &adesc, const engine &aengine,
8915  const gru_forward::primitive_desc &hint_fwd_pd,
8916  bool allow_empty = false)
8917  : rnn_primitive_desc_base(&adesc.data, nullptr, aengine,
8918  hint_fwd_pd.get(), allow_empty) {}
8919 
8933  primitive_desc(const desc &adesc, const primitive_attr &attr,
8934  const engine &aengine,
8935  const gru_forward::primitive_desc &hint_fwd_pd,
8936  bool allow_empty = false)
8937  : rnn_primitive_desc_base(&adesc.data, &attr, aengine,
8938  hint_fwd_pd.get(), allow_empty) {}
8939 
8948  dnnl::algorithm::vanilla_gru) {}
8949 
8952  return rnn_base::src_layer_desc();
8953  }
8954 
8957 
8961  }
8962 
8965  return rnn_base::weights_iter_desc();
8966  }
8967 
8970 
8973  return rnn_base::dst_layer_desc();
8974  }
8975 
8978 
8981  return rnn_base::workspace_desc();
8982  }
8983 
8987  }
8988 
8992  }
8993 
8997  }
8998 
9002  }
9003 
9006  return rnn_base::diff_bias_desc();
9007  }
9008 
9012  }
9013 
9017  }
9018  };
9019 
9021  gru_backward() = default;
9022 
9027 };
9028 
9030 struct lbr_gru_forward : public primitive {
9032  struct desc {
9033  dnnl_rnn_desc_t data;
9034 
9068  desc(prop_kind aprop_kind, rnn_direction direction,
9069  const memory::desc &src_layer_desc,
9070  const memory::desc &src_iter_desc,
9071  const memory::desc &weights_layer_desc,
9072  const memory::desc &weights_iter_desc,
9073  const memory::desc &bias_desc,
9074  const memory::desc &dst_layer_desc,
9075  const memory::desc &dst_iter_desc,
9076  rnn_flags flags = rnn_flags::undef) {
9079  dnnl::convert_to_c(aprop_kind),
9080  dnnl::convert_to_c(direction), &src_layer_desc.data,
9081  &src_iter_desc.data, &weights_layer_desc.data,
9082  &weights_iter_desc.data, &bias_desc.data,
9083  &dst_layer_desc.data, &dst_iter_desc.data,
9084  dnnl::convert_to_c(flags)),
9085  "could not create a descriptor for an LBR GRU forward "
9086  "propagation primitive");
9087  }
9088  };
9089 
9093  primitive_desc() = default;
9094 
9105  primitive_desc(const desc &adesc, const engine &aengine,
9106  bool allow_empty = false)
9108  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
9109 
9121  primitive_desc(const desc &adesc, const primitive_attr &attr,
9122  const engine &aengine, bool allow_empty = false)
9124  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
9125 
9135  dnnl::algorithm::lbr_gru) {}
9136 
9139  return rnn_base::src_layer_desc();
9140  }
9141 
9144 
9148  }
9149 
9152  return rnn_base::weights_iter_desc();
9153  }
9154 
9157 
9160  return rnn_base::dst_layer_desc();
9161  }
9162 
9165 
9168  return rnn_base::workspace_desc();
9169  }
9170  };
9171 
9173  lbr_gru_forward() = default;
9174 
9179 };
9180 
9182 struct lbr_gru_backward : public primitive {
9184  struct desc {
9185  dnnl_rnn_desc_t data;
9186 
9232  desc(prop_kind aprop_kind, rnn_direction direction,
9233  const memory::desc &src_layer_desc,
9234  const memory::desc &src_iter_desc,
9235  const memory::desc &weights_layer_desc,
9236  const memory::desc &weights_iter_desc,
9237  const memory::desc &bias_desc,
9238  const memory::desc &dst_layer_desc,
9239  const memory::desc &dst_iter_desc,
9240  const memory::desc &diff_src_layer_desc,
9241  const memory::desc &diff_src_iter_desc,
9242  const memory::desc &diff_weights_layer_desc,
9243  const memory::desc &diff_weights_iter_desc,
9244  const memory::desc &diff_bias_desc,
9245  const memory::desc &diff_dst_layer_desc,
9246  const memory::desc &diff_dst_iter_desc,
9247  rnn_flags flags = rnn_flags::undef) {
9250  dnnl::convert_to_c(aprop_kind),
9251  dnnl::convert_to_c(direction), &src_layer_desc.data,
9252  &src_iter_desc.data, &weights_layer_desc.data,
9253  &weights_iter_desc.data, &bias_desc.data,
9254  &dst_layer_desc.data, &dst_iter_desc.data,
9255  &diff_src_layer_desc.data, &diff_src_iter_desc.data,
9256  &diff_weights_layer_desc.data,
9257  &diff_weights_iter_desc.data, &diff_bias_desc.data,
9258  &diff_dst_layer_desc.data, &diff_dst_iter_desc.data,
9259  dnnl::convert_to_c(flags)),
9260  "could not create a descriptor for an LBR GRU backward "
9261  "propagation primitive");
9262  }
9263  };
9264 
9268  primitive_desc() = default;
9269 
9283  primitive_desc(const desc &adesc, const engine &aengine,
9284  const lbr_gru_forward::primitive_desc &hint_fwd_pd,
9285  bool allow_empty = false)
9286  : rnn_primitive_desc_base(&adesc.data, nullptr, aengine,
9287  hint_fwd_pd.get(), allow_empty) {}
9288 
9303  primitive_desc(const desc &adesc, const primitive_attr &attr,
9304  const engine &aengine,
9305  const lbr_gru_forward::primitive_desc &hint_fwd_pd,
9306  bool allow_empty = false)
9307  : rnn_primitive_desc_base(&adesc.data, &attr, aengine,
9308  hint_fwd_pd.get(), allow_empty) {}
9309 
9319 
9322  return rnn_base::src_layer_desc();
9323  }
9324 
9327 
9331  }
9332 
9335  return rnn_base::weights_iter_desc();
9336  }
9337 
9340 
9343  return rnn_base::dst_layer_desc();
9344  }
9345 
9348 
9351  return rnn_base::workspace_desc();
9352  }
9353 
9357  }
9358 
9362  }
9363 
9367  }
9368 
9372  }
9373 
9376  return rnn_base::diff_bias_desc();
9377  }
9378 
9382  }
9383 
9387  }
9388  };
9389 
9391  lbr_gru_backward() = default;
9392 
9397 };
9398 
9400 
9408 
9410 struct shuffle_forward : public primitive {
9412  struct desc {
9413  dnnl_shuffle_desc_t data;
9414 
9424  desc(prop_kind aprop_kind, const memory::desc &data_desc, int axis,
9425  int group_size) {
9427  dnnl::convert_to_c(aprop_kind),
9428  &data_desc.data, axis, group_size),
9429  "could not create a descriptor for a shuffle forward "
9430  "propagation primitive");
9431  }
9432  };
9433 
9437  primitive_desc() = default;
9438 
9450  primitive_desc(const desc &adesc, const engine &aengine,
9451  const primitive_attr &attr = primitive_attr(),
9452  bool allow_empty = false)
9453  : dnnl::primitive_desc(
9454  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
9455 
9463  : dnnl::primitive_desc(pd, dnnl::primitive::kind::shuffle,
9466 
9468  memory::desc src_desc() const { return base::src_desc(0); }
9469 
9471  memory::desc dst_desc() const { return base::dst_desc(0); }
9472  };
9473 
9475  shuffle_forward() = default;
9476 
9481 };
9482 
9484 struct shuffle_backward : public primitive {
9487  struct desc {
9488  dnnl_shuffle_desc_t data;
9489 
9497  desc(const memory::desc &diff_data_desc, int axis, int group_size) {
9499  &diff_data_desc.data, axis, group_size),
9500  "could not create a descriptor for a shuffle backward "
9501  "propagation primitive");
9502  }
9503  };
9504 
9508  primitive_desc() = default;
9509 
9524  primitive_desc(const desc &adesc, const engine &aengine,
9525  const shuffle_forward::primitive_desc &hint_fwd_pd,
9526  const primitive_attr &attr = primitive_attr(),
9527  bool allow_empty = false)
9528  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
9529  hint_fwd_pd.get(), allow_empty) {}
9530 
9538  : dnnl::primitive_desc(pd, dnnl::primitive::kind::shuffle,
9540 
9543 
9546  };
9547 
9549  shuffle_backward() = default;
9550 
9555 };
9556 
9558 
9566 
9568 struct binary : public primitive {
9570  struct desc {
9573 
9575  desc() = default;
9576 
9584  desc(algorithm aalgorithm, const memory::desc &src0,
9585  const memory::desc &src1, const memory::desc &dst) {
9588  &src0.data, &src1.data, &dst.data),
9589  "could not create a descriptor for a binary operation "
9590  "primitive");
9591  }
9592  };
9593 
9597  primitive_desc() = default;
9598 
9608  primitive_desc(const desc &adesc, const engine &aengine,
9609  bool allow_empty = false)
9610  : dnnl::primitive_desc(
9611  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
9612 
9623  primitive_desc(const desc &adesc, const primitive_attr &attr,
9624  const engine &aengine, bool allow_empty = false)
9625  : dnnl::primitive_desc(
9626  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
9627 
9634 
9636  memory::desc src_desc(int idx = 0) const { return base::src_desc(idx); }
9637 
9639  memory::desc src0_desc() const { return base::src_desc(0); }
9640 
9642  memory::desc src1_desc() const { return base::src_desc(1); }
9643 
9645  memory::desc dst_desc() const { return base::dst_desc(0); }
9646  };
9647 
9649  binary() = default;
9650 
9654  binary(const primitive_desc &pd) : primitive(pd) {}
9655 };
9656 
9658 
9668 
9670 struct matmul : public primitive {
9672  struct desc {
9673  dnnl_matmul_desc_t data;
9674 
9680  desc(const memory::desc &src_desc, const memory::desc &weights_desc,
9681  const memory::desc &dst_desc) {
9683  dnnl_matmul_desc_init(&data, &src_desc.data,
9684  &weights_desc.data, nullptr, &dst_desc.data),
9685  "could not create a descriptor for a matmul primitive");
9686  }
9687 
9694  desc(const memory::desc &src_desc, const memory::desc &weights_desc,
9695  const memory::desc &bias_desc, const memory::desc &dst_desc) {
9696  error::wrap_c_api(dnnl_matmul_desc_init(&data, &src_desc.data,
9697  &weights_desc.data, &bias_desc.data,
9698  &dst_desc.data),
9699  "could not create a descriptor for a matmul primitive");
9700  }
9701  };
9702 
9706  primitive_desc() = default;
9707 
9716  primitive_desc(const desc &adesc, const engine &aengine,
9717  bool allow_empty = false)
9718  : dnnl::primitive_desc(
9719  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
9720 
9730  primitive_desc(const desc &adesc, const primitive_attr &attr,
9731  const engine &aengine, bool allow_empty = false)
9732  : dnnl::primitive_desc(
9733  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
9734 
9741 
9744 
9747  return query_md(query::weights_md, 0);
9748  }
9749 
9752  return query_md(query::weights_md, 1);
9753  }
9754 
9757  };
9758 
9760  matmul() = default;
9761 
9764  matmul(const primitive_desc &pd) : primitive(pd) {}
9765 };
9766 
9768 
9778 
9782  struct desc {
9784 
9800  desc(prop_kind aprop_kind, algorithm aalgorithm,
9801  const memory::desc &src_desc, const memory::desc &dst_desc) {
9803  dnnl::convert_to_c(aprop_kind),
9804  convert_to_c(aalgorithm), nullptr,
9805  &src_desc.data, &dst_desc.data),
9806  "could not create a resampling forward descriptor");
9807  }
9808 
9820  desc(prop_kind aprop_kind, algorithm aalgorithm,
9821  const std::vector<float> &factors,
9822  const memory::desc &src_desc) {
9823  memory::validate_dims(factors, src_desc.data.ndims - 2);
9825  dnnl::convert_to_c(aprop_kind),
9826  convert_to_c(aalgorithm), &factors[0],
9827  &src_desc.data, nullptr),
9828  "could not create a resampling forward descriptor");
9829  }
9830 
9847  desc(prop_kind aprop_kind, algorithm aalgorithm,
9848  const std::vector<float> &factors, const memory::desc &src_desc,
9849  const memory::desc &dst_desc) {
9850  if (!factors.empty())
9851  memory::validate_dims(factors, src_desc.data.ndims - 2);
9853  dnnl::convert_to_c(aprop_kind),
9854  convert_to_c(aalgorithm), factors.data(),
9855  &src_desc.data, &dst_desc.data),
9856  "could not create a resampling forward descriptor");
9857  }
9858  };
9859 
9863  primitive_desc() = default;
9864 
9875  primitive_desc(const desc &adesc, const engine &aengine,
9876  bool allow_empty = false)
9877  : dnnl::primitive_desc(
9878  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
9879 
9891  primitive_desc(const desc &adesc, const primitive_attr &attr,
9892  const engine &aengine, bool allow_empty = false)
9893  : dnnl::primitive_desc(
9894  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
9895 
9903  : dnnl::primitive_desc(pd, dnnl::primitive::kind::resampling,
9906 
9908  memory::desc src_desc() const { return base::src_desc(0); }
9909 
9911  memory::desc dst_desc() const { return base::dst_desc(0); }
9912  };
9913 
9915  resampling_forward() = default;
9916 
9921 };
9922 
9926  struct desc {
9928 
9937  desc(algorithm aalgorithm, const memory::desc &diff_src_desc,
9938  const memory::desc &diff_dst_desc) {
9940  convert_to_c(aalgorithm), nullptr,
9941  &diff_src_desc.data, &diff_dst_desc.data),
9942  "could not create a resampling backward data descriptor");
9943  }
9944 
9954  desc(algorithm aalgorithm, const std::vector<float> &factors,
9955  const memory::desc &diff_src_desc,
9956  const memory::desc &diff_dst_desc) {
9957  if (!factors.empty())
9958  memory::validate_dims(factors, diff_src_desc.data.ndims - 2);
9960  convert_to_c(aalgorithm), factors.data(),
9961  &diff_src_desc.data, &diff_dst_desc.data),
9962  "could not create a resampling backward data descriptor");
9963  }
9964  };
9965 
9969  primitive_desc() = default;
9970 
9984  primitive_desc(const desc &adesc, const engine &aengine,
9985  const resampling_forward::primitive_desc &hint_fwd_pd,
9986  bool allow_empty = false)
9987  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
9988  hint_fwd_pd.get(), allow_empty) {}
9989 
10004  primitive_desc(const desc &adesc, const primitive_attr &attr,
10005  const engine &aengine,
10006  const resampling_forward::primitive_desc &hint_fwd_pd,
10007  bool allow_empty = false)
10008  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
10009  hint_fwd_pd.get(), allow_empty) {}
10010 
10018  : dnnl::primitive_desc(pd, dnnl::primitive::kind::resampling,
10020 
10023 
10026  };
10027 
10029  resampling_backward() = default;
10030 
10035 };
10036 
10038 
10048 
10052  struct desc {
10054 
10081  desc(prop_kind aprop_kind, algorithm aalgorithm,
10082  const memory::desc &src_desc, const memory::desc &dst_desc,
10083  const memory::dims &strides, const memory::dims &kernel,
10084  const memory::dims &dilation, const memory::dims &padding_l,
10085  const memory::dims &padding_r) {
10086  memory::validate_dims(strides, src_desc.data.ndims - 2);
10087  memory::validate_dims(kernel, src_desc.data.ndims - 2);
10088  memory::validate_dims(padding_l, src_desc.data.ndims - 2);
10089  memory::validate_dims(padding_r, src_desc.data.ndims - 2);
10090  memory::validate_dims(dilation, src_desc.data.ndims - 2);
10093  dnnl::convert_to_c(aprop_kind),
10094  convert_to_c(aalgorithm), &src_desc.data,
10095  &dst_desc.data, &strides[0], &kernel[0],
10096  &dilation[0], &padding_l[0], &padding_r[0]),
10097  "could not create a descriptor for a pooling forward "
10098  "propagation primitive");
10099  }
10100  };
10101 
10105  primitive_desc() = default;
10106 
10117  primitive_desc(const desc &adesc, const engine &aengine,
10118  bool allow_empty = false)
10119  : dnnl::primitive_desc(
10120  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
10121 
10133  primitive_desc(const desc &adesc, const primitive_attr &attr,
10134  const engine &aengine, bool allow_empty = false)
10135  : dnnl::primitive_desc(
10136  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
10137 
10146  : dnnl::primitive_desc(pd, dnnl::primitive::kind::pooling_v2,
10149 
10151  memory::desc src_desc() const { return base::src_desc(0); }
10152 
10154  memory::desc dst_desc() const { return base::dst_desc(0); }
10155 
10158  };
10159 
10161  pooling_v2_forward() = default;
10162 
10168 };
10169 
10173  struct desc {
10175 
10199  desc(algorithm aalgorithm, const memory::desc &diff_src_desc,
10200  const memory::desc &diff_dst_desc, const memory::dims &strides,
10201  const memory::dims &kernel, const memory::dims &dilation,
10202  const memory::dims &padding_l, const memory::dims &padding_r) {
10203  memory::validate_dims(strides, diff_src_desc.data.ndims - 2);
10204  memory::validate_dims(kernel, diff_src_desc.data.ndims - 2);
10205  memory::validate_dims(padding_l, diff_src_desc.data.ndims - 2);
10206  memory::validate_dims(padding_r, diff_src_desc.data.ndims - 2);
10207  memory::validate_dims(dilation, diff_src_desc.data.ndims - 2);
10210  convert_to_c(aalgorithm), &diff_src_desc.data,
10211  &diff_dst_desc.data, &strides[0], &kernel[0],
10212  &dilation[0], &padding_l[0], &padding_r[0]),
10213  "could not create a descriptor for a pooling backward "
10214  "propagation primitive");
10215  }
10216  };
10217 
10222  primitive_desc() = default;
10223 
10237  primitive_desc(const desc &adesc, const engine &aengine,
10238  const pooling_v2_forward::primitive_desc &hint_fwd_pd,
10239  bool allow_empty = false)
10240  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
10241  hint_fwd_pd.get(), allow_empty) {}
10242 
10257  primitive_desc(const desc &adesc, const primitive_attr &attr,
10258  const engine &aengine,
10259  const pooling_v2_forward::primitive_desc &hint_fwd_pd,
10260  bool allow_empty = false)
10261  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
10262  hint_fwd_pd.get(), allow_empty) {}
10263 
10272  : dnnl::primitive_desc(pd, dnnl::primitive::kind::pooling_v2,
10274 
10277 
10280 
10283  };
10284 
10286  pooling_v2_backward() = default;
10287 
10293 };
10294 
10296 
10305 
10307 struct prelu_forward : public primitive {
10309  struct desc {
10310  dnnl_prelu_desc_t data;
10311 
10320  desc(prop_kind aprop_kind, const memory::desc &data_desc,
10321  const memory::desc &weight_desc) {
10323  dnnl::convert_to_c(aprop_kind),
10324  &data_desc.data, &weight_desc.data),
10325  "could not create a descriptor for a prelu forward "
10326  "propagation primitive");
10327  }
10328  };
10329 
10333  primitive_desc() = default;
10334 
10345  primitive_desc(const desc &adesc, const engine &aengine,
10346  bool allow_empty = false)
10347  : dnnl::primitive_desc(
10348  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
10349 
10361  primitive_desc(const desc &adesc, const primitive_attr &attr,
10362  const engine &aengine, bool allow_empty = false)
10363  : dnnl::primitive_desc(
10364  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
10365 
10373  : dnnl::primitive_desc(pd, dnnl::primitive::kind::prelu,
10376 
10378  memory::desc src_desc() const { return base::src_desc(0); }
10379 
10381  memory::desc dst_desc() const { return base::dst_desc(0); }
10382  };
10383 
10385  prelu_forward() = default;
10386 
10391 };
10392 
10394 struct prelu_backward : public primitive {
10396  struct desc {
10397  dnnl_prelu_desc_t data;
10398 
10407  desc(const memory::desc &data_desc, const memory::desc &weight_desc,
10408  const memory::desc &diff_data_desc,
10409  const memory::desc &diff_weights_desc) {
10411  dnnl_prelu_backward_desc_init(&data, &data_desc.data,
10412  &weight_desc.data, &diff_data_desc.data,
10413  &diff_weights_desc.data),
10414  "could not create a descriptor for a prelu backward "
10415  "propagation primitive");
10416  }
10417  };
10418 
10422  primitive_desc() = default;
10423 
10437  primitive_desc(const desc &adesc, const engine &aengine,
10438  const prelu_forward::primitive_desc &hint_fwd_pd,
10439  bool allow_empty = false)
10440  : dnnl::primitive_desc(&adesc.data, nullptr, aengine,
10441  hint_fwd_pd.get(), allow_empty) {}
10442 
10457  primitive_desc(const desc &adesc, const primitive_attr &attr,
10458  const engine &aengine,
10459  const prelu_forward::primitive_desc &hint_fwd_pd,
10460  bool allow_empty = false)
10461  : dnnl::primitive_desc(&adesc.data, &attr, aengine,
10462  hint_fwd_pd.get(), allow_empty) {}
10463 
10471  : dnnl::primitive_desc(pd, dnnl::primitive::kind::prelu,
10473 
10475  memory::desc src_desc() const { return base::src_desc(0); }
10476 
10479 
10482  };
10483 
10485  prelu_backward() = default;
10486 
10491 };
10492 
10494 
10503 
10505 struct reduction : public primitive {
10507  struct desc {
10508  dnnl_reduction_desc_t data;
10509 
10511  desc() = default;
10512 
10530  desc(algorithm aalgorithm, const memory::desc &src_desc,
10531  const memory::desc &dst_desc, float p, float eps) {
10533  dnnl_reduction_desc_init(&data, convert_to_c(aalgorithm),
10534  &src_desc.data, &dst_desc.data, p, eps),
10535  "could not create a reduction descriptor");
10536  }
10537  };
10538 
10542  primitive_desc() = default;
10543 
10552  primitive_desc(const desc &adesc, const engine &aengine,
10553  bool allow_empty = false)
10554  : dnnl::primitive_desc(
10555  &adesc.data, nullptr, aengine, nullptr, allow_empty) {}
10556 
10566  primitive_desc(const desc &adesc, const primitive_attr &attr,
10567  const engine &aengine, bool allow_empty = false)
10568  : dnnl::primitive_desc(
10569  &adesc.data, &attr, aengine, nullptr, allow_empty) {}
10570 
10577 
10579  memory::desc src_desc() const { return base::src_desc(0); }
10580 
10582  memory::desc dst_desc() const { return base::dst_desc(0); }
10583  };
10584 
10586  reduction() = default;
10587 
10590  reduction(const primitive_desc &pd) : primitive(pd) {}
10591 };
10592 
10594 
10596 
10602 
10605 
10607 enum class status {
10622 };
10623 
10625 inline status set_verbose(int level) {
10626  return static_cast<status>(dnnl_set_verbose(level));
10627 }
10628 
10630 inline const version_t *version() {
10631  return dnnl_version();
10632 }
10633 
10635 inline status set_jit_dump(int enable) {
10636  return static_cast<status>(dnnl_set_jit_dump(enable));
10637 }
10638 
10640 inline status set_jit_profiling_flags(unsigned flags) {
10641  return static_cast<status>(dnnl_set_jit_profiling_flags(flags));
10642 }
10643 
10645 inline status set_jit_profiling_jitdumpdir(const std::string &dir) {
10646  return static_cast<status>(dnnl_set_jit_profiling_jitdumpdir(dir.c_str()));
10647 }
10648 
10650 enum class cpu_isa {
10673 };
10674 
10677  return static_cast<status>(
10678  dnnl_set_max_cpu_isa(static_cast<dnnl_cpu_isa_t>(isa)));
10679 }
10680 
10683  return static_cast<cpu_isa>(dnnl_get_effective_cpu_isa());
10684 }
10685 
10687 
10693 
10697  int result = 0;
10699  "could not get primitive cache capacity");
10700  return result;
10701 }
10702 
10704 inline void set_primitive_cache_capacity(int capacity) {
10706  "could not set primitive cache capacity");
10707 }
10708 
10710 
10717 
10719 inline status sgemm(char transa, char transb, dnnl_dim_t M, dnnl_dim_t N,
10720  dnnl_dim_t K, float alpha, const float *A, dnnl_dim_t lda,
10721  const float *B, dnnl_dim_t ldb, float beta, float *C, dnnl_dim_t ldc) {
10722  return static_cast<status>(dnnl_sgemm(
10723  transa, transb, M, N, K, alpha, A, lda, B, ldb, beta, C, ldc));
10724 }
10725 
10727 inline status gemm_u8s8s32(char transa, char transb, char offsetc, dnnl_dim_t M,
10728  dnnl_dim_t N, dnnl_dim_t K, float alpha, const uint8_t *A,
10729  dnnl_dim_t lda, uint8_t ao, const int8_t *B, dnnl_dim_t ldb, int8_t bo,
10730  float beta, int32_t *C, dnnl_dim_t ldc, const int32_t *co) {
10731  return static_cast<status>(dnnl_gemm_u8s8s32(transa, transb, offsetc, M, N,
10732  K, alpha, A, lda, ao, B, ldb, bo, beta, C, ldc, co));
10733 }
10734 
10736 inline status gemm_s8s8s32(char transa, char transb, char offsetc, dnnl_dim_t M,
10737  dnnl_dim_t N, dnnl_dim_t K, float alpha, const int8_t *A,
10738  dnnl_dim_t lda, int8_t ao, const int8_t *B, dnnl_dim_t ldb, int8_t bo,
10739  float beta, int32_t *C, dnnl_dim_t ldc, const int32_t *co) {
10740  return static_cast<status>(dnnl_gemm_s8s8s32(transa, transb, offsetc, M, N,
10741  K, alpha, A, lda, ao, B, ldb, bo, beta, C, ldc, co));
10742 }
10743 
10745 
10746 // implementation section
10747 
10750  dnnl_primitive_t result;
10752  "could not create a primitive");
10753  reset(result);
10754 }
10755 
10756 inline primitive::primitive(const primitive_desc &pd) : primitive(pd.get()) {}
10757 
10758 inline void primitive::execute(const stream &astream,
10759  const std::unordered_map<int, memory> &args) const {
10760  std::vector<dnnl_exec_arg_t> c_args;
10761  c_args.reserve(args.size());
10762  for (const auto &a : args)
10763  c_args.push_back({a.first, a.second.get(true)});
10764 
10765  error::wrap_c_api(dnnl_primitive_execute(get(), astream.get(),
10766  (int)c_args.size(), c_args.data()),
10767  "could not execute a primitive");
10768 }
10769 
10771 
10772 #undef DNNL_DEFINE_BITMASK_OPS
10773 
10774 } // namespace dnnl
10775 
10777 namespace oneapi {
10779 namespace dnnl = ::dnnl;
10780 } // namespace oneapi
10781 
10783 
10784 #endif /* ONEAPI_DNNL_DNNL_HPP */
desc(prop_kind aprop_kind, const memory::desc &data_desc, float epsilon, normalization_flags flags)
Constructs a descriptor for layer normalization forward propagation primitive.
Definition: dnnl.hpp:6609
#define DNNL_ARG_WEIGHTS_PROJECTION
A special mnemonic for RNN weights applied to the projection weights.
Definition: dnnl_types.h:2179
Layer normalization forward propagation primitive.
Definition: dnnl.hpp:6572
dnnl_status_t DNNL_API dnnl_primitive_attr_create(dnnl_primitive_attr_t *attr)
Creates an empty (default) primitive attributes with all the parameters set to their default values...
Reduction using sum.
Definition: dnnl_types.h:1054
pooling_v2_backward()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_post_ops_get_params_dw_k3s1p1(const_dnnl_post_ops_t post_ops, int index, dnnl_data_type_t *weights_data_type, dnnl_data_type_t *bias_data_type, dnnl_data_type_t *dst_data_type, dnnl_dim_t *count, int *mask, const float **scales)
Returns the parameters of an depthwise post-op with stride 1.
primitive_desc(const desc &adesc, const engine &aengine, const shuffle_forward::primitive_desc &hint_fwd_pd, const primitive_attr &attr=primitive_attr(), bool allow_empty=false)
Constructs a primitive descriptor for a shuffle backward propagation primitive.
Definition: dnnl.hpp:9524
A layer normalization primitive.
Definition: dnnl_types.h:914
desc(prop_kind aprop_kind, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc)
Constructs a descriptor for an inner product forward propagation primitive with bias.
Definition: dnnl.hpp:6900
dnnl_status_t DNNL_API dnnl_primitive_attr_set_rnn_data_qparams(dnnl_primitive_attr_t attr, const float scale, const float shift)
Set quantization scale and shift parameters for RNN data tensors.
dnnl_status_t DNNL_API dnnl_post_ops_get_params_dw_k3s2p1(const_dnnl_post_ops_t post_ops, int index, dnnl_data_type_t *weights_data_type, dnnl_data_type_t *bias_data_type, dnnl_data_type_t *dst_data_type, dnnl_dim_t *count, int *mask, const float **scales)
Returns the parameters of an depthwise post-op with stride 2.
plain 7D tensor
Definition: dnnl_types.h:184
deconvolution_forward(const primitive_desc &pd)
Constructs a deconvolution forward propagation primitive.
Definition: dnnl.hpp:4759
rnn_primitive_desc_base(dnnl_primitive_desc_t pd, dnnl::prop_kind aprop_kind, dnnl::algorithm cell_kind)
Constructs an RNN primitive descriptor base from a C API primitive descriptor while checking that it ...
Definition: dnnl.hpp:7263
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a reduction primitive from a C API primitive descriptor that mu...
Definition: dnnl.hpp:10575
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a matmul primitive.
Definition: dnnl.hpp:9716
destination grad. memory desc
Definition: dnnl_types.h:2394
void * get_data_handle() const
Returns the underlying memory buffer.
Definition: dnnl.hpp:2105
An element-wise primitive.
Definition: dnnl_types.h:904
flags
Stream flags. Can be combined using the bitwise OR operator.
Definition: dnnl.hpp:983
memory::desc diff_weights_desc() const
Returns a diff weights memory descriptor.
Definition: dnnl.hpp:5171
Reduction using mean operation.
Primitive descriptor for a shuffle forward propagation primitive.
Definition: dnnl.hpp:9435
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated convolution forward propagation primitive without bias...
Definition: dnnl.hpp:3956
dnnl_status_t DNNL_API dnnl_lstm_forward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *src_iter_c_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *dst_iter_c_desc, unsigned flags)
Initializes a descriptor for LSTM forward propagation primitive.
Elementwise: soft_relu.
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an inner product forward propagation primitive.
Definition: dnnl.hpp:6951
lrn_backward(const primitive_desc &pd)
Constructs an LRN backward propagation primitive.
Definition: dnnl.hpp:5398
Reduction using lp norm without final pth-root.
Definition: dnnl_types.h:1064
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for reorder primitive from a C API primitive descriptor which must ...
Definition: dnnl.hpp:3434
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a softmax forward propagation primitive.
Definition: dnnl.hpp:5927
prop_kind
Propagation kind.
Definition: dnnl.hpp:435
engine get_engine() const
Returns the associated engine.
Definition: dnnl.hpp:1010
6D tensor blocked by 3rd dimension with block size 4
Definition: dnnl_types.h:391
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:7595
memory::desc diff_dst_desc(int idx) const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:3142
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:9743
memory::desc src_iter_c_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8555
dnnl_status_t DNNL_API dnnl_gemm_s8s8s32(char transa, char transb, char offsetc, dnnl_dim_t M, dnnl_dim_t N, dnnl_dim_t K, float alpha, const int8_t *A, dnnl_dim_t lda, int8_t ao, const int8_t *B, dnnl_dim_t ldb, int8_t bo, float beta, int32_t *C, dnnl_dim_t ldc, const int32_t *co)
Performs integer matrix-matrix multiply on 8-bit signed matrix A, 8-bit signed matrix B...
execution engine
Definition: dnnl_types.h:2342
permuted 6D tensor
Definition: dnnl_types.h:195
A batch normalization primitive.
Definition: dnnl_types.h:912
sum()=default
Default constructor. Produces an empty object.
desc(const memory::desc &diff_src_desc, const memory::desc &weights_desc, const memory::desc &diff_dst_desc)
Constructs a descriptor for an inner product backward propagation primitive.
Definition: dnnl.hpp:7021
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a vanilla RNN forward propagation primitive.
Definition: dnnl.hpp:7557
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:6044
primitive_desc()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_primitive_desc_get_attr(const_dnnl_primitive_desc_t primitive_desc, const_dnnl_primitive_attr_t *attr)
Returns a constant reference to the attributes of a primitive descriptor.
Deconvolution forward propagation primitive.
Definition: dnnl.hpp:4498
Eltwise: bounded_relu.
Definition: dnnl_types.h:969
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:9151
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5281
Undefined memory format tag.
Definition: dnnl_types.h:169
3D tensor blocked by 2nd dimension with block size 16
Definition: dnnl_types.h:231
shuffle_backward(const primitive_desc &pd)
Constructs a shuffle backward propagation primitive.
Definition: dnnl.hpp:9554
A tensor in a generic format described by the stride and blocking values in each dimension.
Definition: dnnl_types.h:89
memory::desc diff_dst_iter_desc() const
Returns diff destination iteration memory descriptor.
Definition: dnnl.hpp:8646
Primitive descriptor for a pooling forward propagation primitive.
Definition: dnnl.hpp:5460
scratchpad memory desc
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an inner product forward propagation primitive.
Definition: dnnl.hpp:6967
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a convolution backward propagation primitive from a C API primi...
Definition: dnnl.hpp:4194
Descriptor for a vanilla RNN backward propagation primitive.
Definition: dnnl.hpp:7620
CPU engine.
Definition: dnnl_types.h:1976
inner_product_backward_data()=default
Default constructor. Produces an empty object.
primitive_desc()=default
Default constructor. Produces an empty object.
Eltwise: ReLU (dst for backward)
Definition: dnnl_types.h:996
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:9471
dnnl_status_t DNNL_API dnnl_convolution_backward_weights_desc_init(dnnl_convolution_desc_t *conv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *diff_weights_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a convolution weights gradient primitive.
dnnl_status_t DNNL_API dnnl_gemm_u8s8s32(char transa, char transb, char offsetc, dnnl_dim_t M, dnnl_dim_t N, dnnl_dim_t K, float alpha, const uint8_t *A, dnnl_dim_t lda, uint8_t ao, const int8_t *B, dnnl_dim_t ldb, int8_t bo, float beta, int32_t *C, dnnl_dim_t ldc, const int32_t *co)
Performs integer matrix-matrix multiply on 8-bit unsigned matrix A, 8-bit signed matrix B...
#define DNNL_ARG_DIFF_WEIGHTS_ITER
A special mnemonic for diff of RNN weights applied to the recurrent input.
Definition: dnnl_types.h:2253
destination memory desc
Definition: dnnl_types.h:2393
Direct deconvolution.
Definition: dnnl_types.h:951
Elementwise: exponential linear unit (ELU)
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc()=default
Default constructor. Produces an empty object.
A descriptor for an RNN operation.
Definition: dnnl_types.h:1778
Descriptor for reduction.
Definition: dnnl.hpp:10507
The user manages the scratchpad allocation by querying and providing the scratchpad memory to primiti...
Definition: dnnl_types.h:2048
The operation failed due to an out-of-memory condition.
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:8565
layer normalization descriptor
Definition: dnnl_types.h:2376
gru_backward(const primitive_desc &pd)
Constructs a GRU backward propagation primitive.
Definition: dnnl.hpp:9026
memory::desc diff_weights_peephole_desc() const
Returns diff weights peephole memory descriptor.
Definition: dnnl.hpp:7373
Elementwise: erf-based gelu.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a pooling v2 (dilated pooling) backward propagation primitive f...
Definition: dnnl.hpp:10271
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a reduction primitive.
Definition: dnnl.hpp:10566
A pooling version 2 primitive.
memory consumption – extra
Definition: dnnl_types.h:2349
Average pooling exclude padding, alias for dnnl::algorithm::pooling_avg_include_padding.
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:7289
status gemm_s8s8s32(char transa, char transb, char offsetc, dnnl_dim_t M, dnnl_dim_t N, dnnl_dim_t K, float alpha, const int8_t *A, dnnl_dim_t lda, int8_t ao, const int8_t *B, dnnl_dim_t ldb, int8_t bo, float beta, int32_t *C, dnnl_dim_t ldc, const int32_t *co)
Performs integer matrix-matrix multiply on 8-bit signed matrix A, 8-bit signed matrix B...
Definition: dnnl.hpp:10736
dnnl_primitive_kind_t
Kinds of primitives.
Definition: dnnl_types.h:888
A resampling primitive.
void get_params_dw_k3s1p1(int index, memory::data_type &weights_data_type, memory::data_type &bias_data_type, memory::data_type &dst_data_type, int &mask, std::vector< float > &scales) const
Returns the parameters of an depthwise post-op with stride 1.
Definition: dnnl.hpp:2442
Average pooling include padding.
desc(algorithm aalgorithm, const memory::desc &data_desc, const memory::desc &diff_data_desc, memory::dim local_size, float alpha, float beta, float k=1.f)
Constructs a descriptor for an LRN backward propagation primitive.
Definition: dnnl.hpp:5317
primitive_desc(const desc &adesc, const engine &aengine, const inner_product_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an inner product backward propagation primitive.
Definition: dnnl.hpp:7051
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &kernel, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for pooling forward propagation primitive.
Definition: dnnl.hpp:5441
eltwise_forward()=default
Default constructor. Produces an empty object.
permuted 3D tensor
Definition: dnnl_types.h:203
Eltwise: linear.
Definition: dnnl_types.h:967
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a batch normalization backward propagation primitive from a C A...
Definition: dnnl.hpp:6500
A PReLU primitive.
Definition: dnnl_types.h:934
Primitive descriptor for a convolution backward propagation primitive.
Definition: dnnl.hpp:4144
softmax_backward(const primitive_desc &pd)
Constructs a softmax backward propagation primitive.
Definition: dnnl.hpp:6056
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:5284
Bidirectional execution of RNN primitive with concatenation of the results.
Primitive descriptor for a pooling backward propagation primitive.
Definition: dnnl.hpp:5569
desc(prop_kind aprop_kind, algorithm activation, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags=rnn_flags::undef, float alpha=0.0f, float beta=0.0f)
Constructs a descriptor for a vanilla RNN forward propagation primitive.
Definition: dnnl.hpp:7502
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:10579
permuted 6D tensor
Definition: dnnl_types.h:199
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:8139
dnnl_status_t DNNL_API dnnl_post_ops_get_params_binary(const_dnnl_post_ops_t post_ops, int index, dnnl_alg_kind_t *alg_kind, const dnnl_memory_desc_t **src1_desc)
Returns the parameters of a binary post-op.
memory::desc weights_projection_desc() const
Returns weights projection memory descriptor.
Definition: dnnl.hpp:8575
prelu_forward(const primitive_desc &pd)
Constructs a prelu forward propagation primitive.
Definition: dnnl.hpp:10390
permuted 12D tensor
Definition: dnnl_types.h:222
Elementwise: logistic (dst for backward)
memory::desc diff_weights_desc() const
Returns a diff weights memory descriptor.
Definition: dnnl.hpp:6845
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:7095
void set_scratchpad_mode(scratchpad_mode mode)
Sets scratchpad mode.
Definition: dnnl.hpp:2633
vanilla_rnn_backward()=default
Default constructor. Produces an empty object.
A resampling primitive.
Definition: dnnl_types.h:928
shuffle_forward(const primitive_desc &pd)
Constructs a shuffle forward propagation primitive.
Definition: dnnl.hpp:9480
logsoftmax_backward(const primitive_desc &pd)
Constructs a logsoftmax backward propagation primitive.
Definition: dnnl.hpp:6264
An opaque structure to describe a primitive.
GRU cell with linear before reset.
Definition: dnnl_types.h:1032
deconvolution_backward_weights(const primitive_desc &pd)
Constructs a deconvolution weights gradient primitive.
Definition: dnnl.hpp:5190
oneDNN namespace
Definition: dnnl.hpp:74
Descriptor for a convolution forward propagation primitive.
Definition: dnnl.hpp:3779
Any ISA (excepting those listed as initial support)
Definition: dnnl_types.h:2498
memory::desc diff_weights_desc() const
Returns a diff weights memory descriptor.
Definition: dnnl.hpp:6522
Undefined data type, used for empty memory descriptors.
Definition: dnnl_types.h:64
primitive_desc()=default
Default constructor. Produces an empty object.
status set_max_cpu_isa(cpu_isa isa)
Sets the maximal ISA the library can dispatch to on the CPU.
Definition: dnnl.hpp:10676
desc(algorithm aalgorithm, const memory::desc &diff_src_desc, const memory::desc &weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a deconvolution backward propagation primitive.
Definition: dnnl.hpp:4792
dnnl_status_t DNNL_API dnnl_lstm_backward_desc_init_v2(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *src_iter_c_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *weights_peephole_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *dst_iter_c_desc, const dnnl_memory_desc_t *diff_src_layer_desc, const dnnl_memory_desc_t *diff_src_iter_desc, const dnnl_memory_desc_t *diff_src_iter_c_desc, const dnnl_memory_desc_t *diff_weights_layer_desc, const dnnl_memory_desc_t *diff_weights_iter_desc, const dnnl_memory_desc_t *diff_weights_peephole_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_layer_desc, const dnnl_memory_desc_t *diff_dst_iter_desc, const dnnl_memory_desc_t *diff_dst_iter_c_desc, unsigned flags)
Initializes a descriptor for an LSTM (with or without peephole) backward propagation primitive...
static engine query(const primitive_desc &pd)
Returns the engine of a primitive descriptor.
Definition: dnnl.hpp:932
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8552
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const lrn_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an LRN backward propagation primitive.
Definition: dnnl.hpp:5365
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:10378
pooling_v2_forward()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_memory_desc_init_by_strides(dnnl_memory_desc_t *memory_desc, int ndims, const dnnl_dims_t dims, dnnl_data_type_t data_type, const dnnl_dims_t strides)
Initializes a memory descriptor using dimensions and strides.
primitive_desc()=default
Default constructor. Produces an empty object.
desc(const dnnl_memory_desc_t &data)
Constructs a memory descriptor from a C API data structure.
Definition: dnnl.hpp:1869
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:7771
memory::desc bias_desc() const
Returns the bias memory descriptor.
Definition: dnnl.hpp:4036
memory::desc diff_weights_layer_desc() const
Returns diff weights layer memory descriptor.
Definition: dnnl.hpp:7361
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an elementwise forward propagation primitive.
Definition: dnnl.hpp:5708
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:9334
dnnl_status_t DNNL_API dnnl_dilated_convolution_forward_desc_init(dnnl_convolution_desc_t *conv_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_desc, const dnnl_dims_t strides, const dnnl_dims_t dilates, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a dilated convolution forward propagation primitive. ...
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:5744
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:9326
dnnl_status_t DNNL_API dnnl_lrn_backward_desc_init(dnnl_lrn_desc_t *lrn_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *data_desc, dnnl_dim_t local_size, float alpha, float beta, float k)
Initializes a descriptor for LRN backward propagation primitive.
Primitive descriptor for a convolution weights gradient primitive.
Definition: dnnl.hpp:4406
static size_t get_count(kind akind)
Returns the number of engines of a certain kind.
Definition: dnnl.hpp:887
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags=rnn_flags::undef)
Constructs a descriptor for a GRU backward propagation primitive.
Definition: dnnl.hpp:8864
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:10478
binary()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_layer_normalization_backward_desc_init(dnnl_layer_normalization_desc_t *lnrm_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *data_desc, const dnnl_memory_desc_t *stat_desc, float epsilon, unsigned flags)
Initializes a descriptor for a layer normalization backward propagation primitive.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a GRU backward propagation primitive.
Definition: dnnl.hpp:8933
#define DNNL_ARG_WEIGHTS_LAYER
A special mnemonic for RNN weights applied to the layer input.
Definition: dnnl_types.h:2161
Use no normalization flags.
Definition: dnnl_types.h:1079
scratchpad memory desc
Definition: dnnl_types.h:2396
Elementwise: natural logarithm.
dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_next(dnnl_primitive_desc_iterator_t iterator)
Advances the primitive descriptor iterator to point to the next available implementation.
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:8980
const void * const_dnnl_op_desc_t
A pointer to any of the operation descriptors (constant variant).
Definition: dnnl_types.h:1351
Intel Streaming SIMD Extensions 4.1 (Intel SSE4.1)
Definition: dnnl_types.h:2501
Eltwise: clip.
Definition: dnnl_types.h:988
reduction()=default
Default constructor. Produces an empty object.
inner_product_backward_data(const primitive_desc &pd)
Constructs an inner product backward propagation primitive.
Definition: dnnl.hpp:7104
Shuffle backward propagation primitive.
Definition: dnnl.hpp:9484
sum(const primitive_desc &pd)
Constructs a sum primitive.
Definition: dnnl.hpp:3685
Intel AVX-512, Intel DL Boost and bfloat16 support and Intel AMX with 8-bit integer and bfloat16 supp...
Definition: dnnl_types.h:2534
An opaque structure for primitive descriptor attributes.
reorder destination engine
primitive_desc_base(dnnl_primitive_desc_t pd, dnnl::primitive::kind prim_kind, dnnl::prop_kind aprop_kind)
Constructs a primitive descriptor base object from a clone of a C API primitive descriptor after veri...
Definition: dnnl.hpp:3284
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:9164
PReLU backward propagation primitive.
Definition: dnnl.hpp:10394
Deconvolution weights gradient primitive.
Definition: dnnl.hpp:4929
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a matmul primitive from a C API primitive descriptor that must ...
Definition: dnnl.hpp:9739
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:7222
memory::desc diff_src_layer_desc() const
Returns diff source layer memory descriptor.
Definition: dnnl.hpp:8601
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:9468
gru_forward()=default
Default constructor. Produces an empty object.
logsoftmax descriptor
Definition: dnnl_types.h:2381
Backward propagation (with respect to all parameters).
kind
Kinds of primitives supported by the library.
Definition: dnnl.hpp:271
permuted 4D tensor
Definition: dnnl_types.h:200
void get_output_scales(int &mask, std::vector< float > &scales) const
Returns output scaling factors correspondence mask and values.
Definition: dnnl.hpp:2648
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, rnn_flags flags=rnn_flags::undef)
Constructs a descriptor for an LSTM (with or without peephole) forward propagation primitive...
Definition: dnnl.hpp:7966
void append_eltwise(float scale, algorithm aalgorithm, float alpha, float beta)
Appends an elementwise post-op.
Definition: dnnl.hpp:2365
Use scale and shift parameters.
memory::desc diff_src_iter_desc() const
Returns diff source iteration memory descriptor.
Definition: dnnl.hpp:7349
desc(algorithm aalgorithm, const memory::desc &diff_src_desc, const memory::desc &weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a convolution backward propagation primitive.
Definition: dnnl.hpp:4080
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8103
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:4744
Primitive iterator passed over last primitive descriptor.
Definition: dnnl_types.h:49
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a convolution forward propagation primitive without bias.
Definition: dnnl.hpp:3858
plain 8D tensor
Definition: dnnl_types.h:185
memory::desc diff_bias_desc() const
Returns diff bias memory descriptor.
Definition: dnnl.hpp:7389
dnnl_status_t DNNL_API dnnl_convolution_backward_data_desc_init(dnnl_convolution_desc_t *conv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a convolution backward propagation primitive.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const deconvolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a deconvolution backward propagation primitive.
Definition: dnnl.hpp:4892
#define DNNL_ARG_DST_LAYER
A special mnemonic for RNN output vector. An alias for DNNL_ARG_DST_0.
Definition: dnnl_types.h:2137
Local response normalization (LRN) forward propagation primitive.
Definition: dnnl.hpp:5205
memory::desc src_desc(int idx) const
Returns a source memory descriptor.
Definition: dnnl.hpp:3106
An opaque structure to describe a memory.
void execute(const stream &astream, const std::unordered_map< int, memory > &args) const
Executes computations specified by the primitive in a specified stream.
Base class for primitive descriptors for RNN primitives.
Definition: dnnl.hpp:7250
void reset(T t, bool weak=false)
Resets the handle wrapper objects to wrap a new C API handle.
Definition: dnnl.hpp:176
Descriptor for an inner product backward propagation primitive.
Definition: dnnl.hpp:7008
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &dst_desc, float p, float eps)
Constructs a descriptor for a reduction primitive using algorithm specific parameters, source and destination memory descriptors.
Definition: dnnl.hpp:10530
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a shuffle backward propagation primitive from a C API primitive...
Definition: dnnl.hpp:9537
plain 11D tensor
Definition: dnnl_types.h:188
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a convolution forward propagation primitive with bias.
Definition: dnnl.hpp:3812
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:6842
Elementwise: hyperbolic tangent non-linearity (tanh) (dst for backward)
Descriptor for a PReLU backward propagation primitive.
Definition: dnnl.hpp:10396
permuted 5D tensor
Definition: dnnl_types.h:201
dnnl_memory_desc_t data
The underlying C API data structure.
Definition: dnnl.hpp:1803
LBR GRU backward propagation primitive.
Definition: dnnl.hpp:9182
Descriptor for a layer normalization forward propagation primitive.
Definition: dnnl.hpp:6574
dnnl_engine_kind_t
Kinds of engines.
Definition: dnnl_types.h:1972
struct dnnl_primitive_desc * dnnl_primitive_desc_t
A primitive descriptor handle.
Definition: dnnl_types.h:2015
Eltwise: square root (dst for backward)
Definition: dnnl_types.h:1002
non-standard 16-bit (bfloat16 w/ 7 bit mantissa) floating point.
Definition: dnnl_types.h:68
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:5847
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:7582
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:4024
Pooling v2 (dilated pooling) backward propagation primitive.
Definition: dnnl.hpp:10171
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a softmax forward propagation primitive from a C API primitive ...
Definition: dnnl.hpp:5938
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:8797
batch_normalization_backward()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_lstm_forward_desc_init_v3(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *src_iter_c_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *weights_peephole_desc, const dnnl_memory_desc_t *weights_projection_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *dst_iter_c_desc, unsigned flags)
Initializes a descriptor for an LSTM (with or without peephole and with or without recurrent projecti...
Intel AVX-512 and Intel Deep Learning Boost (Intel DL Boost) support for Intel Xeon Scalable processo...
desc(algorithm aalgorithm, const memory::desc &src0, const memory::desc &src1, const memory::desc &dst)
Constructs a descriptor for an elementwise binary operator primitive.
Definition: dnnl.hpp:9584
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:10279
lbr_gru_forward()=default
Default constructor. Produces an empty object.
Primitive descriptor for a concat primitive.
Definition: dnnl.hpp:3511
memory::dims dims() const
Returns dimensions of the memory descriptor.
Definition: dnnl.hpp:2002
#define DNNL_ARG_SRC_LAYER
A special mnemonic for RNN input vector.
Definition: dnnl_types.h:2111
Elementwise: square root (dst for backward)
desc(const memory::desc &diff_data_desc, const memory::desc &data_desc, int softmax_axis)
Constructs a descriptor for a softmax backward propagation primitive.
Definition: dnnl.hpp:5975
Undefined primitive.
Definition: dnnl_types.h:890
Intel Advanced Vector Extensions 512 (Intel AVX-512) subset for Intel Xeon Phi processors x200 Series...
void set_post_ops(const post_ops ops)
Sets post-ops.
Definition: dnnl.hpp:2832
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &data_desc, float alpha=0, float beta=0)
Constructs a descriptor for an elementwise forward propagation primitive.
Definition: dnnl.hpp:5681
number of outputs expected
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:7603
primitive::kind kind(int index) const
Returns the primitive kind of post-op at entry with a certain index.
Definition: dnnl.hpp:2283
Unidirectional execution of RNN primitive from left to right.
Definition: dnnl_types.h:1764
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a PReLU forward propagation primitive.
Definition: dnnl.hpp:10345
execution engine
primitive_desc(const desc &adesc, const engine &aengine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a convolution weights gradient primitive.
Definition: dnnl.hpp:4422
The library manages the scratchpad allocation according to the policy specified by the DNNL_ENABLE_CO...
Definition: dnnl_types.h:2043
memory::desc diff_src_layer_desc() const
Returns diff source layer memory descriptor.
Definition: dnnl.hpp:7341
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a layer normalization forward propagation primitive.
Definition: dnnl.hpp:6652
Descriptor for an inner product weights gradient primitive.
Definition: dnnl.hpp:7110
dnnl_status_t DNNL_API dnnl_memory_destroy(dnnl_memory_t memory)
Destroys a memory object.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:5508
dnnl_status_t DNNL_API dnnl_memory_get_data_handle(const_dnnl_memory_t memory, void **handle)
Returns memory object&#39;s data handle.
3D tensor blocked by 2nd dimension with block size 4
Definition: dnnl_types.h:239
desc(const memory::desc &diff_data_desc, const memory::desc &data_desc, int logsoftmax_axis)
Constructs a descriptor for a logsoftmax backward propagation primitive.
Definition: dnnl.hpp:6179
memory::desc weights_peephole_desc() const
Returns weights peephole memory descriptor.
Definition: dnnl.hpp:7301
batch normalization descriptor
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:8771
3D CNN activations tensor blocked by channels with block size 8, an alias to dnnl_aBc8b ...
Definition: dnnl_types.h:630
Intel AVX2 and Intel Deep Learning Boost (Intel DL Boost) support.
Definition: dnnl_types.h:2537
Nearest Neighbor resampling method.
memory::desc diff_weights_iter_desc() const
Returns diff weights iteration memory descriptor.
Definition: dnnl.hpp:8621
Intel AVX-512 subset for Intel Xeon Phi processors 7235, 7285, 7295 Series.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6151
dnnl_dims_t dims
Dimensions in the following order:
Definition: dnnl_types.h:1291
dnnl_status_t DNNL_API dnnl_stream_get_engine(const_dnnl_stream_t stream, dnnl_engine_t *engine)
Returns the engine of a stream object.
primitive_desc()=default
Default constructor. Produces an empty object.
4D CNN activations tensor blocked by channels with block size 16, an alias to dnnl_aBcd16b ...
Definition: dnnl_types.h:612
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:9156
binary descriptor
Definition: dnnl_types.h:2380
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a pooling forward propagation primitive.
Definition: dnnl.hpp:5488
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:6987
Elementwise: square root.
primitive_desc()=default
Default constructor. Produces an empty object.
The operation was successful.
permuted 4D tensor
Definition: dnnl_types.h:193
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:3186
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:9908
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:6252
Any ISA (excepting those listed as initial support)
Intel Streaming SIMD Extensions 4.1 (Intel SSE4.1)
Descriptor for a pooling forward propagation primitive.
Definition: dnnl.hpp:10052
desc(prop_kind aprop_kind, const memory::desc &data_desc, const memory::desc &stat_desc, float epsilon, normalization_flags flags)
Constructs a descriptor for layer normalization forward propagation primitive.
Definition: dnnl.hpp:6588
dnnl_status_t DNNL_API dnnl_primitive_attr_destroy(dnnl_primitive_attr_t attr)
Destroys primitive attributes.
#define DNNL_ARG_WEIGHTS_ITER
A special mnemonic for RNN weights applied to the recurrent input.
Definition: dnnl_types.h:2167
Descriptor for a batch normalization backward propagation primitive.
Definition: dnnl.hpp:6421
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &dst_desc)
Constructs a descriptor for a resampling forward propagation primitive using source and destination m...
Definition: dnnl.hpp:9800
memory::desc diff_weights_peephole_desc() const
Returns diff weights peephole memory descriptor.
Definition: dnnl.hpp:8626
memory::desc diff_dst_iter_desc() const
Returns diff destination iteration memory descriptor.
Definition: dnnl.hpp:7830
memory::desc diff_weights_layer_desc() const
Returns diff weights layer memory descriptor.
Definition: dnnl.hpp:8616
A descriptor of a pooling operation.
Definition: dnnl_types.h:1521
status set_jit_profiling_jitdumpdir(const std::string &dir)
Sets JIT dump output path.
Definition: dnnl.hpp:10645
desc permute_axes(const std::vector< int > &permutation, bool allow_empty=false) const
Constructs a memory descriptor by permuting axes in an existing one.
Definition: dnnl.hpp:1986
plain 2D tensor
Definition: dnnl_types.h:178
kind get_kind() const
Returns the kind of the engine.
Definition: dnnl.hpp:919
A memory descriptor.
Definition: dnnl.hpp:1800
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_src_iter_c_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_weights_peephole_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, const memory::desc &diff_dst_iter_c_desc, rnn_flags flags=rnn_flags::undef)
Constructs an LSTM (with or without peephole) descriptor for backward propagation using prop_kind...
Definition: dnnl.hpp:8354
permuted 5D tensor
Definition: dnnl_types.h:208
rnn_direction
A direction of RNN primitive execution.
Definition: dnnl.hpp:706
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:4030
destination gradient (diff) memory desc
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:8972
vanilla_rnn_forward()=default
Default constructor. Produces an empty object.
Undefined memory format kind, used for empty memory descriptors.
Definition: dnnl_types.h:82
GRU cell with linear before reset.
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags=rnn_flags::undef)
Constructs a descriptor for a GRU forward propagation primitive.
Definition: dnnl.hpp:8703
memory::desc diff_dst_iter_desc() const
Returns diff destination iteration memory descriptor.
Definition: dnnl.hpp:9015
dnnl_status_t DNNL_API dnnl_vanilla_rnn_backward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, const dnnl_alg_kind_t activation, const dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *diff_src_layer_desc, const dnnl_memory_desc_t *diff_src_iter_desc, const dnnl_memory_desc_t *diff_weights_layer_desc, const dnnl_memory_desc_t *diff_weights_iter_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_layer_desc, const dnnl_memory_desc_t *diff_dst_iter_desc, unsigned flags, float alpha, float beta)
Initializes a descriptor for vanilla RNN backward propagation primitive.
Reduction using lp norm without final pth-root.
Definition: dnnl_types.h:1066
32-bit signed integer.
Definition: dnnl_types.h:72
Bidirectional execution of RNN primitive with summation of the results.
Definition: dnnl_types.h:1772
reorder source engine
dnnl_status_t DNNL_API dnnl_post_ops_get_params_eltwise(const_dnnl_post_ops_t post_ops, int index, float *scale, dnnl_alg_kind_t *alg_kind, float *alpha, float *beta)
Returns the parameters of an elementwise post-op.
An inner product primitive.
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc()=default
Default constructor. Produces an empty object.
A softmax primitive.
Undefined RNN flags.
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:8134
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5168
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:6148
primitive_desc(const desc &adesc, const engine &aengine, const layer_normalization_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a layer normalization backward propagation primitive.
Definition: dnnl.hpp:6790
Direct convolution.
Definition: dnnl_types.h:945
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a batch normalization forward propagation primitive.
Definition: dnnl.hpp:6336
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:3162
memory::desc diff_weights_layer_desc() const
Returns diff weights layer memory descriptor.
Definition: dnnl.hpp:9365
dnnl_status_t DNNL_API dnnl_primitive_attr_get_rnn_data_qparams(const_dnnl_primitive_attr_t attr, float *scale, float *shift)
Returns the quantization scale and shift parameters for RNN data tensors.
desc submemory_desc(const dims &adims, const dims &offsets, bool allow_empty=false) const
Constructs a memory descriptor for a region inside an area described by this memory descriptor...
Definition: dnnl.hpp:1882
Just a sentinel, not real memory format tag.
Definition: dnnl_types.h:465
Primitive descriptor for an LRN forward propagation primitive.
Definition: dnnl.hpp:5236
desc(const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_desc)
Constructs a descriptor for an inner product descriptor weights update primitive with bias...
Definition: dnnl.hpp:7124
Descriptor for an LSTM forward propagation primitive.
Definition: dnnl.hpp:7847
5D tensor blocked by 1st dimension with block size 8
Definition: dnnl_types.h:329
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:8977
dnnl_primitive_kind_t convert_to_c(primitive::kind akind)
Converts primitive kind enum value from C++ API to C API type.
Definition: dnnl.hpp:364
An opaque structure to describe a primitive descriptor iterator.
eltwise_forward(const primitive_desc &pd)
Constructs an eltwise forward propagation primitive.
Definition: dnnl.hpp:5753
pooling descriptor
Definition: dnnl_types.h:2372
Convolution algorithm(either direct or Winograd) is chosen just in time.
Definition: dnnl_types.h:949
memory::desc diff_src_layer_desc() const
Returns diff source layer memory descriptor.
Definition: dnnl.hpp:9355
Reduction using mean.
Definition: dnnl_types.h:1058
Elementwise: bounded_relu.
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated convolution forward propagation primitive with bias...
Definition: dnnl.hpp:3907
Logsoftmax backward propagation primitive.
Definition: dnnl.hpp:6164
memory(const desc &md, const engine &aengine)
Constructs a memory object.
Definition: dnnl.hpp:2082
An execution engine.
Definition: dnnl.hpp:863
matmul(const primitive_desc &pd)
Constructs a matmul primitive.
Definition: dnnl.hpp:9764
void get_rnn_weights_projection_qparams(int &mask, std::vector< float > &scales)
Returns the quantization scaling factors for RNN projection weights tensors.
Definition: dnnl.hpp:3017
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &kernel, const memory::dims &dilation, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for pooling v2 (dilated pooling) forward propagation primitive.
Definition: dnnl.hpp:10081
dnnl_status_t DNNL_API dnnl_stream_create(dnnl_stream_t *stream, dnnl_engine_t engine, unsigned flags)
Creates an execution stream.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6249
GRU forward propagation primitive.
Definition: dnnl.hpp:8666
dnnl_status_t DNNL_API dnnl_memory_desc_permute_axes(dnnl_memory_desc_t *out_memory_desc, const dnnl_memory_desc_t *in_memory_desc, const int *permutation)
Initializes a memory descriptor by permuting axes in an existing one.
Primitive descriptor for a layer normalization forward propagation primitive.
Definition: dnnl.hpp:6622
dnnl_status_t DNNL_API dnnl_primitive_desc_query(const_dnnl_primitive_desc_t primitive_desc, dnnl_query_t what, int index, void *result)
Queries a primitive descriptor for various pieces of information.
convolution_backward_data(const primitive_desc &pd)
Constructs a convolution backward propagation primitive.
Definition: dnnl.hpp:4214
dnnl_status_t DNNL_API dnnl_memory_unmap_data(const_dnnl_memory_t memory, void *mapped_ptr)
Unmaps a memory object and writes back any changes made to the previously mapped memory buffer...
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:3450
const char * impl_info_str() const
Returns implementation name.
Definition: dnnl.hpp:3053
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:9329
primitive_desc()=default
Default constructor. Produces an empty object.
void unmap_data(void *mapped_ptr) const
Unmaps a memory object and writes back any changes made to the previously mapped memory buffer...
Definition: dnnl.hpp:2201
destination memory desc
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:8789
primitive_desc(const desc &adesc, const engine &aengine, const logsoftmax_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a logsoftmax backward propagation primitive.
Definition: dnnl.hpp:6207
Descriptor for an LRN backward propagation primitive.
Definition: dnnl.hpp:5302
Primitive descriptor for an inner product weights gradient primitive.
Definition: dnnl.hpp:7159
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:8800
layer_normalization_forward()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_lstm_forward_desc_init_v2(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *src_iter_c_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *weights_peephole_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *dst_iter_c_desc, unsigned flags)
Initializes a descriptor for an LSTM (with or without peephole) forward propagation primitive...
An element-wise primitive.
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &weights_projection_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_src_iter_c_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_weights_peephole_desc, const memory::desc &diff_weights_projection_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, const memory::desc &diff_dst_iter_c_desc, rnn_flags flags=rnn_flags::undef)
Constructs an LSTM (with or without peephole and with or without projection) descriptor for backward ...
Definition: dnnl.hpp:8242
dnnl_status_t DNNL_API dnnl_gru_backward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *diff_src_layer_desc, const dnnl_memory_desc_t *diff_src_iter_desc, const dnnl_memory_desc_t *diff_weights_layer_desc, const dnnl_memory_desc_t *diff_weights_iter_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_layer_desc, const dnnl_memory_desc_t *diff_dst_iter_desc, unsigned flags)
Initializes a descriptor for GRU backward propagation primitive.
dnnl_status_t DNNL_API dnnl_deconvolution_backward_weights_desc_init(dnnl_deconvolution_desc_t *deconv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *diff_weights_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a deconvolution weights gradient primitive.
memory desc of an execute argument
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:9146
Unidirectional execution of RNN primitive from right to left.
Definition: dnnl_types.h:1766
dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_create(dnnl_primitive_desc_iterator_t *iterator, const_dnnl_op_desc_t op_desc, const_dnnl_primitive_attr_t attr, dnnl_engine_t engine, const_dnnl_primitive_desc_t hint_forward_primitive_desc)
Creates a primitive descriptor iterator.
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, rnn_flags flags=rnn_flags::undef)
Constructs a descriptor for an LSTM forward propagation primitive.
Definition: dnnl.hpp:8027
A deconvolution primitive.
Definition: dnnl_types.h:902
Descriptor for an LRN forward propagation primitive.
Definition: dnnl.hpp:5207
A class that provides the destructor for a oneDNN C API handle.
Definition: dnnl.hpp:120
lstm_backward()=default
Default constructor. Produces an empty object.
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:7214
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a convolution forward propagation primitive from a C API primit...
Definition: dnnl.hpp:4018
LSTM backward propagation primitive.
Definition: dnnl.hpp:8162
engine(kind akind, size_t index)
Constructs an engine.
Definition: dnnl.hpp:896
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:7277
dnnl_status_t DNNL_API dnnl_post_ops_append_eltwise(dnnl_post_ops_t post_ops, float scale, dnnl_alg_kind_t alg_kind, float alpha, float beta)
Appends an elementwise post-op.
5D tensor blocked by 2nd dimension with block size 8
Definition: dnnl_types.h:357
8-bit unsigned integer.
Definition: dnnl_types.h:76
A descriptor of a matrix multiplication operation.
Definition: dnnl_types.h:1886
memory::desc diff_weights_desc() const
Returns a diff weights memory descriptor.
Definition: dnnl.hpp:4462
memory::desc mean_desc() const
Returns memory descriptor for mean.
Definition: dnnl.hpp:6682
Alias for dnnl::rnn_direction::unidirectional_left2right.
memory::desc src_desc(int idx=0) const
Returns a source memory descriptor.
Definition: dnnl.hpp:3674
deconvolution_backward_data()=default
Default constructor. Produces an empty object.
permuted 6D tensor
Definition: dnnl_types.h:214
primitive_desc()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_primitive_attr_get_scales(dnnl_primitive_attr_t attr, int arg, dnnl_dim_t *count, int *mask, const float **scales)
Returns primitive attributes scaling factors correspondence mask and values for a given memory argume...
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:9342
dnnl_status_t DNNL_API dnnl_set_jit_profiling_flags(unsigned flags)
Sets library profiling flags.
dnnl_status_t DNNL_API dnnl_primitive_attr_set_output_scales(dnnl_primitive_attr_t attr, dnnl_dim_t count, int mask, const float *scales)
Sets output scaling factors correspondence mask and values.
number of inputs expected
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:4199
prelu_backward()=default
Default constructor. Produces an empty object.
memory::desc diff_bias_desc() const
Returns diff bias memory descriptor.
Definition: dnnl.hpp:7820
layer_normalization_forward(const primitive_desc &pd)
Constructs a layer normalization forward propagation primitive.
Definition: dnnl.hpp:6713
#define DNNL_ARG_DIFF_DST_ITER
A special mnemonic for gradient (diff) of RNN input recurrent hidden state vector.
Definition: dnnl_types.h:2229
dnnl_query_t
Primitive descriptor query specification.
Definition: dnnl_types.h:2339
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:6833
Intel Advanced Vector Extensions (Intel AVX)
Definition: dnnl_types.h:2504
Intel AVX-512 subset for Intel Xeon Phi processors 7235, 7285, 7295 Series.
Definition: dnnl_types.h:2515
Backward data propagation.
Definition: dnnl_types.h:879
Inner product forward propagation primitive.
Definition: dnnl.hpp:6881
Average pooling exclude padding.
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:5625
A descriptor of a binary operation.
Definition: dnnl_types.h:1860
dnnl_status_t DNNL_API dnnl_gru_forward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, unsigned flags)
Initializes a descriptor for GRU forward propagation primitive.
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:7579
source gradient memory desc
Definition: dnnl_types.h:2390
plain 10D tensor
Definition: dnnl_types.h:187
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const lstm_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an LSTM backward propagation primitive.
Definition: dnnl.hpp:8529
void execute(const stream &astream, memory &src, memory &dst) const
Executes the reorder primitive.
Definition: dnnl.hpp:3482
engine get_engine() const
Returns the engine of the primitive descriptor.
Definition: dnnl.hpp:3049
A binary primitive.
Definition: dnnl_types.h:922
Structure containing version information as per Semantic Versioning
Definition: dnnl_types.h:2466
Elementwise unary operation backward propagation primitive.
Definition: dnnl.hpp:5757
reduction descriptor
Definition: dnnl_types.h:2385
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a prelu forward propagation primitive from a C API primitive de...
Definition: dnnl.hpp:10372
desc(prop_kind aprop_kind, const memory::desc &diff_data_desc, const memory::desc &data_desc, float epsilon, normalization_flags flags)
Constructs a descriptor for layer normalization backward propagation primitive.
Definition: dnnl.hpp:6759
primitive_desc(const desc &adesc, const engine &aengine, const pooling_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a pooling backward propagation primitive.
Definition: dnnl.hpp:5585
deconvolution_backward_data(const primitive_desc &pd)
Constructs a deconvolution backward propagation primitive.
Definition: dnnl.hpp:4925
void set_rnn_data_qparams(float scale, float shift)
Sets quantization scale and shift parameters for RNN data tensors.
Definition: dnnl.hpp:2870
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:8547
4D tensor blocked by 2nd dimension with block size 32
Definition: dnnl_types.h:280
dnnl_status_t DNNL_API dnnl_primitive_attr_set_zero_points(dnnl_primitive_attr_t attr, int arg, dnnl_dim_t count, int mask, const int32_t *zero_points)
Sets primitive attributes zero points for primitive operations for a given memory argument...
#define DNNL_ARG_DIFF_SRC_ITER
A special mnemonic for gradient (diff) of RNN input recurrent hidden state vector.
Definition: dnnl_types.h:2208
primitive_desc()=default
Default constructor. Produces an empty object.
permuted 11D tensor
Definition: dnnl_types.h:221
LSTM cell.
Definition: dnnl_types.h:1022
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a pooling v2 (dilated pooling) forward propagation primitive...
Definition: dnnl.hpp:10133
memory::desc diff_bias_desc() const
Returns the diff bias memory descriptor.
Definition: dnnl.hpp:7225
Packed weights format used in RNN.
Definition: dnnl_types.h:93
desc()=default
Default constructor. Produces an empty object.
int DNNL_API dnnl_post_ops_len(const_dnnl_post_ops_t post_ops)
Returns the length of post-ops.
#define DNNL_ARG_DST_ITER
A special mnemonic for RNN input recurrent hidden state vector.
Definition: dnnl_types.h:2143
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for concat primitive from a C API primitive descriptor which must h...
Definition: dnnl.hpp:3573
Descriptor for an elementwise forward propagation primitive.
Definition: dnnl.hpp:5666
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a logsoftmax backward propagation primitive from a C API primit...
Definition: dnnl.hpp:6240
4D tensor blocked by 2nd dimension with block size 16
Definition: dnnl_types.h:272
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:9350
desc()=default
Default constructor. Produces an empty object.
#define DNNL_ARG_SRC_ITER_C
A special mnemonic for RNN input recurrent cell state vector.
Definition: dnnl_types.h:2126
permuted 7D tensor
Definition: dnnl_types.h:217
Inner product weights gradient primitive.
Definition: dnnl.hpp:7108
primitive_desc()=default
Default constructor. Produces an empty object.
memory::desc diff_bias_desc() const
Returns the diff bias memory descriptor.
Definition: dnnl.hpp:5179
A reorder primitive.
Definition: dnnl_types.h:892
A pooling primitive.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:9756
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:9339
dnnl_status_t DNNL_API dnnl_softmax_forward_desc_init(dnnl_softmax_desc_t *softmax_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *data_desc, int softmax_axis)
Initializes a descriptor for softmax forward propagation primitive.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const batch_normalization_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a batch normalization backward propagation primitive.
Definition: dnnl.hpp:6487
pooling_forward()=default
Default constructor. Produces an empty object.
A descriptor of a convolution operation.
Definition: dnnl_types.h:1363
dnnl_status_t DNNL_API dnnl_dilated_convolution_backward_weights_desc_init(dnnl_convolution_desc_t *conv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *diff_weights_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t dilates, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a dilated convolution weights gradient primitive.
primitive_desc(const desc &adesc, const engine &aengine, const vanilla_rnn_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a vanilla RNN backward propagation primitive.
Definition: dnnl.hpp:7728
memory::desc diff_weights_iter_desc() const
Returns diff weights iteration memory descriptor.
Definition: dnnl.hpp:7367
Descriptor for a resampling backward propagation primitive.
Definition: dnnl.hpp:9926
normalization_flags
Flags for normalization primitives.
Definition: dnnl.hpp:609
matmul()=default
Default constructor. Produces an empty object.
convolution_forward()=default
Default constructor. Produces an empty object.
status set_verbose(int level)
Configures verbose output to stdout.
Definition: dnnl.hpp:10625
softmax descriptor
Definition: dnnl_types.h:2371
permuted 5D tensor
Definition: dnnl_types.h:215
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an LRN forward propagation primitive from a C API primitive des...
Definition: dnnl.hpp:5275
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8956
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a GRU forward propagation primitive from a C API primitive desc...
Definition: dnnl.hpp:8765
dnnl_status_t DNNL_API dnnl_sum_primitive_desc_create(dnnl_primitive_desc_t *sum_primitive_desc, const dnnl_memory_desc_t *dst_desc, int n, const float *scales, const dnnl_memory_desc_t *src_descs, const_dnnl_primitive_attr_t attr, dnnl_engine_t engine)
Creates a primitive descriptor for an (out-of-place) sum primitive.
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a deconvolution forward propagation primitive.
Definition: dnnl.hpp:4708
Elementwise: tanh-based gelu.
softmax_forward(const primitive_desc &pd)
Constructs a softmax forward propagation primitive.
Definition: dnnl.hpp:5956
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a logsoftmax forward propagation primitive. ...
Definition: dnnl.hpp:6127
primitive_desc(const engine &src_engine, const memory::desc &src_md, const engine &dst_engine, const memory::desc &dst_md, const primitive_attr &attr=primitive_attr(), bool allow_empty=false)
Constructs a primitive descriptor for reorder primitive.
Definition: dnnl.hpp:3388
Intel AVX-512 subset for Intel Xeon Scalable processor family and Intel Core processor family...
Definition: dnnl_types.h:2519
format_kind
Memory format kind.
Definition: dnnl.hpp:1143
binary(const primitive_desc &pd)
Constructs an elementwise binary operation primitive.
Definition: dnnl.hpp:9654
no query
Definition: dnnl_types.h:2340
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:6984
dnnl_scratchpad_mode_t
Scratchpad mode.
Definition: dnnl_types.h:2026
Fuse with ReLU.
Definition: dnnl_types.h:1118
data_type
Data type specification.
Definition: dnnl.hpp:1124
primitive_desc()=default
Default constructor. Produces an empty object.
memory::desc weights_desc(int idx) const
Returns a weights memory descriptor.
Definition: dnnl.hpp:3124
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:8147
Primitive descriptor for a logsoftmax backward propagation primitive.
Definition: dnnl.hpp:6190
Forward data propagation (training mode).
batch normalization descriptor
Definition: dnnl_types.h:2375
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const vanilla_rnn_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a vanilla RNN backward propagation primitive.
Definition: dnnl.hpp:7748
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:8560
A reduction primitive.
Definition: dnnl_types.h:932
The operation failed because requested functionality is not implemented.
primitive_desc()=default
Default constructor. Produces an empty object.
Out-of-place summation (sum) primitive.
Definition: dnnl.hpp:3602
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a deconvolution forward propagation primitive from a C API prim...
Definition: dnnl.hpp:4735
memory::desc diff_weights_projection_desc() const
Returns diff weights projection memory descriptor.
Definition: dnnl.hpp:8631
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:10282
memory::desc weights_peephole_desc() const
Returns weights peephole memory descriptor.
Definition: dnnl.hpp:8121
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:9911
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:8959
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:9347
runtime estimation (seconds)
Definition: dnnl_types.h:2348
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:10481
Backward propagation (with respect to all parameters).
Definition: dnnl_types.h:877
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:10025
An unspecified engine.
Definition: dnnl_types.h:1974
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a shuffle forward propagation primitive from a C API primitive ...
Definition: dnnl.hpp:9462
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for sum primitive from a C API primitive descriptor which must have...
Definition: dnnl.hpp:3670
Backward weights propagation.
eltwise_backward()=default
Default constructor. Produces an empty object.
handle()=default
Constructs an empty handle object.
dnnl_status_t DNNL_API dnnl_logsoftmax_backward_desc_init(dnnl_logsoftmax_desc_t *logsoftmax_desc, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *data_desc, int logsoftmax_axis)
Initializes a descriptor for logsoftmax backward propagation primitive.
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8776
gru_forward(const primitive_desc &pd)
Constructs a GRU forward propagation primitive.
Definition: dnnl.hpp:8811
5D tensor blocked by 1st dimension with block size 16
Definition: dnnl_types.h:325
Eltwise: ReLU.
Definition: dnnl_types.h:955
memory::desc diff_weights_desc(int idx) const
Returns a diff weights memory descriptor.
Definition: dnnl.hpp:3151
Descriptor for an LBR GRU forward propagation primitive.
Definition: dnnl.hpp:9032
dnnl_status_t DNNL_API dnnl_concat_primitive_desc_create(dnnl_primitive_desc_t *concat_primitive_desc, const dnnl_memory_desc_t *dst_desc, int n, int concat_dimension, const dnnl_memory_desc_t *src_descs, const_dnnl_primitive_attr_t attr, dnnl_engine_t engine)
Creates a primitive descriptor for an out-of-place concatenation primitive.
GPU engine.
Definition: dnnl_types.h:1978
Reduction using norm_lp_sum operation.
Local response normalization (LRN) across multiple channels.
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:10475
dnnl_status_t DNNL_API dnnl_lrn_forward_desc_init(dnnl_lrn_desc_t *lrn_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *data_desc, dnnl_dim_t local_size, float alpha, float beta, float k)
Initializes a descriptor for LRN forward propagation primitive.
desc(algorithm aalgorithm, const memory::desc &diff_src_desc, const memory::desc &weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated deconvolution backward propagation primitive.
Definition: dnnl.hpp:4834
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:7089
dnnl_status_t DNNL_API dnnl_shuffle_backward_desc_init(dnnl_shuffle_desc_t *shuffle_desc, const dnnl_memory_desc_t *diff_data_desc, int axis, dnnl_dim_t group_size)
Initializes a descriptor for shuffle backward propagation primitive.
softmax_backward()=default
Default constructor. Produces an empty object.
Batch normalization forward propagation primitive.
Definition: dnnl.hpp:6290
Convolution forward propagation primitive.
Definition: dnnl.hpp:3777
primitive_desc()=default
Default constructor. Produces an empty object.
Primitive descriptor for a deconvolution weights gradient primitive.
Definition: dnnl.hpp:5113
memory::desc mean_desc() const
Returns memory descriptor for mean.
Definition: dnnl.hpp:6527
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:5628
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:6519
inner_product_forward(const primitive_desc &pd)
Constructs an inner product forward propagation primitive.
Definition: dnnl.hpp:7002
Use no normalization flags.
vanilla_rnn_forward(const primitive_desc &pd)
Constructs a vanilla RNN forward propagation primitive.
Definition: dnnl.hpp:7614
3D tensor blocked by 2nd dimension with block size 32
Definition: dnnl_types.h:237
Descriptor for an elementwise backward propagation primitive.
Definition: dnnl.hpp:5759
eltwise_backward(const primitive_desc &pd)
Constructs an eltwise backward propagation primitive.
Definition: dnnl.hpp:5856
primitive_desc(const desc &adesc, const engine &aengine, const deconvolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a deconvolution weights update primitive.
Definition: dnnl.hpp:5130
void reset_with_clone(const_dnnl_primitive_desc_t pd)
Resets the value of the handle to a clone of a C API primitive descriptor.
Definition: dnnl.hpp:3249
(scratch) memory, additional to all inputs and outputs memory (bytes)
Definition: dnnl_types.h:2354
memory::desc diff_src_iter_desc() const
Returns diff source iteration memory descriptor.
Definition: dnnl.hpp:9360
memory::desc scratchpad_desc() const
Returns the scratchpad memory descriptor.
Definition: dnnl.hpp:3207
Elementwise unary operation forward propagation primitive.
Definition: dnnl.hpp:5664
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:8784
Local response normalization (LRN) backward propagation primitive.
Definition: dnnl.hpp:5300
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:8583
memory::desc diff_bias_desc() const
Returns diff bias memory descriptor.
Definition: dnnl.hpp:9005
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc()=default
Default constructor. Produces an empty object.
Eltwise: pow.
Definition: dnnl_types.h:990
memory::desc src_iter_c_desc() const
Returns source recurrent cell state memory descriptor.
Definition: dnnl.hpp:7283
5D tensor blocked by 2nd dimension with block size 4
Definition: dnnl_types.h:342
lstm_forward()=default
Default constructor. Produces an empty object.
memory::desc diff_src_iter_desc() const
Returns diff source iteration memory descriptor.
Definition: dnnl.hpp:8606
permuted 4D tensor
Definition: dnnl_types.h:210
Elementwise: logistic.
An LRN primitive.
lrn descriptor
Reduction using norm_lp_power_p_sum operation.
An opaque structure to describe an engine.
void get_zero_points(int arg, int &mask, std::vector< int32_t > &zero_points) const
Returns zero points correspondence mask and values.
Definition: dnnl.hpp:2769
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5741
void get_rnn_weights_qparams(int &mask, std::vector< float > &scales)
Returns the quantization scaling factors for RNN projection weights tensors.
Definition: dnnl.hpp:2948
void append_dw_k3s2p1(memory::data_type weights_data_type, memory::data_type bias_data_type, memory::data_type dst_data_type, int mask, const std::vector< float > &scales)
Appends a depthwise post-op convolution with stride 2.
Definition: dnnl.hpp:2501
desc()=default
Default constructor. Produces an empty object.
Vanilla RNN forward propagation primitive.
Definition: dnnl.hpp:7457
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:4459
memory::desc diff_src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:10276
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a LBR GRU forward propagation primitive.
Definition: dnnl.hpp:9121
resampling_backward(const primitive_desc &pd)
Constructs a resampling backward propagation primitive.
Definition: dnnl.hpp:10034
primitive_desc_base(dnnl_primitive_desc_t pd, dnnl::primitive::kind prim_kind)
Constructs a primitive descriptor base object from a clone of a C API primitive descriptor after veri...
Definition: dnnl.hpp:3269
lrn_forward()=default
Default constructor. Produces an empty object.
primitive_desc()=default
Default constructor. Produces an empty object.
#define DNNL_ARG_SRC_ITER
A special mnemonic for RNN input recurrent hidden state vector.
Definition: dnnl_types.h:2120
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:5287
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &data_desc, memory::dim local_size, float alpha, float beta, float k=1.f)
Constructs a descriptor for a LRN forward propagation primitive.
Definition: dnnl.hpp:5223
inner_product_backward_weights(const primitive_desc &pd)
Constructs an inner product weights gradient primitive.
Definition: dnnl.hpp:7236
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a resampling backward propagation primitive from a C API primit...
Definition: dnnl.hpp:10017
binary descriptor
Forward data propagation (inference mode).
Definition: dnnl_types.h:871
Undefined RNN flags.
Definition: dnnl_types.h:1758
memory::desc query_md(query what, int idx=0) const
Returns a memory descriptor.
Definition: dnnl.hpp:3086
A sum primitive.
Definition: dnnl_types.h:898
dnnl_status_t DNNL_API dnnl_reduction_desc_init(dnnl_reduction_desc_t *desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *dst_desc, float p, float eps)
Initializes a descriptor for a reduction primitive.
memory::desc variance_desc() const
Returns memory descriptor for variance.
Definition: dnnl.hpp:6853
oneDNN exception class.
Definition: dnnl.hpp:84
memory::desc weights_projection_desc() const
Returns weights projection memory descriptor.
Definition: dnnl.hpp:8126
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:9542
#define DNNL_ARG_BIAS
Bias tensor argument.
Definition: dnnl_types.h:2182
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:7779
Primitive descriptor for a pooling forward propagation primitive.
Definition: dnnl.hpp:10103
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a convolution weights gradient primitive.
Definition: dnnl.hpp:4441
source memory desc
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags=rnn_flags::undef)
Constructs a descriptor for LBR GRU backward propagation primitive.
Definition: dnnl.hpp:9232
void get_params_dw_k3s2p1(int index, memory::data_type &weights_data_type, memory::data_type &bias_data_type, memory::data_type &dst_data_type, int &mask, std::vector< float > &scales) const
Returns the parameters of an depthwise post-op with stride 2.
Definition: dnnl.hpp:2527
size_t DNNL_API dnnl_memory_desc_get_size(const dnnl_memory_desc_t *memory_desc)
Returns the size of a memory descriptor.
workspace memory desc
Intel Advanced Vector Extensions 512 (Intel AVX-512) subset for Intel Xeon Phi processors x200 Series...
Definition: dnnl_types.h:2511
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &weights_peephole_desc, const memory::desc &weights_projection_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, rnn_flags flags=rnn_flags::undef)
Constructs a descriptor for an LSTM (with or without peephole and with or without projection) forward...
Definition: dnnl.hpp:7898
primitive_desc()=default
Default constructor. Produces an empty object.
void set_data_handle(void *handle) const
Sets the underlying memory buffer.
Definition: dnnl.hpp:2156
Forward data propagation (inference mode).
A descriptor of a element-wise operation.
Definition: dnnl_types.h:1438
dnnl_status_t DNNL_API dnnl_post_ops_get_params_sum(const_dnnl_post_ops_t post_ops, int index, float *scale)
Returns the parameters of an accumulation (sum) post-op.
A descriptor of a Softmax operation.
Definition: dnnl_types.h:1491
Descriptor for a convolution weights gradient primitive.
Definition: dnnl.hpp:4220
An opaque structure for a chain of post operations.
A descriptor of an inner product operation.
Definition: dnnl_types.h:1722
Eltwise: round.
Definition: dnnl_types.h:994
primitive_desc(const memory::desc &dst, const std::vector< float > &scales, const std::vector< memory::desc > &srcs, const engine &aengine, const primitive_attr &attr=primitive_attr())
Constructs a primitive descriptor for a sum primitive.
Definition: dnnl.hpp:3618
Descriptor for a deconvolution weights gradient primitive.
Definition: dnnl.hpp:4931
The operation failed because of incorrect function arguments.
Definition: dnnl_types.h:45
Forward data propagation, alias for dnnl::prop_kind::forward_training.
int len() const
Returns the number of post-ops entries.
Definition: dnnl.hpp:2278
runtime estimation (seconds), unimplemented
resampling_forward(const primitive_desc &pd)
Constructs a resampling forward propagation primitive.
Definition: dnnl.hpp:9920
Undefined algorithm.
desc(prop_kind aprop_kind, const memory::desc &data_desc, const memory::desc &weight_desc)
Constructs a descriptor for a PReLU forward propagation primitive.
Definition: dnnl.hpp:10320
Intel AVX2 and Intel Deep Learning Boost (Intel DL Boost) support.
Pooling forward propagation primitive.
Definition: dnnl.hpp:5412
softmax descriptor
primitive_desc(const memory::desc &dst, int concat_dimension, const std::vector< memory::desc > &srcs, const engine &aengine, const primitive_attr &attr=primitive_attr())
Constructs a primitive descriptor for an out-of-place concatenation primitive.
Definition: dnnl.hpp:3527
dnnl_rnn_direction_t
A direction of RNN primitive execution.
Definition: dnnl_types.h:1762
primitive_desc()=default
Default constructor. Produces an empty object.
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:4027
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const pooling_v2_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a pooling v2 (dilated pooling) backward propagation primitive...
Definition: dnnl.hpp:10257
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:7766
inner product descriptor
Definition: dnnl_types.h:2377
desc(algorithm aalgorithm, const memory::desc &diff_src_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &kernel, const memory::dims &dilation, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for pooling v2 (dilated pooling) backward propagation primitive.
Definition: dnnl.hpp:10199
5D tensor blocked by 2nd dimension with block size 16
Definition: dnnl_types.h:331
A descriptor of reduction operation.
Definition: dnnl_types.h:1936
6D tensor blocked by 2nd dimension with block size 4
Definition: dnnl_types.h:393
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an inner product forward propagation primitive from a C API pri...
Definition: dnnl.hpp:6978
batch_normalization_forward(const primitive_desc &pd)
Constructs a batch normalization forward propagation primitive.
Definition: dnnl.hpp:6415
void get_params_binary(int index, algorithm &aalgorithm, memory::desc &src1_desc) const
Returns the parameters of a binary post-op.
Definition: dnnl.hpp:2578
Out-of-order execution.
status gemm_u8s8s32(char transa, char transb, char offsetc, dnnl_dim_t M, dnnl_dim_t N, dnnl_dim_t K, float alpha, const uint8_t *A, dnnl_dim_t lda, uint8_t ao, const int8_t *B, dnnl_dim_t ldb, int8_t bo, float beta, int32_t *C, dnnl_dim_t ldc, const int32_t *co)
Performs integer matrix-matrix multiply on 8-bit unsigned matrix A, 8-bit signed matrix B...
Definition: dnnl.hpp:10727
dnnl_status_t DNNL_API dnnl_memory_get_memory_desc(const_dnnl_memory_t memory, const dnnl_memory_desc_t **memory_desc)
Returns the memory descriptor for a memory object.
desc(algorithm aalgorithm, const memory::desc &diff_src_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &kernel, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for pooling backward propagation primitive.
Definition: dnnl.hpp:5550
dnnl_status_t
Status values returned by the library functions.
Definition: dnnl_types.h:39
memory::desc diff_src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5622
stream()=default
Constructs an empty stream.
Pooling backward propagation primitive.
Definition: dnnl.hpp:5524
Undefined data type (used for empty memory descriptors).
Reduction using lp norm.
Definition: dnnl_types.h:1062
memory::desc dst_iter_c_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8142
dnnl_status_t DNNL_API dnnl_primitive_create(dnnl_primitive_t *primitive, const_dnnl_primitive_desc_t primitive_desc)
Creates a primitive.
dnnl_status_t DNNL_API dnnl_pooling_v2_backward_desc_init(dnnl_pooling_v2_desc_t *pool_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t kernel, const dnnl_dims_t dilation, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for pooling v2 (pooling with dilation support) backward propagation primitiv...
Binary mul.
Definition: dnnl_types.h:1036
LRN within a single channel.
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:5511
dnnl_status_t DNNL_API dnnl_post_ops_destroy(dnnl_post_ops_t post_ops)
Destroys post-ops.
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:8580
const dnnl_memory_desc_t DNNL_API * dnnl_primitive_desc_query_md(const_dnnl_primitive_desc_t primitive_desc, dnnl_query_t what, int index)
Queries primitive descriptor for a memory descriptor.
memory::desc diff_weights_layer_desc() const
Returns diff weights layer memory descriptor.
Definition: dnnl.hpp:8995
Primitive descriptor for a batch normalization forward propagation primitive.
Definition: dnnl.hpp:6322
Elementwise: rectified linear unit (ReLU)
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:8098
PReLU forward propagation primitive.
Definition: dnnl.hpp:10307
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a layer normalization backward propagation primitive from a C A...
Definition: dnnl.hpp:6823
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:8964
A softmax primitive.
Definition: dnnl_types.h:906
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5841
memory::desc diff_dst_layer_desc() const
Returns diff destination layer memory descriptor.
Definition: dnnl.hpp:7395
desc(prop_kind aprop_kind, const memory::desc &data_desc, float epsilon, normalization_flags flags)
Constructs a batch normalization descriptor for forward propagation.
Definition: dnnl.hpp:6309
memory::desc weights_peephole_desc() const
Returns weights peephole memory descriptor.
Definition: dnnl.hpp:8570
int64_t dnnl_dim_t
A type to describe tensor dimension.
Definition: dnnl_types.h:1162
dnnl_status_t DNNL_API dnnl_primitive_desc_clone(dnnl_primitive_desc_t *primitive_desc, const_dnnl_primitive_desc_t existing_primitive_desc)
Clones a primitive descriptor.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an LSTM forward propagation primitive.
Definition: dnnl.hpp:8081
Forward data propagation (alias for dnnl_forward_training).
Definition: dnnl_types.h:875
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:9159
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:9167
stream & wait()
Waits for all primitives executing in the stream to finish.
Definition: dnnl.hpp:1019
primitive kind
Definition: dnnl_types.h:2343
matrix multiplication (matmul) descriptor
Definition: dnnl_types.h:2382
shuffle_backward()=default
Default constructor. Produces an empty object.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:9645
Default stream configuration.
Definition: dnnl_types.h:2417
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6513
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a batch normalization forward propagation primitive from a C AP...
Definition: dnnl.hpp:6363
Reduction.
Definition: dnnl.hpp:10505
Shuffle forward propagation primitive.
Definition: dnnl.hpp:9410
logsoftmax descriptor
error(dnnl_status_t status, const char *message)
Constructs an instance of an exception class.
Definition: dnnl.hpp:92
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a matmul primitive.
Definition: dnnl.hpp:9730
LRN within a single channel.
Definition: dnnl_types.h:1018
primitive_desc(const desc &adesc, const engine &aengine, const batch_normalization_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a batch normalization backward propagation primitive.
Definition: dnnl.hpp:6467
dnnl_status_t DNNL_API dnnl_lstm_backward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *src_iter_c_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *dst_iter_c_desc, const dnnl_memory_desc_t *diff_src_layer_desc, const dnnl_memory_desc_t *diff_src_iter_desc, const dnnl_memory_desc_t *diff_src_iter_c_desc, const dnnl_memory_desc_t *diff_weights_layer_desc, const dnnl_memory_desc_t *diff_weights_iter_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_layer_desc, const dnnl_memory_desc_t *diff_dst_iter_desc, const dnnl_memory_desc_t *diff_dst_iter_c_desc, unsigned flags)
Initializes a descriptor for an LSTM backward propagation primitive.
dnnl_data_type_t
Data type specification.
Definition: dnnl_types.h:62
post_ops()
Constructs an empty sequence of post-ops.
Definition: dnnl.hpp:2270
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:6670
plain 4D tensor
Definition: dnnl_types.h:180
const_dnnl_primitive_desc_t get_primitive_desc() const
Returns the C API primitive descriptor of the underlying C API primitive.
Definition: dnnl.hpp:368
bool next_impl()
Advances the primitive iterator to the next implementation.
Definition: dnnl.hpp:3740
pooling_backward(const primitive_desc &pd)
Constructs a pooling backward propagation primitive.
Definition: dnnl.hpp:5637
dnnl_status_t DNNL_API dnnl_pooling_v2_forward_desc_init(dnnl_pooling_v2_desc_t *pool_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *dst_desc, const dnnl_dims_t strides, const dnnl_dims_t kernel, const dnnl_dims_t dilation, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for pooling v2 (pooling with dilation support) forward propagation primitive...
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a vanilla RNN backward propagation primitive from a C API primi...
Definition: dnnl.hpp:7761
memory::desc diff_dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6047
batch_normalization_forward()=default
Default constructor. Produces an empty object.
plain 6D tensor
Definition: dnnl_types.h:183
Tensor concatenation (concat) primitive.
Definition: dnnl.hpp:3509
Primitive attributes.
Definition: dnnl.hpp:2602
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:9321
dnnl_status_t DNNL_API dnnl_engine_create(dnnl_engine_t *engine, dnnl_engine_kind_t kind, size_t index)
Creates an engine.
Eltwise: exp (dst for backward)
Definition: dnnl_types.h:1006
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:4202
Winograd convolution.
Definition: dnnl_types.h:947
void get_params_eltwise(int index, float &scale, algorithm &aalgorithm, float &alpha, float &beta) const
Returns parameters of an elementwise post-op.
Definition: dnnl.hpp:2379
5D tensor blocked by 3rd dimension with block size 4
Definition: dnnl_types.h:381
int get_primitive_cache_capacity()
Returns the number of primitives that can be held in the primitive cache at the same time...
Definition: dnnl.hpp:10696
desc reshape(const dims &adims, bool allow_empty=false) const
Constructs a memory descriptor by reshaping an existing one.
Definition: dnnl.hpp:1938
Intel AVX-512 subset for Intel Xeon Scalable processor family and Intel Core processor family...
primitive_attr(dnnl_primitive_attr_t attr)
Creates primitive attributes from a C API dnnl_primitive_attr_t handle.
Definition: dnnl.hpp:2618
primitive_desc(const desc &adesc, const engine &aengine, const inner_product_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an inner product weights update primitive.
Definition: dnnl.hpp:7176
#define DNNL_ARG_DIFF_SRC_ITER_C
A special mnemonic for gradient (diff) of RNN input recurrent cell state vector.
Definition: dnnl_types.h:2214
Vanilla RNN backward propagation primitive.
Definition: dnnl.hpp:7618
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a layer normalization forward propagation primitive from a C AP...
Definition: dnnl.hpp:6663
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:5176
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:5386
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:7321
Layer normalization backward propagation primitive.
Definition: dnnl.hpp:6717
dnnl_format_tag_t
Memory format tag specification.
Definition: dnnl_types.h:164
Max pooling.
Definition: dnnl_types.h:1008
dnnl_status_t DNNL_API dnnl_memory_get_engine(const_dnnl_memory_t memory, dnnl_engine_t *engine)
Returns the engine of a memory object.
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:7592
Eltwise: natural logarithm.
Definition: dnnl_types.h:986
Reduction using max operation.
memory::desc diff_src_layer_desc() const
Returns diff source layer memory descriptor.
Definition: dnnl.hpp:7800
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an LRN forward propagation primitive.
Definition: dnnl.hpp:5249
memory::desc diff_bias_desc() const
Returns the diff bias memory descriptor.
Definition: dnnl.hpp:4473
Elementwise: round.
A PReLU primitive.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an LSTM forward propagation primitive from a C API primitive de...
Definition: dnnl.hpp:8092
primitive_desc_base(dnnl_primitive_desc_t pd, dnnl::primitive::kind prim_kind, dnnl::prop_kind prop_kind1, dnnl::prop_kind prop_kind2)
Constructs a primitive descriptor base object from a clone of a C API primitive descriptor after veri...
Definition: dnnl.hpp:3301
primitive_desc(const desc &adesc, const engine &aengine, const primitive_attr &attr=primitive_attr(), bool allow_empty=false)
Constructs a primitive descriptor for a shuffle forward propagation primitive.
Definition: dnnl.hpp:9450
const char * what() const noexcept override
Returns the explanatory string.
Definition: dnnl.hpp:96
primitive_desc()=default
Default constructor. Produces an empty object.
operation descriptor
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a convolution forward propagation primitive.
Definition: dnnl.hpp:4007
dnnl_status_t DNNL_API dnnl_memory_map_data(const_dnnl_memory_t memory, void **mapped_ptr)
Maps a memory object and returns a host-side pointer to a memory buffer with a copy of its contents...
#define DNNL_ARG_DIFF_WEIGHTS_PROJECTION
A special mnemonic for diff of RNN weights applied to the projection weights.
Definition: dnnl_types.h:2265
Unidirectional execution of RNN primitive from left to right.
dnnl_status_t DNNL_API dnnl_post_ops_append_binary(dnnl_post_ops_t post_ops, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src1_desc)
Appends a binary post-op.
plain 12D tensor
Definition: dnnl_types.h:189
dnnl_status_t DNNL_API dnnl_inner_product_backward_data_desc_init(dnnl_inner_product_desc_t *ip_desc, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *diff_dst_desc)
Initializes descriptor for inner product backward propagation.
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc(const_dnnl_op_desc_t desc, const primitive_attr *attr, const engine &aengine, const_dnnl_primitive_desc_t hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor.
Definition: dnnl.hpp:3722
kind
Kinds of engines.
Definition: dnnl.hpp:868
dnnl_status_t DNNL_API dnnl_primitive_attr_get_rnn_weights_projection_qparams(const_dnnl_primitive_attr_t attr, dnnl_dim_t *count, int *mask, const float **scales)
Returns the quantization scaling factors for RNN projection weights tensors.
4D CNN activations tensor blocked by channels with block size 4, an alias to dnnl_aBcd4b ...
Definition: dnnl_types.h:615
Base class for all computational primitives.
Definition: dnnl.hpp:269
Reduction using lp norm.
Definition: dnnl_types.h:1060
T get(bool allow_empty=false) const
Returns the underlying C API handle.
Definition: dnnl.hpp:185
Primitive descriptor for a reduction primitive.
Definition: dnnl.hpp:10540
Binary div.
Definition: dnnl_types.h:1042
Primitive descriptor for a batch normalization backward propagation primitive.
Definition: dnnl.hpp:6450
const version_t * version()
Returns library version information.
Definition: dnnl.hpp:10630
4D tensor blocked by 2nd dimension with block size 8
Definition: dnnl_types.h:303
Out-of-order execution.
Definition: dnnl_types.h:2415
Descriptor for a GRU backward propagation primitive.
Definition: dnnl.hpp:8817
Fuse normalization with ReLU.
Binary min.
Definition: dnnl_types.h:1040
pooling_backward()=default
Default constructor. Produces an empty object.
Batch normalization backward propagation primitive.
Definition: dnnl.hpp:6419
status
Status values returned by the library functions.
Definition: dnnl.hpp:10607
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a PReLU forward propagation primitive.
Definition: dnnl.hpp:10361
desc(const dims &adims, data_type adata_type, const dims &strides, bool allow_empty=false)
Constructs a memory descriptor by strides.
Definition: dnnl.hpp:1852
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const inner_product_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an inner product weights update primitive.
Definition: dnnl.hpp:7196
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:6676
memory::desc bias_desc() const
Returns the bias memory descriptor.
Definition: dnnl.hpp:4750
Primitive descriptor for a logsoftmax forward propagation primitive.
Definition: dnnl.hpp:6097
void get_rnn_data_qparams(float &scale, float &shift)
Returns the quantization scale and shift parameters for RNN data tensors.
Definition: dnnl.hpp:2886
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:4205
Default stream configuration.
permuted 3D tensor
Definition: dnnl_types.h:196
primitive_desc()=default
Default constructor. Produces an empty object.
4D tensor blocked by 3rd dimension with block size 4
Definition: dnnl_types.h:323
5D CNN activations tensor blocked by channels with block size 4, an alias to dnnl_aBcde4b ...
Definition: dnnl_types.h:603
layer_normalization_backward()=default
Default constructor. Produces an empty object.
Average pooling (alias for dnnl_pooling_avg_exclude_padding)
Definition: dnnl_types.h:1014
Descriptor for a batch normalization forward propagation primitive.
Definition: dnnl.hpp:6292
Primitive descriptor for an LRN backward propagation primitive.
Definition: dnnl.hpp:5330
Descriptor for an elementwise binary operator primitive.
Definition: dnnl.hpp:9570
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:7295
#define DNNL_ARG_DIFF_BIAS
Gradient (diff) of the bias tensor argument.
Definition: dnnl_types.h:2268
memory::desc diff_src_layer_desc() const
Returns diff source layer memory descriptor.
Definition: dnnl.hpp:8985
Pooling v2 (dilated pooling) forward propagation primitive.
Definition: dnnl.hpp:10050
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6836
3D tensor blocked by 2nd dimension with block size 8
Definition: dnnl_types.h:262
Binary add.
Definition: dnnl_types.h:1034
dnnl_status_t DNNL_API dnnl_lstm_backward_desc_init_v3(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *src_iter_c_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *weights_peephole_desc, const dnnl_memory_desc_t *weights_projection_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *dst_iter_c_desc, const dnnl_memory_desc_t *diff_src_layer_desc, const dnnl_memory_desc_t *diff_src_iter_desc, const dnnl_memory_desc_t *diff_src_iter_c_desc, const dnnl_memory_desc_t *diff_weights_layer_desc, const dnnl_memory_desc_t *diff_weights_iter_desc, const dnnl_memory_desc_t *diff_weights_peephole_desc, const dnnl_memory_desc_t *diff_weights_projection_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_layer_desc, const dnnl_memory_desc_t *diff_dst_iter_desc, const dnnl_memory_desc_t *diff_dst_iter_c_desc, unsigned flags)
Initializes a descriptor for an LSTM (with or without peephole and with or with out recurrent project...
memory::desc dst_iter_c_desc() const
Returns destination recurrent cell state memory descriptor.
Definition: dnnl.hpp:7335
deconvolution descriptor
Definition: dnnl_types.h:2368
A pooling primitive.
Definition: dnnl_types.h:908
void get_params_sum(int index, float &scale, memory::data_type &data_type) const
Returns the parameters of an accumulation (sum) post-op.
Definition: dnnl.hpp:2343
#define DNNL_ARG_WEIGHTS_PEEPHOLE
A special mnemonic for RNN weights applied to the peephole weights.
Definition: dnnl_types.h:2173
Primitive descriptor for a PReLU forward propagation primitive.
Definition: dnnl.hpp:10331
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a GRU backward propagation primitive from a C API primitive des...
Definition: dnnl.hpp:8946
rnn descriptor
Definition: dnnl_types.h:2378
void set_scales(int arg, int mask, const std::vector< float > &scales)
Sets scaling factors for primitive operations for a given memory argument.
Definition: dnnl.hpp:2752
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:7092
memory required for scratchpad (bytes)
LSTM forward propagation primitive.
Definition: dnnl.hpp:7845
memory::data_type data_type() const
Returns the data type of the memory descriptor.
Definition: dnnl.hpp:2008
dnnl_status_t DNNL_API dnnl_pooling_forward_desc_init(dnnl_pooling_desc_t *pool_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *dst_desc, const dnnl_dims_t strides, const dnnl_dims_t kernel, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for pooling forward propagation primitive.
Eltwise: logistic.
Definition: dnnl_types.h:973
status sgemm(char transa, char transb, dnnl_dim_t M, dnnl_dim_t N, dnnl_dim_t K, float alpha, const float *A, dnnl_dim_t lda, const float *B, dnnl_dim_t ldb, float beta, float *C, dnnl_dim_t ldc)
Performs single-precision matrix-matrix multiply.
Definition: dnnl.hpp:10719
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:6839
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:3453
In-order execution.
resampling_backward()=default
Default constructor. Produces an empty object.
A descriptor of a shuffle operation.
Definition: dnnl_types.h:1416
dnnl_status_t DNNL_API dnnl_reorder_primitive_desc_create(dnnl_primitive_desc_t *reorder_primitive_desc, const dnnl_memory_desc_t *src_desc, dnnl_engine_t src_engine, const dnnl_memory_desc_t *dst_desc, dnnl_engine_t dst_engine, const_dnnl_primitive_attr_t attr)
Creates a primitive descriptor for a reorder primitive.
resampling_forward()=default
Default constructor. Produces an empty object.
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:10022
memory::desc diff_weights_projection_desc() const
Returns diff weights projection memory descriptor.
Definition: dnnl.hpp:7380
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:10151
prelu_forward()=default
Default constructor. Produces an empty object.
desc(algorithm aalgorithm, const std::vector< float > &factors, const memory::desc &diff_src_desc, const memory::desc &diff_dst_desc)
Constructs a descriptor for resampling backward propagation primitive.
Definition: dnnl.hpp:9954
Elementwise: exponent.
Intel AVX-512, Intel DL Boost and bfloat16 support for Intel Xeon Scalable processor family and Intel...
cpu_isa get_effective_cpu_isa()
Gets the maximal ISA the library can dispatch to on the CPU.
Definition: dnnl.hpp:10682
primitive_desc(const desc &adesc, const engine &aengine, const softmax_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a softmax backward propagation primitive.
Definition: dnnl.hpp:6003
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:3677
Eltwise: hyperbolic tangent non-linearity (tanh) (dst for backward)
Definition: dnnl_types.h:998
dnnl_status_t DNNL_API dnnl_lbr_gru_backward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, const dnnl_memory_desc_t *diff_src_layer_desc, const dnnl_memory_desc_t *diff_src_iter_desc, const dnnl_memory_desc_t *diff_weights_layer_desc, const dnnl_memory_desc_t *diff_weights_iter_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_layer_desc, const dnnl_memory_desc_t *diff_dst_iter_desc, unsigned flags)
Initializes a descriptor for LBR GRU backward propagation primitive.
dnnl_status_t DNNL_API dnnl_shuffle_forward_desc_init(dnnl_shuffle_desc_t *shuffle_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *data_desc, int axis, dnnl_dim_t group_size)
Initializes a descriptor for shuffle forward propagation primitive.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a GRU forward propagation primitive.
Definition: dnnl.hpp:8754
dnnl_status_t DNNL_API dnnl_memory_desc_reshape(dnnl_memory_desc_t *out_memory_desc, const dnnl_memory_desc_t *in_memory_desc, int ndims, const dnnl_dims_t dims)
Initializes a memory descriptor by reshaping an existing one.
convolution descriptor
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:4910
lbr_gru_forward(const primitive_desc &pd)
Constructs an LBR GRU forward propagation primitive.
Definition: dnnl.hpp:9178
Winograd deconvolution.
Definition: dnnl_types.h:953
dnnl_status_t DNNL_API dnnl_set_max_cpu_isa(dnnl_cpu_isa_t isa)
Sets the maximal ISA the library can dispatch to on the CPU.
memory::desc bias_desc() const
Returns the bias memory descriptor.
Definition: dnnl.hpp:9751
permuted 4D tensor
Definition: dnnl_types.h:211
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:6679
dnnl_status_t DNNL_API dnnl_memory_desc_init_by_tag(dnnl_memory_desc_t *memory_desc, int ndims, const dnnl_dims_t dims, dnnl_data_type_t data_type, dnnl_format_tag_t tag)
Initializes a memory descriptor using dimensions and memory format tag.
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:8969
primitive_desc()=default
Default constructor. Produces an empty object.
Primitive descriptor for an LBR GRU backward propagation primitive.
Definition: dnnl.hpp:9266
layer_normalization_backward(const primitive_desc &pd)
Constructs a layer normalization backward propagation primitive.
Definition: dnnl.hpp:6867
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an inner product weights update primitive from a C API primitiv...
Definition: dnnl.hpp:7209
dnnl_status_t DNNL_API dnnl_eltwise_forward_desc_init(dnnl_eltwise_desc_t *eltwise_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *data_desc, float alpha, float beta)
Initializes a descriptor for eltwise forward propagation primitive.
dnnl_dim_t dim
Integer type for representing dimension sizes and indices.
Definition: dnnl.hpp:1106
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:7774
reorder()=default
Default constructor. Produces an empty object.
Convolution backward propagation primitive.
Definition: dnnl.hpp:4049
number of outputs expected
Definition: dnnl_types.h:2346
Primitive descriptor for a deconvolution forward propagation primitive.
Definition: dnnl.hpp:4694
memory::desc diff_src_iter_c_desc() const
Returns diff source recurrent cell state memory descriptor.
Definition: dnnl.hpp:7355
reorder(const primitive_desc &pd)
Constructs a reorder primitive.
Definition: dnnl.hpp:3461
memory::desc bias_desc() const
Returns the bias memory descriptor.
Definition: dnnl.hpp:6993
Descriptor for a matmul primitive.
Definition: dnnl.hpp:9672
#define DNNL_MAX_NDIMS
Maximum number of dimensions a tensor can have.
Definition: dnnl_types.h:1130
engine get_dst_engine() const
Returns the engine on which the destination memory is allocated.
Definition: dnnl.hpp:3445
lbr_gru_backward(const primitive_desc &pd)
Constructs an LBR GRU backward propagation primitive.
Definition: dnnl.hpp:9396
gru_backward()=default
Default constructor. Produces an empty object.
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:7784
Primitive descriptor for a vanilla RNN forward propagation primitive.
Definition: dnnl.hpp:7527
Elementwise: swish ( )
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a layer normalization forward propagation primitive.
Definition: dnnl.hpp:6636
plain 1D tensor
Definition: dnnl_types.h:177
The user manages the scratchpad allocation by querying and providing the scratchpad memory to primiti...
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:7792
Softmax forward propagation primitive.
Definition: dnnl.hpp:5870
primitive_desc()=default
Default constructor. Produces an empty object.
Bidirectional execution of RNN primitive with concatenation of the results.
Definition: dnnl_types.h:1769
Reduction using min.
Definition: dnnl_types.h:1052
permuted 2D tensor
Definition: dnnl_types.h:202
permuted 5D tensor
Definition: dnnl_types.h:213
A layer normalization primitive.
dnnl_status_t DNNL_API dnnl_primitive_get_primitive_desc(const_dnnl_primitive_t primitive, const_dnnl_primitive_desc_t *primitive_desc)
Retrieves a constant reference to the primitive descriptor of a given primitive.
Descriptor for a deconvolution backward propagation primitive.
Definition: dnnl.hpp:4765
memory::desc diff_dst_layer_desc() const
Returns diff destination layer memory descriptor.
Definition: dnnl.hpp:9380
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated convolution weights gradient primitive with bias...
Definition: dnnl.hpp:4338
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const inner_product_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an inner product backward propagation primitive.
Definition: dnnl.hpp:7071
permuted 6D tensor
Definition: dnnl_types.h:198
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:7329
reduction descriptor
int DNNL_API dnnl_memory_desc_equal(const dnnl_memory_desc_t *lhs, const dnnl_memory_desc_t *rhs)
Compares two memory descriptors.
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:7795
memory::desc src1_desc() const
Returns the memory descriptor for source #1.
Definition: dnnl.hpp:9642
desc()=default
Default constructor. Produces an empty object.
memory::desc diff_src_iter_c_desc() const
Returns diff source recurrent cell state memory descriptor.
Definition: dnnl.hpp:8611
void get_scales(int arg, int &mask, std::vector< float > &scales) const
Returns scaling factors correspondence mask and values for a given memory argument.
Definition: dnnl.hpp:2722
dnnl_engine_kind_t convert_to_c(engine::kind akind)
Converts engine kind enum value from C++ API to C API type.
Definition: dnnl.hpp:955
memory::desc src_desc(int idx=0) const
Returns a source memory descriptor.
Definition: dnnl.hpp:3577
dnnl::primitive::kind get_kind() const
Returns the kind of the primitive descriptor.
Definition: dnnl.hpp:3237
5D CNN activations tensor blocked by channels with block size 8, an alias to dnnl_aBcde8b ...
Definition: dnnl_types.h:606
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an elementwise binary operator primitive.
Definition: dnnl.hpp:9623
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a softmax backward propagation primitive from a C API primitive...
Definition: dnnl.hpp:6036
propagation kind
Definition: dnnl_types.h:2362
Descriptor for a GRU forward propagation primitive.
Definition: dnnl.hpp:8668
inner_product_forward()=default
Default constructor. Produces an empty object.
plain 9D tensor
Definition: dnnl_types.h:186
cpu_isa
CPU instruction set flags.
Definition: dnnl.hpp:10650
An inner product primitive.
Definition: dnnl_types.h:916
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a vanilla RNN forward propagation primitive.
Definition: dnnl.hpp:7541
Use global statistics.
Definition: dnnl_types.h:1092
shuffle descriptor
Primitive descriptor for an elementwise binary operator primitive.
Definition: dnnl.hpp:9595
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a pooling forward propagation primitive.
Definition: dnnl.hpp:5473
eltwise descriptor
desc(prop_kind aprop_kind, algorithm activation, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, rnn_flags flags=rnn_flags::undef, float alpha=0.0f, float beta=0.0f)
Constructs a descriptor for a vanilla RNN backward propagation primitive.
Definition: dnnl.hpp:7675
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a deconvolution forward propagation primitive.
Definition: dnnl.hpp:4724
dnnl_status_t DNNL_API dnnl_post_ops_append_dw_k3s1p1(dnnl_post_ops_t post_ops, dnnl_data_type_t weights_data_type, dnnl_data_type_t bias_data_type, dnnl_data_type_t dst_data_type, dnnl_dim_t count, int mask, const float *scales)
Appends a depthwise post-op convolution with stride 1.
Primitive descriptor for a GRU backward propagation primitive.
Definition: dnnl.hpp:8898
memory::desc diff_dst_iter_desc() const
Returns diff destination iteration memory descriptor.
Definition: dnnl.hpp:9385
engine get_engine() const
Returns the associated engine.
Definition: dnnl.hpp:2094
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an LRN forward propagation primitive.
Definition: dnnl.hpp:5264
GRU cell.
Definition: dnnl_types.h:1024
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6990
memory::desc variance_desc() const
Returns memory descriptor for variance.
Definition: dnnl.hpp:6685
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a softmax forward propagation primitive.
Definition: dnnl.hpp:5911
The operation was successful.
Definition: dnnl_types.h:41
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:8779
Undefined propagation kind.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a deconvolution backward propagation primitive from a C API pri...
Definition: dnnl.hpp:4905
deconvolution_forward()=default
Default constructor. Produces an empty object.
static void validate_dims(const std::vector< T > &v, int min_size=0)
Helper function that validates that an std::vector of dimensions can be safely converted to the C API...
Definition: dnnl.hpp:1118
primitive_desc()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_post_ops_append_dw_k3s2p1(dnnl_post_ops_t post_ops, dnnl_data_type_t weights_data_type, dnnl_data_type_t bias_data_type, dnnl_data_type_t dst_data_type, dnnl_dim_t count, int mask, const float *scales)
Appends a depthwise post-op convolution with stride 2.
memory::desc diff_dst_iter_desc() const
Returns diff destination iteration memory descriptor.
Definition: dnnl.hpp:7403
kind get_kind() const
Returns the kind of the primitive.
Definition: dnnl.hpp:375
Elementwise: hyperbolic tangent non-linearity (tanh)
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const resampling_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a resampling backward propagation primitive.
Definition: dnnl.hpp:10004
A descriptor of a Layer Normalization operation.
Definition: dnnl_types.h:1685
Undefined primitive.
8-bit signed integer.
Definition: dnnl_types.h:74
Primitive descriptor for an elementwise forward propagation primitive.
Definition: dnnl.hpp:5694
C API.
convolution descriptor
Definition: dnnl_types.h:2367
concat()=default
Default constructor. Produces an empty object.
RNN cell.
Definition: dnnl_types.h:1020
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const layer_normalization_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a layer normalization backward propagation primitive.
Definition: dnnl.hpp:6810
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:3174
Alias for dnnl_unidirectional_left2right.
Definition: dnnl_types.h:1774
A (out-of-place) concat primitive.
Definition: dnnl_types.h:896
handle(T t, bool weak=false)
Constructs a handle wrapper object from a C API handle.
Definition: dnnl.hpp:169
convolution_backward_data()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_prelu_forward_desc_init(dnnl_prelu_desc_t *prelu_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *data_desc, const dnnl_memory_desc_t *weights_desc)
Initializes a descriptor for PReLU (leaky ReLU with trainable alpha parameter) forward propagation pr...
dnnl_status_t DNNL_API dnnl_convolution_forward_desc_init(dnnl_convolution_desc_t *conv_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_desc, const dnnl_dims_t strides, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a convolution forward propagation primitive.
desc()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_set_jit_profiling_jitdumpdir(const char *dir)
Sets JIT dump output path.
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated deconvolution forward propagation primitive with bias...
Definition: dnnl.hpp:4625
dnnl_status_t DNNL_API dnnl_primitive_destroy(dnnl_primitive_t primitive)
Destroys a primitive.
Intel AVX-512 and Intel Deep Learning Boost (Intel DL Boost) support for Intel Xeon Scalable processo...
Definition: dnnl_types.h:2524
Undefined memory format tag.
Definition: dnnl_types.h:166
A shuffle primitive.
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc(const memory &src, const memory &dst, const primitive_attr &attr=primitive_attr(), bool allow_empty=false)
Constructs a primitive descriptor for reorder primitive.
Definition: dnnl.hpp:3414
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a resampling forward propagation primitive from a C API primiti...
Definition: dnnl.hpp:9902
#define DNNL_ARG_DIFF_SRC_LAYER
A special mnemonic for gradient (diff) of RNN input vector.
Definition: dnnl_types.h:2202
The operation failed because of incorrect function arguments.
dnnl_status_t DNNL_API dnnl_dilated_convolution_backward_data_desc_init(dnnl_convolution_desc_t *conv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t dilates, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a dilated convolution backward propagation primitive.
dnnl_status_t DNNL_API dnnl_deconvolution_forward_desc_init(dnnl_deconvolution_desc_t *deconv_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_desc, const dnnl_dims_t strides, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a deconvolution forward propagation primitive.
dnnl_status_t DNNL_API dnnl_post_ops_append_sum(dnnl_post_ops_t post_ops, float scale)
Appends an accumulation (sum) to post-ops.
Reduction using mul.
Definition: dnnl_types.h:1056
permuted 5D tensor
Definition: dnnl_types.h:197
resampling descriptor
Eltwise: square root.
Definition: dnnl_types.h:965
dnnl_status_t DNNL_API dnnl_primitive_attr_get_output_scales(const_dnnl_primitive_attr_t attr, dnnl_dim_t *count, int *mask, const float **scales)
Returns primitive attributes output scaling factors correspondence mask and values.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a resampling forward propagation primitive. ...
Definition: dnnl.hpp:9891
primitive_desc()=default
Default constructor. Produces an empty object.
lstm_backward(const primitive_desc &pd)
Constructs an LSTM backward propagation primitive.
Definition: dnnl.hpp:8662
inner product descriptor
primitive_desc()=default
Default constructor. Produces an empty object.
Primitive descriptor for resampling backward propagation primitive.
Definition: dnnl.hpp:9967
void set_output_scales(int mask, const std::vector< float > &scales)
Sets output scaling factors correspondence mask and values.
Definition: dnnl.hpp:2704
dnnl_status_t DNNL_API dnnl_binary_desc_init(dnnl_binary_desc_t *binary_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src0_desc, const dnnl_memory_desc_t *src1_desc, const dnnl_memory_desc_t *dst_desc)
Initializes a descriptor for a binary primitive.
memory::desc dst_desc(int idx) const
Returns a destination memory descriptor.
Definition: dnnl.hpp:3115
Primitive descriptor for an LSTM forward propagation primitive.
Definition: dnnl.hpp:8053
static void wrap_c_api(dnnl_status_t status, const char *message)
A convenience function for wrapping calls to C API functions.
Definition: dnnl.hpp:103
Intel Advanced Vector Extensions (Intel AVX)
lrn_forward(const primitive_desc &pd)
Constructs an LRN forward propagation primitive.
Definition: dnnl.hpp:5296
desc(const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc)
Constructs a descriptor for a matmul primitive.
Definition: dnnl.hpp:9680
convolution_forward(const primitive_desc &pd)
Constructs a convolution forward propagation primitive.
Definition: dnnl.hpp:4045
rnn descriptor
permuted 3D tensor
Definition: dnnl_types.h:206
dnnl_status_t DNNL_API dnnl_set_jit_dump(int enable)
Configures dumping of JIT-generated code.
permuted 8D tensor
Definition: dnnl_types.h:218
primitive_desc(const desc &adesc, const engine &aengine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a convolution backward propagation primitive.
Definition: dnnl.hpp:4161
Primitive or engine failed on execution.
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a resampling forward propagation primitive. ...
Definition: dnnl.hpp:9875
A logsoftmax primitive.
GRU backward propagation primitive.
Definition: dnnl.hpp:8815
desc(algorithm aalgorithm, const memory::desc &diff_src_desc, const memory::desc &weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for dilated convolution backward propagation primitive.
Definition: dnnl.hpp:4123
dnnl_status_t DNNL_API dnnl_memory_set_data_handle_v2(dnnl_memory_t memory, void *handle, dnnl_stream_t stream)
Sets the underlying memory buffer.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:10381
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a deconvolution weights gradient primitive without bias.
Definition: dnnl.hpp:5002
Inner product backward propagation primitive.
Definition: dnnl.hpp:7006
dnnl_status_t DNNL_API dnnl_deconvolution_backward_data_desc_init(dnnl_deconvolution_desc_t *deconv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a deconvolution backward propagation primitive.
Backward bias propagation.
LBR GRU forward propagation primitive.
Definition: dnnl.hpp:9030
rnn_primitive_desc_base()=default
Default constructor. Produces an empty object.
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:6858
source memory desc
Definition: dnnl_types.h:2389
A base class for descriptors of all primitives that have an operation descriptor and that support ite...
Definition: dnnl.hpp:3695
#define DNNL_ARG_DIFF_DST_LAYER
A special mnemonic for gradient (diff) of RNN output vector.
Definition: dnnl_types.h:2223
Eltwise: swish.
Definition: dnnl_types.h:984
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:4916
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:9545
memory(const desc &md, const engine &aengine, void *handle)
Constructs a memory object.
Definition: dnnl.hpp:2068
engine get_src_engine() const
Returns the engine on which the source memory is allocated.
Definition: dnnl.hpp:3439
desc()=default
Default constructor. Produces an empty object.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a batch normalization forward propagation primitive.
Definition: dnnl.hpp:6352
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:3168
desc(const memory::desc &diff_data_desc, int axis, int group_size)
Constructs a descriptor for a shuffle backward propagation primitive.
Definition: dnnl.hpp:9497
#define DNNL_ARG_TO
A special mnemonic for reorder destination argument.
Definition: dnnl_types.h:2135
pooling_forward(const primitive_desc &pd)
Constructs a pooling forward propagation primitive.
Definition: dnnl.hpp:5520
status set_jit_profiling_flags(unsigned flags)
Sets library profiling flags.
Definition: dnnl.hpp:10640
dnnl_cpu_isa_t DNNL_API dnnl_get_effective_cpu_isa(void)
Gets the maximal ISA the library can dispatch to on the CPU.
dnnl_status_t DNNL_API dnnl_stream_wait(dnnl_stream_t stream)
Waits for all primitives in the execution stream to finish computations.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a LBR GRU backward propagation primitive from a C API primitive...
Definition: dnnl.hpp:9316
dnnl_primitive_kind_t DNNL_API dnnl_post_ops_get_kind(const_dnnl_post_ops_t post_ops, int index)
Returns the kind of a post-op entry.
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5505
dnnl_status_t DNNL_API dnnl_batch_normalization_backward_desc_init(dnnl_batch_normalization_desc_t *bnrm_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *data_desc, float epsilon, unsigned flags)
Initializes a descriptor for a batch normalization backward propagation primitive.
dnnl_status_t DNNL_API dnnl_primitive_attr_set_scales(dnnl_primitive_attr_t attr, int arg, dnnl_dim_t count, int mask, const float *scales)
Sets primitive attributes scaling factors for primitive operations for a given memory argument...
memory::desc diff_bias_desc() const
Returns diff bias memory descriptor.
Definition: dnnl.hpp:8636
Memory descriptor.
Definition: dnnl_types.h:1274
const dnnl_version_t DNNL_API * dnnl_version(void)
Returns library version information.
Elementwise binary operator primitive.
Definition: dnnl.hpp:9568
A descriptor of a pooling operation.
Definition: dnnl_types.h:1559
dnnl_data_type_t data_type
Data type of the tensor elements.
Definition: dnnl_types.h:1294
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an LSTM backward propagation primitive from a C API primitive d...
Definition: dnnl.hpp:8542
primitive_desc()=default
Default constructor. Produces an empty object.
memory::desc mean_desc() const
Returns memory descriptor for mean.
Definition: dnnl.hpp:6850
A matrix multiplication primitive.
Definition: dnnl_types.h:926
Queried element is not required for given primitive.
Definition: dnnl_types.h:53
The library manages the scratchpad allocation according to the policy specified by the DNNL_ENABLE_CO...
void get_params_sum(int index, float &scale) const
Returns the parameters of an accumulation (sum) post-op.
Definition: dnnl.hpp:2333
dnnl_status_t DNNL_API dnnl_prelu_backward_desc_init(dnnl_prelu_desc_t *prelu_desc, const dnnl_memory_desc_t *data_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *diff_weights_desc)
Initializes a descriptor for PReLU (leaky ReLU with trainable alpha parameter) backward propagation p...
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:5947
primitive_desc(int concat_dimension, const std::vector< memory::desc > &srcs, const engine &aengine, const primitive_attr &attr=primitive_attr())
Constructs a primitive descriptor for an out-of-place concatenation primitive.
Definition: dnnl.hpp:3554
dnnl_status_t DNNL_API dnnl_layer_normalization_forward_desc_init(dnnl_layer_normalization_desc_t *lnrm_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *data_desc, const dnnl_memory_desc_t *stat_desc, float epsilon, unsigned flags)
Initializes a descriptor for layer normalization forward propagation primitive.
Descriptor for a softmax backward propagation primitive.
Definition: dnnl.hpp:5962
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a pooling v2 (dilated pooling) forward propagation primitive...
Definition: dnnl.hpp:10117
primitive_attr get_primitive_attr() const
Returns the primitive attributes.
Definition: dnnl.hpp:3225
Eltwise: erf-based gelu.
Definition: dnnl_types.h:992
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:3580
permuted 9D tensor
Definition: dnnl_types.h:219
dnnl_status_t DNNL_API dnnl_engine_destroy(dnnl_engine_t engine)
Destroys an engine.
The operation failed due to an out-of-memory condition.
Definition: dnnl_types.h:43
Deconvolution backward propagation primitive.
Definition: dnnl.hpp:4763
handle< T, traits > & operator=(const handle< T, traits > &)=default
Assignment operator.
Primitive descriptor for a reorder primitive.
Definition: dnnl.hpp:3365
Backward weights propagation.
Definition: dnnl_types.h:881
layer normalization descriptor
5D tensor blocked by 2nd dimension with block size 32
Definition: dnnl_types.h:340
Reduction using sum operation.
Queried element is not required for given primitive.
primitive_desc()=default
Default constructor. Produces an empty object.
Primitive descriptor for a convolution forward propagation primitive.
Definition: dnnl.hpp:3977
memory::desc diff_dst_iter_c_desc() const
Returns diff destination recurrent cell state memory descriptor.
Definition: dnnl.hpp:8651
dnnl_status_t DNNL_API dnnl_primitive_attr_set_rnn_weights_projection_qparams(dnnl_primitive_attr_t attr, dnnl_dim_t count, int mask, const float *scales)
Sets quantization scaling factors for RNN projection weights tensors.
#define DNNL_ARG_DIFF_DST_ITER_C
A special mnemonic for gradient (diff) of RNN input recurrent cell state vector.
Definition: dnnl_types.h:2235
memory::desc diff_weights_layer_desc() const
Returns diff weights layer memory descriptor.
Definition: dnnl.hpp:7810
workspace memory desc
Definition: dnnl_types.h:2395
weights gradient (diff) memory desc
inner_product_backward_weights()=default
Default constructor. Produces an empty object.
dnnl_status_t DNNL_API dnnl_softmax_backward_desc_init(dnnl_softmax_desc_t *softmax_desc, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *data_desc, int softmax_axis)
Initializes a descriptor for softmax backward propagation primitive.
Memory object.
Definition: dnnl.hpp:1102
convolution_backward_weights(const primitive_desc &pd)
Constructs a convolution weights gradient primitive.
Definition: dnnl.hpp:4484
dnnl_status_t DNNL_API dnnl_primitive_execute(const_dnnl_primitive_t primitive, dnnl_stream_t stream, int nargs, const dnnl_exec_arg_t *args)
Executes a primitive.
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:7574
Descriptor for a pooling backward propagation primitive.
Definition: dnnl.hpp:5526
primitive_desc()=default
Default constructor. Produces an empty object.
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:6376
memory::desc diff_weights_iter_desc() const
Returns diff weights iteration memory descriptor.
Definition: dnnl.hpp:9370
dnnl_status_t DNNL_API dnnl_sgemm(char transa, char transb, dnnl_dim_t M, dnnl_dim_t N, dnnl_dim_t K, float alpha, const float *A, dnnl_dim_t lda, const float *B, dnnl_dim_t ldb, float beta, float *C, dnnl_dim_t ldc)
Performs single-precision matrix-matrix multiply.
memory::desc weights_layer_desc() const
Returns weights layer memory descriptor.
Definition: dnnl.hpp:8111
Elementwise: exponent (dst for backward)
eltwise descriptor
Definition: dnnl_types.h:2370
number of inputs expected
Definition: dnnl_types.h:2345
shuffle descriptor
Definition: dnnl_types.h:2369
Average pooling include padding.
Definition: dnnl_types.h:1010
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:8131
Linear (Bilinear, Trilinear) resampling method.
Reduction using min operation.
Weights format used in 8bit Winograd convolution.
Definition: dnnl_types.h:91
logsoftmax_backward()=default
Default constructor. Produces an empty object.
primitive_desc()=default
Default constructor. Produces an empty object.
memory::desc variance_desc() const
Returns memory descriptor for variance.
Definition: dnnl.hpp:6530
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:5389
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:7269
dnnl_status_t DNNL_API dnnl_primitive_attr_set_rnn_weights_qparams(dnnl_primitive_attr_t attr, dnnl_dim_t count, int mask, const float *scales)
Sets quantization scaling factors for RNN weights tensors.
desc(const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc)
Constructs a descriptor for a matmul primitive.
Definition: dnnl.hpp:9694
32-bit/single-precision floating point.
Definition: dnnl_types.h:70
desc(prop_kind aprop_kind, algorithm aalgorithm, const std::vector< float > &factors, const memory::desc &src_desc, const memory::desc &dst_desc)
Constructs a descriptor for a resampling forward propagation primitive.
Definition: dnnl.hpp:9847
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:8792
permuted 5D tensor
Definition: dnnl_types.h:212
#define DNNL_MEMORY_ALLOCATE
Special pointer value that indicates that the library needs to allocate an underlying buffer for a me...
Definition: dnnl_types.h:1339
engine scratchpad_engine() const
Returns the engine on which the scratchpad memory is located.
Definition: dnnl.hpp:3213
Intel AVX-512, Intel DL Boost and bfloat16 support for Intel Xeon Scalable processor family and Intel...
Definition: dnnl_types.h:2529
Elementwise: linear.
Primitive descriptor for a softmax backward propagation primitive.
Definition: dnnl.hpp:5986
Reorder primitive.
Definition: dnnl.hpp:3363
4D CNN activations tensor blocked by channels with block size 8, an alias to dnnl_aBcd8b ...
Definition: dnnl_types.h:618
bool operator==(const desc &other) const
An equality operator.
Definition: dnnl.hpp:2027
prelu_backward(const primitive_desc &pd)
Constructs a prelu backward propagation primitive.
Definition: dnnl.hpp:10490
Descriptor for an inner product forward propagation primitive.
Definition: dnnl.hpp:6883
memory::desc src_iter_c_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8106
memory::desc diff_weights_desc() const
Returns a diff weights memory descriptor.
Definition: dnnl.hpp:7217
Descriptor for a shuffle forward propagation primitive.
Definition: dnnl.hpp:9412
lrn descriptor
Definition: dnnl_types.h:2374
void append_binary(algorithm aalgorithm, const memory::desc &src1_desc)
Appends a binary post-op.
Definition: dnnl.hpp:2567
dnnl_status_t DNNL_API dnnl_memory_create(dnnl_memory_t *memory, const dnnl_memory_desc_t *memory_desc, dnnl_engine_t engine, void *handle)
Creates a memory object.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:10154
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:6830
dnnl_status_t DNNL_API dnnl_set_primitive_cache_capacity(int capacity)
Sets a number of primitives that can be held in the primitive cache at a time.
dnnl_status_t DNNL_API dnnl_eltwise_backward_desc_init(dnnl_eltwise_desc_t *eltwise_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_data_desc, const dnnl_memory_desc_t *data_desc, float alpha, float beta)
Initializes a descriptor for eltwise backward propagation primitive.
primitive_desc(const desc &adesc, const engine &aengine, const resampling_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a resampling backward propagation primitive.
Definition: dnnl.hpp:9984
desc(prop_kind aprop_kind, const memory::desc &data_desc, int logsoftmax_axis)
Constructs a descriptor for a logsoftmax forward propagation primitive.
Definition: dnnl.hpp:6086
memory::desc diff_src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5383
Primitive descriptor for an LSTM backward propagation primitive.
Definition: dnnl.hpp:8494
4D tensor blocked by 1st and 2nd dimension with block size 8
Definition: dnnl_types.h:311
A shuffle primitive.
Definition: dnnl_types.h:894
memory::desc mean_desc() const
Returns memory descriptor for mean.
Definition: dnnl.hpp:6383
engine(const handle< dnnl_primitive_desc_t > &pd)
Constructs an engine based on a primitive from the primitive descriptor pd by querying its engine...
Definition: dnnl.hpp:908
memory::desc diff_dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6255
for creating scratchpad memory
Definition: dnnl_types.h:2357
dnnl_status_t DNNL_API dnnl_primitive_attr_set_scratchpad_mode(dnnl_primitive_attr_t attr, dnnl_scratchpad_mode_t mode)
Sets primitive attributes scratchpad mode.
dnnl_status_t DNNL_API dnnl_dilated_deconvolution_backward_weights_desc_init(dnnl_deconvolution_desc_t *deconv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *diff_weights_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t dilates, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a dilated deconvolution weights gradient primitive.
memory::desc diff_weights_iter_desc() const
Returns diff weights iteration memory descriptor.
Definition: dnnl.hpp:9000
desc(algorithm aalgorithm, const memory::desc &diff_src_desc, const memory::desc &diff_dst_desc)
Constructs a descriptor for a resampling backward propagation primitive using source and destination ...
Definition: dnnl.hpp:9937
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:6535
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:5844
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a binary primitive from a C API primitive descriptor that must ...
Definition: dnnl.hpp:9632
Intel AVX-512, Intel DL Boost and bfloat16 support and Intel AMX with 8-bit integer and bfloat16 supp...
An RNN primitive.
bool operator!=(const handle &other) const
Inequality operator.
Definition: dnnl.hpp:220
memory::desc diff_weights_desc() const
Returns a diff weights memory descriptor.
Definition: dnnl.hpp:3192
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a LBR GRU forward propagation primitive from a C API primitive ...
Definition: dnnl.hpp:9132
permuted 4D tensor
Definition: dnnl_types.h:207
bool operator==(const handle< T, traits > &other) const
Equality operator.
Definition: dnnl.hpp:210
desc(const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_dst_desc)
Constructs a descriptor for an inner product descriptor weights update primitive without bias...
Definition: dnnl.hpp:7146
Intel Advanced Vector Extensions 2 (Intel AVX2)
4D tensor blocked by 2nd dimension with block size 4
Definition: dnnl_types.h:282
Binary max.
Definition: dnnl_types.h:1038
Unspecified format kind.
Definition: dnnl_types.h:85
oneAPI namespace
Definition: dnnl.hpp:10777
void set_zero_points(int arg, int mask, const std::vector< int32_t > &zero_points)
Sets zero points for primitive operations for a given memory argument.
Definition: dnnl.hpp:2804
Resampling forward propagation.
Definition: dnnl.hpp:9780
dnnl_status_t DNNL_API dnnl_pooling_backward_desc_init(dnnl_pooling_desc_t *pool_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t kernel, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for pooling backward propagation primitive.
desc(const dims &adims, data_type adata_type, format_tag aformat_tag, bool allow_empty=false)
Constructs a memory descriptor.
Definition: dnnl.hpp:1824
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const softmax_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a softmax backward propagation primitive.
Definition: dnnl.hpp:6023
Average pooling exclude padding.
Definition: dnnl_types.h:1012
Reduction using mul operation.
memory::desc diff_src_desc(int idx) const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:3133
memory::desc diff_dst_desc() const
Returns a diff destination memory descriptor.
Definition: dnnl.hpp:4467
3D CNN activations tensor blocked by channels with block size 16, an alias to dnnl_aBc16b ...
Definition: dnnl_types.h:624
dnnl_status_t DNNL_API dnnl_get_primitive_cache_capacity(int *capacity)
Returns the number of primitives that can be held in the primitive cache at the same time...
dnnl_alg_kind_t
Kinds of algorithms.
Definition: dnnl_types.h:942
Reduction using norm_lp_power_p_max operation.
primitive_desc()=default
Default constructor. Produces an empty object.
Reduction using max.
Definition: dnnl_types.h:1050
Primitive descriptor for an RNN backward propagation primitive.
Definition: dnnl.hpp:7711
permuted 3D tensor
Definition: dnnl_types.h:209
memory::desc weights_projection_desc() const
Returns weights projection memory descriptor.
Definition: dnnl.hpp:7307
desc get_desc() const
Returns the associated memory descriptor.
Definition: dnnl.hpp:2086
dnnl_rnn_flags_t
Flags for RNN cell.
Definition: dnnl_types.h:1756
Descriptor for a PReLU forward propagation primitive.
Definition: dnnl.hpp:10309
bool operator!=(const desc &other) const
An inequality operator.
Definition: dnnl.hpp:2035
Base class for all primitive descriptors.
Definition: dnnl.hpp:3041
Primitive descriptor for a layer normalization backward propagation primitive.
Definition: dnnl.hpp:6773
A pooling version 2 primitive (pooling with dilation support).
Definition: dnnl_types.h:930
Descriptor for a vanilla RNN forward propagation primitive.
Definition: dnnl.hpp:7459
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:4747
primitive_desc(const desc &adesc, const engine &aengine, const gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a GRU backward propagation primitive.
Definition: dnnl.hpp:8914
memory::desc src0_desc() const
Returns the memory descriptor for source #0.
Definition: dnnl.hpp:9639
dnnl_status_t DNNL_API dnnl_primitive_desc_destroy(dnnl_primitive_desc_t primitive_desc)
Destroys a primitive descriptor.
dnnl_status_t DNNL_API dnnl_post_ops_create(dnnl_post_ops_t *post_ops)
Creates empty post-ops sequence.
dnnl_binary_desc_t data
Underlying C operation descriptor.
Definition: dnnl.hpp:9572
void append_sum(float scale=1.f, memory::data_type data_type=memory::data_type::undef)
Appends an accumulation (sum) post-op.
Definition: dnnl.hpp:2318
An LRN primitive.
Definition: dnnl_types.h:910
reorder(const memory &src, const memory &dst, const primitive_attr &attr=primitive_attr())
Constructs a reorder primitive that would reorder data between memory objects having the same memory ...
Definition: dnnl.hpp:3470
A descriptor of a Local Response Normalization (LRN) operation.
Definition: dnnl_types.h:1621
Primitive descriptor for a shuffle backward propagation primitive.
Definition: dnnl.hpp:9506
Primitive descriptor for prelu backward propagation.
Definition: dnnl.hpp:10420
int ndims
Number of dimensions.
Definition: dnnl_types.h:1276
dnnl_stream_flags_t
Stream flags.
Definition: dnnl_types.h:2411
Undefined propagation type.
Definition: dnnl_types.h:864
dnnl_status_t DNNL_API dnnl_engine_get_kind(dnnl_engine_t engine, dnnl_engine_kind_t *kind)
Returns the kind of an engine.
oneDNN C API handle wrapper class.
Definition: dnnl.hpp:136
Primitive or engine failed on execution.
Definition: dnnl_types.h:51
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc(const desc &adesc, const engine &aengine, const lstm_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an LSTM backward propagation primitive.
Definition: dnnl.hpp:8510
void set_rnn_weights_qparams(int mask, const std::vector< float > &scales)
Sets quantization scaling factors for RNN weights tensors.
Definition: dnnl.hpp:2922
op descriptor
Definition: dnnl_types.h:2366
dnnl_status_t DNNL_API dnnl_primitive_attr_clone(dnnl_primitive_attr_t *attr, const_dnnl_primitive_attr_t existing_attr)
Clones primitive attributes.
primitive_desc_base()=default
Default constructor. Produces an empty object.
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a convolution weights gradient primitive with bias.
Definition: dnnl.hpp:4250
6D tensor blocked by 2nd dimension with block size 8
Definition: dnnl_types.h:388
lrn_backward()=default
Default constructor. Produces an empty object.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a vanilla RNN forward propagation primitive from a C API primit...
Definition: dnnl.hpp:7568
Primitive descriptor for an inner product forward propagation primitive.
Definition: dnnl.hpp:6937
memory::desc src_desc(int idx=0) const
Returns a source memory descriptor.
Definition: dnnl.hpp:9636
primitive_desc(const desc &adesc, const engine &aengine, const lbr_gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an LBR GRU backward propagation primitive.
Definition: dnnl.hpp:9283
desc(prop_kind aprop_kind, const memory::desc &data_desc, int axis, int group_size)
Constructs a descriptor for a shuffle forward propagation primitive.
Definition: dnnl.hpp:9424
memory::desc bias_desc() const
Returns bias memory descriptor.
Definition: dnnl.hpp:7315
Descriptor for a deconvolution forward propagation primitive.
Definition: dnnl.hpp:4500
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a logsoftmax forward propagation primitive. ...
Definition: dnnl.hpp:6111
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const logsoftmax_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a logsoftmax backward propagation primitive.
Definition: dnnl.hpp:6227
Eltwise: exponent.
Definition: dnnl_types.h:975
weights memory descriptor desc
lbr_gru_backward()=default
Default constructor. Produces an empty object.
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const eltwise_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an elementwise backward propagation primitive.
Definition: dnnl.hpp:5823
dnnl_status_t DNNL_API dnnl_primitive_attr_get_rnn_weights_qparams(const_dnnl_primitive_attr_t attr, dnnl_dim_t *count, int *mask, const float **scales)
Returns the quantization scaling factors for RNN weights tensors.
desc(const memory::desc &data_desc, const memory::desc &weight_desc, const memory::desc &diff_data_desc, const memory::desc &diff_weights_desc)
Constructs a descriptor for a PReLU backward propagation primitive.
Definition: dnnl.hpp:10407
Reduction using norm_lp_max operation.
dnnl_status_t DNNL_API dnnl_primitive_desc_iterator_destroy(dnnl_primitive_desc_iterator_t iterator)
Destroys a primitive descriptor iterator.
primitive_desc()=default
Default constructor. Produces an empty object.
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:10157
memory::desc src_iter_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:9143
Local response normalization (LRN) across multiple channels.
Definition: dnnl_types.h:1016
resampling descriptor
Definition: dnnl_types.h:2383
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a convolution forward propagation primitive.
Definition: dnnl.hpp:3991
stream(const engine &aengine, flags aflags=flags::default_flags)
Constructs a stream for the specified engine and with behavior controlled by the specified flags...
Definition: dnnl.hpp:1001
dnnl_status_t DNNL_API dnnl_logsoftmax_forward_desc_init(dnnl_logsoftmax_desc_t *logsoftmax_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *data_desc, int logsoftmax_axis)
Initializes a descriptor for logsoftmax forward propagation primitive.
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a LBR GRU forward propagation primitive.
Definition: dnnl.hpp:9105
Forward data propagation, alias for dnnl::prop_kind::forward_inference.
softmax_forward()=default
Default constructor. Produces an empty object.
primitive_desc(const desc &adesc, const engine &aengine, const prelu_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a PReLU backward propagation primitive.
Definition: dnnl.hpp:10437
desc(prop_kind aprop_kind, algorithm aalgorithm, const std::vector< float > &factors, const memory::desc &src_desc)
Constructs a descriptor for a resampling forward propagation primitive using source memory descriptor...
Definition: dnnl.hpp:9820
Descriptor for a logsoftmax backward propagation primitive.
Definition: dnnl.hpp:6166
memory::desc diff_dst_layer_desc() const
Returns diff destination layer memory descriptor.
Definition: dnnl.hpp:7825
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:8951
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a pooling backward propagation primitive from a C API primitive...
Definition: dnnl.hpp:5617
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const deconvolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a deconvolution weights update primitive.
Definition: dnnl.hpp:5150
Primitive descriptor for a GRU forward propagation primitive.
Definition: dnnl.hpp:8726
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an LSTM forward propagation primitive.
Definition: dnnl.hpp:8066
dnnl_status_t DNNL_API dnnl_inner_product_backward_weights_desc_init(dnnl_inner_product_desc_t *ip_desc, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *diff_weights_desc, const dnnl_memory_desc_t *diff_bias_desc, const dnnl_memory_desc_t *diff_dst_desc)
Initializes descriptor for inner product weights gradient primitive.
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:8116
plain 3D tensor
Definition: dnnl_types.h:179
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:3180
Use scale and shift parameters.
Definition: dnnl_types.h:1105
A descriptor of a Batch Normalization operation.
Definition: dnnl_types.h:1652
dnnl_status_t DNNL_API dnnl_lbr_gru_forward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, unsigned flags)
Initializes a descriptor for LBR GRU forward propagation primitive.
memory::desc dst_layer_desc() const
Returns destination layer memory descriptor.
Definition: dnnl.hpp:7787
primitive_desc()=default
Default constructor. Produces an empty object.
Intel Advanced Vector Extensions 2 (Intel AVX2)
Definition: dnnl_types.h:2507
3D CNN activations tensor blocked by channels with block size 4, an alias to dnnl_aBc4b ...
Definition: dnnl_types.h:627
Eltwise: exponential linear unit (elu) (dst for backward)
Definition: dnnl_types.h:1000
Logsoftmax forward propagation primitive.
Definition: dnnl.hpp:6070
Convolution algorithm that is chosen to be either direct or Winograd automatically.
Eltwise: exponential linear unit (elu)
Definition: dnnl_types.h:959
dnnl_status_t DNNL_API dnnl_matmul_desc_init(dnnl_matmul_desc_t *matmul_desc, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_desc)
Initializes a matrix multiplication descriptor.
pooling descriptor
dnnl_primitive_desc_t DNNL_API dnnl_primitive_desc_iterator_fetch(const_dnnl_primitive_desc_iterator_t iterator)
Fetches the current primitive descriptor from a primitive descriptor iterator.
size_t DNNL_API dnnl_engine_get_count(dnnl_engine_kind_t kind)
Returns the number of engines of a particular kind.
6D tensor blocked by 2nd dimension with block size 16
Definition: dnnl_types.h:383
Forward data propagation (alias for dnnl_forward_inference).
Definition: dnnl_types.h:873
Binary sub.
Definition: dnnl_types.h:1044
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:5944
Primitive descriptor for a matmul primitive.
Definition: dnnl.hpp:9704
5D CNN activations tensor blocked by channels with block size 16, an alias to dnnl_aBcde16b ...
Definition: dnnl_types.h:600
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated convolution weights gradient primitive without bias...
Definition: dnnl.hpp:4385
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, rnn_flags flags=rnn_flags::undef)
Constructs a descriptor for LBR GRU forward propagation primitive.
Definition: dnnl.hpp:9068
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a deconvolution weights gradient primitive with bias. ...
Definition: dnnl.hpp:4960
An opaque structure to describe a primitive descriptor.
Descriptor for a LBR GRU backward propagation primitive.
Definition: dnnl.hpp:9184
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const pooling_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a pooling backward propagation primitive.
Definition: dnnl.hpp:5604
memory::desc diff_src_desc() const
Returns a diff source memory descriptor.
Definition: dnnl.hpp:6516
Eltwise: abs.
Definition: dnnl_types.h:963
bool is_zero() const
Checks whether the memory descriptor is zero (empty).
Definition: dnnl.hpp:2021
Descriptor for resampling forward propagation.
Definition: dnnl.hpp:9782
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:3198
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:6379
Forward data propagation (training mode).
Definition: dnnl_types.h:867
A deconvolution primitive.
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a GRU forward propagation primitive.
Definition: dnnl.hpp:8739
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a prelu backward propagation primitive from a C API primitive d...
Definition: dnnl.hpp:10470
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const lbr_gru_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an LBR GRU backward propagation primitive.
Definition: dnnl.hpp:9303
permuted 5D tensor
Definition: dnnl_types.h:194
desc(prop_kind aprop_kind, const memory::desc &diff_data_desc, const memory::desc &data_desc, float epsilon, normalization_flags flags)
Constructs a batch normalization descriptor for backward propagation.
Definition: dnnl.hpp:6436
Elementwise: rectified linar unit (ReLU) (dst for backward)
lstm_forward(const primitive_desc &pd)
Constructs an LSTM forward propagation primitive.
Definition: dnnl.hpp:8158
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an LRN backward propagation primitive from a C API primitive de...
Definition: dnnl.hpp:5378
Eltwise: tanh-based gelu (alias for dnnl_eltwise_gelu_tanh)
Definition: dnnl_types.h:982
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a logsoftmax forward propagation primitive from a C API primiti...
Definition: dnnl.hpp:6138
Descriptor for an LSTM backward propagation primitive.
Definition: dnnl.hpp:8164
source gradient (diff) memory desc
A rnn primitive.
Definition: dnnl_types.h:918
An opaque structure to describe an execution stream.
Primitive descriptor for an inner product backward propagation primitive.
Definition: dnnl.hpp:7034
Descriptor for a layer normalization backward propagation primitive.
Definition: dnnl.hpp:6719
A logsoftmax primitive.
Definition: dnnl_types.h:924
memory::desc diff_src_iter_desc() const
Returns diff source iteration memory descriptor.
Definition: dnnl.hpp:8990
primitive_desc()=default
Default constructor. Produces an empty object.
A convolution primitive.
rnn_flags
RNN cell flags.
Definition: dnnl.hpp:652
Elementwise: square.
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an elementwise binary operator primitive.
Definition: dnnl.hpp:9608
dnnl_status_t DNNL_API dnnl_resampling_backward_desc_init(dnnl_resampling_desc_t *resampling_desc, dnnl_alg_kind_t alg_kind, const float *factors, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *diff_dst_desc)
Initializes a descriptor for resampling backward propagation primitive.
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:6370
Descriptor for a shuffle primitive backward propagation primitive.
Definition: dnnl.hpp:9487
permuted 5D tensor
Definition: dnnl_types.h:205
dnnl_status_t DNNL_API dnnl_post_ops_append_sum_v2(dnnl_post_ops_t post_ops, float scale, dnnl_data_type_t data_type)
Appends an accumulation v2 (sum) to post-ops.
memory::desc diff_src_iter_desc() const
Returns diff source iteration memory descriptor.
Definition: dnnl.hpp:7805
logsoftmax_forward(const primitive_desc &pd)
Constructs a logsoftmax forward propagation primitive.
Definition: dnnl.hpp:6160
desc(prop_kind aprop_kind, rnn_direction direction, const memory::desc &src_layer_desc, const memory::desc &src_iter_desc, const memory::desc &src_iter_c_desc, const memory::desc &weights_layer_desc, const memory::desc &weights_iter_desc, const memory::desc &bias_desc, const memory::desc &dst_layer_desc, const memory::desc &dst_iter_desc, const memory::desc &dst_iter_c_desc, const memory::desc &diff_src_layer_desc, const memory::desc &diff_src_iter_desc, const memory::desc &diff_src_iter_c_desc, const memory::desc &diff_weights_layer_desc, const memory::desc &diff_weights_iter_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_layer_desc, const memory::desc &diff_dst_iter_desc, const memory::desc &diff_dst_iter_c_desc, rnn_flags flags=rnn_flags::undef)
Constructs an LSTM descriptor for backward propagation using prop_kind, direction, and memory descriptors.
Definition: dnnl.hpp:8453
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &bias_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a deconvolution forward propagation primitive with bias.
Definition: dnnl.hpp:4532
The operation failed because requested functionality is not implemented.
Definition: dnnl_types.h:47
Eltwise: gelu.
Definition: dnnl_types.h:980
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an eltwise forward propagation primitive from a C API primitive...
Definition: dnnl.hpp:5735
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:4741
memory::desc diff_dst_layer_desc() const
Returns diff destination layer memory descriptor.
Definition: dnnl.hpp:9010
Eltwise: hyperbolic tangent non-linearity (tanh)
Definition: dnnl_types.h:957
primitive_desc()=default
Default constructor. Produces an empty object.
Primitive descriptor for a deconvolution backward propagation primitive.
Definition: dnnl.hpp:4855
desc(prop_kind aprop_kind, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc)
Constructs a descriptor for an inner product forward propagation primitive without bias...
Definition: dnnl.hpp:6924
desc(algorithm aalgorithm, const memory::desc &diff_data_desc, const memory::desc &data_desc, float alpha=0, float beta=0)
Constructs a descriptor for an elementwise backward propagation primitive.
Definition: dnnl.hpp:5773
Softmax backward propagation primitive.
Definition: dnnl.hpp:5960
void set_primitive_cache_capacity(int capacity)
Sets a number of primitives that can be held in the primitive cache at a time.
Definition: dnnl.hpp:10704
permuted 10D tensor
Definition: dnnl_types.h:220
primitive_desc(const desc &adesc, const engine &aengine, const pooling_v2_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a pooling v2 (dilated pooling) backward propagation primitive...
Definition: dnnl.hpp:10237
Bidirectional execution of RNN primitive with summation of the results.
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:4913
Primitive descriptor for an LBR GRU forward propagation primitive.
Definition: dnnl.hpp:9091
dnnl_status_t DNNL_API dnnl_memory_desc_init_submemory(dnnl_memory_desc_t *memory_desc, const dnnl_memory_desc_t *parent_memory_desc, const dnnl_dims_t dims, const dnnl_dims_t offsets)
Initializes a memory descriptor for a region inside an area described by an existing memory descripto...
A descriptor of resampling operation.
Definition: dnnl_types.h:1908
dnnl_status_t DNNL_API dnnl_set_verbose(int level)
Configures verbose output to stdout.
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:8588
primitive_desc()=default
Default constructor. Produces an empty object.
primitive_desc(const desc &adesc, const engine &aengine, const deconvolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a deconvolution backward propagation primitive.
Definition: dnnl.hpp:4872
dnnl_status_t DNNL_API dnnl_primitive_attr_get_post_ops(const_dnnl_primitive_attr_t attr, const_dnnl_post_ops_t *post_ops)
Returns primitive attributes post-ops.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a convolution weights gradient primitive from a C API primitive...
Definition: dnnl.hpp:4454
desc(prop_kind aprop_kind, const memory::desc &data_desc, int softmax_axis)
Constructs a descriptor for a softmax forward propagation primitive.
Definition: dnnl.hpp:5886
scratchpad_mode get_scratchpad_mode() const
Returns the scratchpad mode.
Definition: dnnl.hpp:2622
primitive_desc(const std::vector< float > &scales, const std::vector< memory::desc > &srcs, const engine &aengine, const primitive_attr &attr=primitive_attr())
Constructs a primitive descriptor for a sum primitive.
Definition: dnnl.hpp:3648
dnnl_status_t DNNL_API dnnl_post_ops_get_params_sum_v2(const_dnnl_post_ops_t post_ops, int index, float *scale, dnnl_data_type_t *data_type)
Returns the parameters of an accumulation (sum) post-op with a data type parameter.
query
Primitive descriptor query specification.
Definition: dnnl.hpp:739
memory::desc diff_dst_layer_desc() const
Returns diff destination layer memory descriptor.
Definition: dnnl.hpp:8641
Primitive descriptor for a sum primitive.
Definition: dnnl.hpp:3604
T * map_data() const
Maps a memory object and returns a host-side pointer to a memory buffer with a copy of its contents...
Definition: dnnl.hpp:2184
dnnl_prop_kind_t
Kinds of propagation.
Definition: dnnl_types.h:861
#define DNNL_ARG_DIFF_WEIGHTS_LAYER
A special mnemonic for diff of RNN weights applied to the layer input.
Definition: dnnl_types.h:2247
dnnl_status_t DNNL_API dnnl_batch_normalization_forward_desc_init(dnnl_batch_normalization_desc_t *bnrm_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *data_desc, float epsilon, unsigned flags)
Initializes a descriptor for a batch normalization forward propagation primitive. ...
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated deconvolution weights gradient primitive without bias...
Definition: dnnl.hpp:5092
permuted 6D tensor
Definition: dnnl_types.h:216
scratchpad_mode
Scratchpad mode.
Definition: dnnl.hpp:401
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated deconvolution forward propagation primitive without bias...
Definition: dnnl.hpp:4673
Descriptor for a pooling forward propagation primitive.
Definition: dnnl.hpp:5414
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for an elementwise forward propagation primitive.
Definition: dnnl.hpp:5724
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:6510
desc(prop_kind aprop_kind, algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &weights_desc, const memory::desc &dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a deconvolution forward propagation primitive without bias...
Definition: dnnl.hpp:4577
primitive_desc(const desc &adesc, const engine &aengine, const eltwise_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an elementwise backward propagation primitive.
Definition: dnnl.hpp:5803
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a convolution weights gradient primitive without bias.
Definition: dnnl.hpp:4293
primitive_desc()=default
Default constructor. Produces an empty object.
desc(prop_kind aprop_kind, const memory::desc &diff_data_desc, const memory::desc &data_desc, const memory::desc &stat_desc, float epsilon, normalization_flags flags)
Constructs a descriptor for layer normalization backward propagation primitive.
Definition: dnnl.hpp:6735
Convolution weights gradient primitive.
Definition: dnnl.hpp:4218
Elementwise: gelu alias for dnnl::algorithm::eltwise_gelu_tanh.
void set_rnn_weights_projection_qparams(int mask, const std::vector< float > &scales)
Sets quantization scaling factors for RNN projection weights tensors.
Definition: dnnl.hpp:2989
Nearest Neighbor Resampling Method.
Definition: dnnl_types.h:1046
std::vector< dim > dims
Vector of dimensions.
Definition: dnnl.hpp:1109
concat(const primitive_desc &pd)
Constructs a concatenation primitive.
Definition: dnnl.hpp:3588
permuted 4D tensor
Definition: dnnl_types.h:204
memory::dim query_s64(query what) const
Returns a memory::dim value (same as int64_t).
Definition: dnnl.hpp:3065
desc()
Constructs a zero (empty) memory descriptor.
Definition: dnnl.hpp:1807
dnnl_status_t DNNL_API dnnl_stream_destroy(dnnl_stream_t stream)
Destroys an execution stream.
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an eltwise backward propagation primitive from a C API primitiv...
Definition: dnnl.hpp:5836
dnnl_status_t DNNL_API dnnl_vanilla_rnn_forward_desc_init(dnnl_rnn_desc_t *rnn_desc, dnnl_prop_kind_t prop_kind, const dnnl_alg_kind_t activation, const dnnl_rnn_direction_t direction, const dnnl_memory_desc_t *src_layer_desc, const dnnl_memory_desc_t *src_iter_desc, const dnnl_memory_desc_t *weights_layer_desc, const dnnl_memory_desc_t *weights_iter_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_layer_desc, const dnnl_memory_desc_t *dst_iter_desc, unsigned flags, float alpha, float beta)
Initializes a descriptor for vanilla RNN forward propagation primitive.
16-bit/half-precision floating point.
Definition: dnnl_types.h:66
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const convolution_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a convolution backward propagation primitive.
Definition: dnnl.hpp:4181
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a pooling v2 (dilated pooling) forward propagation primitive fr...
Definition: dnnl.hpp:10145
Primitive descriptor for a softmax forward propagation primitive.
Definition: dnnl.hpp:5897
Primitive descriptor for eltwise backward propagation.
Definition: dnnl.hpp:5786
source engine
Definition: dnnl_types.h:2359
Descriptor for a softmax forward propagation primitive.
Definition: dnnl.hpp:5872
dnnl_status_t DNNL_API dnnl_inner_product_forward_desc_init(dnnl_inner_product_desc_t *ip_desc, dnnl_prop_kind_t prop_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_desc)
Initializes descriptor for inner product forward propagation.
logsoftmax_forward()=default
Default constructor. Produces an empty object.
const post_ops get_post_ops() const
Returns post-ops previously set via set_post_ops().
Definition: dnnl.hpp:2815
primitive_desc(const desc &adesc, const engine &aengine, const lrn_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for an LRN backward propagation primitive.
Definition: dnnl.hpp:5346
memory::desc dst_iter_c_desc() const
Returns source iteration memory descriptor.
Definition: dnnl.hpp:8591
dnnl_status_t DNNL_API dnnl_resampling_forward_desc_init(dnnl_resampling_desc_t *resampling_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const float *factors, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *dst_desc)
Initializes a descriptor for a resampling forward propagation primitive.
dnnl_normalization_flags_t
Flags for normalization primitives.
Definition: dnnl_types.h:1070
weights grad. memory desc
Definition: dnnl_types.h:2392
engine()=default
Constructs an empty engine.
shuffle_forward()=default
Default constructor. Produces an empty object.
#define DNNL_ARG_DST_ITER_C
A special mnemonic for LSTM output recurrent cell state vector.
Definition: dnnl_types.h:2149
algorithm
Kinds of algorithms.
Definition: dnnl.hpp:470
Resampling backward propagation primitive.
Definition: dnnl.hpp:9924
status set_jit_dump(int enable)
Configures dumping of JIT-generated code.
Definition: dnnl.hpp:10635
memory::desc variance_desc() const
Returns memory descriptor for variance.
Definition: dnnl.hpp:6387
deconvolution_backward_weights()=default
Default constructor. Produces an empty object.
Primitive iterator passed over last primitive descriptor.
memory::desc workspace_desc() const
Returns the workspace memory descriptor.
Definition: dnnl.hpp:8596
Primitive descriptor for a resampling forward propagation primitive.
Definition: dnnl.hpp:9861
format_tag
Memory format tag specification.
Definition: dnnl.hpp:1199
primitive_desc(const desc &adesc, const primitive_attr &attr, const engine &aengine, const prelu_forward::primitive_desc &hint_fwd_pd, bool allow_empty=false)
Constructs a primitive descriptor for a PReLU backward propagation primitive.
Definition: dnnl.hpp:10457
A convolution primitive.
Definition: dnnl_types.h:900
memory desc of an execute argument
Definition: dnnl_types.h:2397
#define DNNL_ARG_FROM
A special mnemonic for reorder source argument.
Definition: dnnl_types.h:2114
Backward bias propagation.
Definition: dnnl_types.h:883
Primitive descriptor for a pooling v2 (dilated pooling) backward propagation primitive.
Definition: dnnl.hpp:10220
matmul descriptor
memory::desc dst_iter_desc() const
Returns destination iteration memory descriptor.
Definition: dnnl.hpp:7600
memory::desc src_layer_desc() const
Returns source layer memory descriptor.
Definition: dnnl.hpp:9138
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a deconvolution weights gradient primitive from a C API primiti...
Definition: dnnl.hpp:5163
Eltwise: logistic (dst for backward)
Definition: dnnl_types.h:1004
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for an inner product backward propagation primitive from a C API pr...
Definition: dnnl.hpp:7084
primitive_desc(dnnl_primitive_desc_t pd)
Constructs a primitive descriptor for a pooling forward propagation primitive from a C API primitive ...
Definition: dnnl.hpp:5499
deconvolution descriptor
weights memory descriptor desc
Definition: dnnl_types.h:2391
memory::desc weights_iter_desc() const
Returns weights iteration memory descriptor.
Definition: dnnl.hpp:7587
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6041
dnnl_status_t DNNL_API dnnl_primitive_attr_get_zero_points(const_dnnl_primitive_attr_t attr, int arg, dnnl_dim_t *count, int *mask, const int32_t **zero_points)
Returns count, correspondence zero point mask, and a pointer to a constant int32_t array of zero_poin...
primitive_desc()=default
Default constructor. Produces an empty object.
void append_dw_k3s1p1(memory::data_type weights_data_type, memory::data_type bias_data_type, memory::data_type dst_data_type, int mask, const std::vector< float > &scales)
Appends a depthwise post-op convolution with stride 1.
Definition: dnnl.hpp:2416
implementation name
desc(algorithm aalgorithm, const memory::desc &src_desc, const memory::desc &diff_weights_desc, const memory::desc &diff_bias_desc, const memory::desc &diff_dst_desc, const memory::dims &strides, const memory::dims &dilates, const memory::dims &padding_l, const memory::dims &padding_r)
Constructs a descriptor for a dilated deconvolution weights gradient primitive with bias...
Definition: dnnl.hpp:5046
Linear Resampling Method.
Definition: dnnl_types.h:1048
primitive_desc(const desc &adesc, const engine &aengine, bool allow_empty=false)
Constructs a primitive descriptor for a reduction primitive.
Definition: dnnl.hpp:10552
Descriptor for a logsoftmax forward propagation primitive.
Definition: dnnl.hpp:6072
Eltwise: soft_relu.
Definition: dnnl_types.h:971
vanilla_rnn_backward(const primitive_desc &pd)
Constructs a vanilla RNN backward propagation primitive.
Definition: dnnl.hpp:7841
Unidirectional execution of RNN primitive from right to left.
plain 5D tensor
Definition: dnnl_types.h:182
Descriptor for a pooling backward propagation primitive.
Definition: dnnl.hpp:10173
memory::desc src_desc() const
Returns a source memory descriptor.
Definition: dnnl.hpp:6507
dnnl_status_t DNNL_API dnnl_dilated_deconvolution_backward_data_desc_init(dnnl_deconvolution_desc_t *deconv_desc, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *diff_src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *diff_dst_desc, const dnnl_dims_t strides, const dnnl_dims_t dilates, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a dilated deconvolution backward propagation primitive.
primitive_attr()
Constructs default (empty) primitive attributes.
Definition: dnnl.hpp:2606
destination engine
Definition: dnnl_types.h:2360
size_t get_size() const
Returns size of the memory descriptor in bytes.
Definition: dnnl.hpp:2016
batch_normalization_backward(const primitive_desc &pd)
Constructs a batch normalization backward propagation primitive.
Definition: dnnl.hpp:6544
Eltwise: square.
Definition: dnnl_types.h:961
memory::desc weights_desc() const
Returns a weights memory descriptor.
Definition: dnnl.hpp:9746
#define DNNL_ARG_DIFF_WEIGHTS_PEEPHOLE
A special mnemonic for diff of RNN weights applied to the peephole weights.
Definition: dnnl_types.h:2259
dnnl_status_t DNNL_API dnnl_primitive_attr_set_post_ops(dnnl_primitive_attr_t attr, const_dnnl_post_ops_t post_ops)
Sets primitive attributes post-ops.
An unspecified engine.
Descriptor for a convolution backward propagation primitive.
Definition: dnnl.hpp:4052
pooling_v2_backward(const primitive_desc &pd)
Constructs a pooling v2 (dilated pooling) backward propagation primitive.
Definition: dnnl.hpp:10292
memory::desc diff_dst_iter_c_desc() const
Returns diff destination recurrent cell state memory descriptor.
Definition: dnnl.hpp:7409
A batch normalization primitive.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6373
An execution stream.
Definition: dnnl.hpp:979
memory::desc diff_bias_desc() const
Returns diff bias memory descriptor.
Definition: dnnl.hpp:9375
Elementwise: exponential linear unit (ELU) (dst for backward)
reduction(const primitive_desc &pd)
Constructs a reduction primitive.
Definition: dnnl.hpp:10590
convolution_backward_weights()=default
Default constructor. Produces an empty object.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:6673
memory::desc diff_weights_iter_desc() const
Returns diff weights iteration memory descriptor.
Definition: dnnl.hpp:7815
dnnl_status_t DNNL_API dnnl_primitive_attr_get_scratchpad_mode(const_dnnl_primitive_attr_t attr, dnnl_scratchpad_mode_t *mode)
Returns the primitive attributes scratchpad mode.
memory::desc dst_desc() const
Returns a destination memory descriptor.
Definition: dnnl.hpp:10582
Post-ops.
Definition: dnnl.hpp:2266
dnnl_status_t DNNL_API dnnl_dilated_deconvolution_forward_desc_init(dnnl_deconvolution_desc_t *deconv_desc, dnnl_prop_kind_t prop_kind, dnnl_alg_kind_t alg_kind, const dnnl_memory_desc_t *src_desc, const dnnl_memory_desc_t *weights_desc, const dnnl_memory_desc_t *bias_desc, const dnnl_memory_desc_t *dst_desc, const dnnl_dims_t strides, const dnnl_dims_t dilates, const dnnl_dims_t padding_l, const dnnl_dims_t padding_r)
Initializes a descriptor for a dilated deconvolution forward propagation primitive.
primitive()=default
Default constructor. Constructs an empty object.
pooling_v2_forward(const primitive_desc &pd)
Constructs a pooling v2 (dilated pooling) forward propagation primitive.
Definition: dnnl.hpp:10167
Backward data propagation.
Matrix multiplication (matmul) primitive.
Definition: dnnl.hpp:9670
void set_data_handle(void *handle, const stream &astream) const
Sets the underlying memory buffer.
Definition: dnnl.hpp:2140