Skip to content

Commit 8be7efc

Browse files
committed
Move definition of _result_typeid to the header to avoid undefined reference issue
1 parent fea1477 commit 8be7efc

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

dpnp/backend/extensions/elementwise_functions/elementwise_functions.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ namespace td_ns = dpctl::tensor::type_dispatch;
6262
using dpctl::tensor::kernels::alignment_utils::is_aligned;
6363
using dpctl::tensor::kernels::alignment_utils::required_alignment;
6464

65+
using type_utils::_result_typeid;
66+
6567
/*! @brief Template implementing Python API for unary elementwise functions */
6668
template <typename output_typesT,
6769
typename contig_dispatchT,
@@ -261,9 +263,7 @@ py::object py_unary_ufunc_result_type(const py::dtype &input_dtype,
261263
throw py::value_error(e.what());
262264
}
263265

264-
using type_utils::_result_typeid;
265266
int dst_typeid = _result_typeid(src_typeid, output_types);
266-
267267
if (dst_typeid < 0) {
268268
auto res = py::none();
269269
return py::cast<py::object>(res);
@@ -511,7 +511,6 @@ std::pair<py::object, py::object>
511511
throw py::value_error(e.what());
512512
}
513513

514-
using type_utils::_result_typeid;
515514
std::pair<int, int> dst_typeids = _result_typeid(src_typeid, output_types);
516515
int dst1_typeid = dst_typeids.first;
517516
int dst2_typeid = dst_typeids.second;

dpnp/backend/extensions/elementwise_functions/elementwise_functions_type_utils.cpp

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
// dpctl tensor headers
3838
#include "utils/type_dispatch.hpp"
3939

40+
namespace dpnp::extensions::py_internal::type_utils
41+
{
4042
namespace py = pybind11;
4143
namespace td_ns = dpctl::tensor::type_dispatch;
4244

43-
namespace dpnp::extensions::py_internal::type_utils
44-
{
4545
py::dtype _dtype_from_typenum(td_ns::typenum_t dst_typenum_t)
4646
{
4747
switch (dst_typenum_t) {
@@ -77,15 +77,4 @@ py::dtype _dtype_from_typenum(td_ns::typenum_t dst_typenum_t)
7777
throw py::value_error("Unrecognized dst_typeid");
7878
}
7979
}
80-
81-
template <typename output_idT>
82-
output_idT _result_typeid(int arg_typeid, const output_idT *fn_output_id)
83-
{
84-
if (arg_typeid < 0 || arg_typeid >= td_ns::num_types) {
85-
throw py::value_error("Input typeid " + std::to_string(arg_typeid) +
86-
" is outside of expected bounds.");
87-
}
88-
89-
return fn_output_id[arg_typeid];
90-
}
9180
} // namespace dpnp::extensions::py_internal::type_utils

dpnp/backend/extensions/elementwise_functions/elementwise_functions_type_utils.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ extern py::dtype _dtype_from_typenum(td_ns::typenum_t);
4747
/*! @brief Lookup typeid of the result from typeid of
4848
* argument and the mapping table */
4949
template <typename output_idT>
50-
extern output_idT _result_typeid(int arg_typeid,
51-
const output_idT *fn_output_id);
50+
output_idT _result_typeid(int arg_typeid, const output_idT *fn_output_id)
51+
{
52+
if (arg_typeid < 0 || arg_typeid >= td_ns::num_types) {
53+
throw py::value_error("Input typeid " + std::to_string(arg_typeid) +
54+
" is outside of expected bounds.");
55+
}
56+
57+
return fn_output_id[arg_typeid];
58+
}
5259
} // namespace dpnp::extensions::py_internal::type_utils

0 commit comments

Comments
 (0)