• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IntelPython / dpnp / 24347838098

13 Apr 2026 02:06PM UTC coverage: 77.879%. First build
24347838098

Pull #2843

github

web-flow
Merge 23da515f9 into 761573ccf
Pull Request #2843: Merge master into include-dpctl-tensor

1578 of 2920 branches covered (54.04%)

Branch coverage included in aggregate %.

332 of 399 new or added lines in 64 files covered. (83.21%)

26386 of 32987 relevant lines covered (79.99%)

7861.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.48
/dpnp/tensor/libtensor/include/utils/type_dispatch.hpp
1
//*****************************************************************************
2
// Copyright (c) 2026, Intel Corporation
3
// All rights reserved.
4
//
5
// Redistribution and use in source and binary forms, with or without
6
// modification, are permitted provided that the following conditions are met:
7
// - Redistributions of source code must retain the above copyright notice,
8
//   this list of conditions and the following disclaimer.
9
// - Redistributions in binary form must reproduce the above copyright notice,
10
//   this list of conditions and the following disclaimer in the documentation
11
//   and/or other materials provided with the distribution.
12
// - Neither the name of the copyright holder nor the names of its contributors
13
//   may be used to endorse or promote products derived from this software
14
//   without specific prior written permission.
15
//
16
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
26
// THE POSSIBILITY OF SUCH DAMAGE.
27
//*****************************************************************************
28
///
29
/// \file
30
/// This file defines class to implement dispatch tables for pair of types
31
//===----------------------------------------------------------------------===//
32

33
#pragma once
34

35
#include <cassert>
36
#include <cstdint>
37
#include <stdexcept>
38
#include <string>
39

40
#include "dpnp4pybind11.hpp"
41

42
#include "type_dispatch_building.hpp"
43

44
namespace dpctl::tensor::type_dispatch
45
{
46
struct usm_ndarray_types
47
{
48
    int typenum_to_lookup_id(int typenum) const
49
    {
489,680✔
50
        using typenum_t = ::dpctl::tensor::type_dispatch::typenum_t;
489,680✔
51
        auto const &api = ::dpctl::detail::dpctl_capi::get();
489,680✔
52

53
        if (typenum == api.UAR_DOUBLE_) {
489,680✔
54
            return static_cast<int>(typenum_t::DOUBLE);
233,946✔
55
        }
233,946✔
56
        else if (typenum == api.UAR_INT64_) {
255,734✔
57
            return static_cast<int>(typenum_t::INT64);
45,536✔
58
        }
45,536✔
59
        else if (typenum == api.UAR_INT32_) {
210,198✔
60
            return static_cast<int>(typenum_t::INT32);
23,672✔
61
        }
23,672✔
62
        else if (typenum == api.UAR_BOOL_) {
186,526✔
63
            return static_cast<int>(typenum_t::BOOL);
7,125✔
64
        }
7,125✔
65
        else if (typenum == api.UAR_CDOUBLE_) {
179,401✔
66
            return static_cast<int>(typenum_t::CDOUBLE);
48,784✔
67
        }
48,784✔
68
        else if (typenum == api.UAR_FLOAT_) {
130,617✔
69
            return static_cast<int>(typenum_t::FLOAT);
67,572✔
70
        }
67,572✔
71
        else if (typenum == api.UAR_INT16_) {
63,045✔
72
            return static_cast<int>(typenum_t::INT16);
3,706✔
73
        }
3,706✔
74
        else if (typenum == api.UAR_INT8_) {
59,339✔
75
            return static_cast<int>(typenum_t::INT8);
3,551✔
76
        }
3,551✔
77
        else if (typenum == api.UAR_UINT64_) {
55,788✔
78
            return static_cast<int>(typenum_t::UINT64);
3,437✔
79
        }
3,437✔
80
        else if (typenum == api.UAR_UINT32_) {
52,351✔
81
            return static_cast<int>(typenum_t::UINT32);
3,790✔
82
        }
3,790✔
83
        else if (typenum == api.UAR_UINT16_) {
48,561✔
84
            return static_cast<int>(typenum_t::UINT16);
3,031✔
85
        }
3,031✔
86
        else if (typenum == api.UAR_UINT8_) {
45,530✔
87
            return static_cast<int>(typenum_t::UINT8);
2,737✔
88
        }
2,737✔
89
        else if (typenum == api.UAR_CFLOAT_) {
42,793✔
90
            return static_cast<int>(typenum_t::CFLOAT);
31,165✔
91
        }
31,165✔
92
        else if (typenum == api.UAR_HALF_) {
11,628!
93
            return static_cast<int>(typenum_t::HALF);
11,628✔
94
        }
11,628✔
95
        else if (typenum == api.UAR_INT_ || typenum == api.UAR_UINT_) {
×
96
            switch (sizeof(int)) {
×
97
            case sizeof(std::int32_t):
×
98
                return ((typenum == api.UAR_INT_)
×
99
                            ? static_cast<int>(typenum_t::INT32)
×
100
                            : static_cast<int>(typenum_t::UINT32));
×
101
            case sizeof(std::int64_t):
×
102
                return ((typenum == api.UAR_INT_)
×
103
                            ? static_cast<int>(typenum_t::INT64)
×
104
                            : static_cast<int>(typenum_t::UINT64));
×
105
            default:
×
106
                throw_unrecognized_typenum_error(typenum);
×
107
            }
×
108
        }
×
NEW
109
        else if (typenum == api.UAR_LONGLONG_ ||
×
NEW
110
                 typenum == api.UAR_ULONGLONG_) {
×
111
            switch (sizeof(long long)) {
×
112
            case sizeof(std::int64_t):
×
113
                return ((typenum == api.UAR_LONGLONG_)
×
114
                            ? static_cast<int>(typenum_t::INT64)
×
115
                            : static_cast<int>(typenum_t::UINT64));
×
116
            default:
×
117
                throw_unrecognized_typenum_error(typenum);
×
118
            }
×
119
        }
×
120
        else {
×
121
            throw_unrecognized_typenum_error(typenum);
×
122
        }
×
123
        // return code signalling error, should never be reached
124
        assert(false);
489,680!
125
        return -1;
×
126
    }
×
127

128
private:
129
    void throw_unrecognized_typenum_error(int typenum) const
130
    {
×
131
        throw std::runtime_error("Unrecognized typenum " +
×
132
                                 std::to_string(typenum) + " encountered.");
×
133
    }
×
134
};
135
} // namespace dpctl::tensor::type_dispatch
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc