DPC++ Runtime
Runtime libraries for oneAPI DPC++
matrix-unified-utils.hpp
Go to the documentation of this file.
1 //===------- matrix-unified.hpp - SYCL matrix extension ----*- C++ -*------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 // ===--------------------------------------------------------------------=== //
8 
9 #pragma once
10 
11 #include <CL/__spirv/spirv_types.hpp> // __spv namespace
12 #include <optional> // std::optional
13 #include <string_view> // std::string_view
14 #include <utility> // std::pair
15 
16 namespace sycl {
17 inline namespace _V1 {
18 namespace ext {
19 namespace oneapi {
20 namespace experimental {
21 namespace matrix {
22 
23 enum class use { a, b, accumulator };
24 
25 enum class layout {
26  row_major = 0,
27  col_major = 1,
28  ext_intel_packed = 2,
29  dynamic = 3
30 };
31 
32 namespace precision {
33 class tf32 {
34  tf32() = delete;
35 };
36 } // namespace precision
37 
38 } // namespace matrix
39 } // namespace experimental
40 } // namespace oneapi
41 } // namespace ext
42 
43 namespace detail {
45  std::pair<ext::oneapi::experimental::matrix::use, const char *>;
46 
51 };
52 
53 constexpr const char *
55  for (const auto &Item : UseToUseStringMap) {
56  if (Item.first == Use)
57  return Item.second;
58  }
59  return "";
60 }
61 
62 constexpr std::optional<ext::oneapi::experimental::matrix::use>
63 convertMatrixUseStringToEnum(const char *UseString) {
64  for (const auto &Item : UseToUseStringMap) {
65  if (std::string_view(Item.second) == UseString)
66  return Item.first;
67  }
68  return std::nullopt;
69 }
70 
73  switch (Layout) {
74  case sycl::ext::oneapi::experimental::matrix::layout::row_major:
76  case sycl::ext::oneapi::experimental::matrix::layout::col_major:
78  case sycl::ext::oneapi::experimental::matrix::layout::ext_intel_packed:
80  case sycl::ext::oneapi::experimental::matrix::layout::dynamic:
82  }
83 }
84 
85 } // namespace detail
86 } // namespace _V1
87 } // namespace sycl
#define __SYCL_ALWAYS_INLINE
std::pair< ext::oneapi::experimental::matrix::use, const char * > UseToUseStringPair
constexpr UseToUseStringPair UseToUseStringMap[]
__SYCL_ALWAYS_INLINE __spv::MatrixLayout joint_matrix_layout_to_spv(sycl::ext::oneapi::experimental::matrix::layout Layout)
constexpr std::optional< ext::oneapi::experimental::matrix::use > convertMatrixUseStringToEnum(const char *UseString)
constexpr const char * convertMatrixUseEnumToString(ext::oneapi::experimental::matrix::use Use)
Definition: access.hpp:18