Skip to content

Commit 22b04e4

Browse files
Changed use of "static inline" for utility functions
Instead, moved common functions into anonymous namespace as inline, which is C++ way of expressing that multiple definitions of the same function may exist in different C++ translation units, which linker unifies.
1 parent 69f54be commit 22b04e4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

dpctl/tensor/libtensor/source/elementwise_functions/elementwise_functions.hpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,16 @@
3939
namespace py = pybind11;
4040
namespace td_ns = dpctl::tensor::type_dispatch;
4141

42-
static inline py::dtype _dtype_from_typenum(td_ns::typenum_t dst_typenum_t)
42+
namespace dpctl
43+
{
44+
namespace tensor
45+
{
46+
namespace py_internal
47+
{
48+
49+
namespace
50+
{
51+
inline py::dtype _dtype_from_typenum(td_ns::typenum_t dst_typenum_t)
4352
{
4453
switch (dst_typenum_t) {
4554
case td_ns::typenum_t::BOOL:
@@ -75,7 +84,7 @@ static inline py::dtype _dtype_from_typenum(td_ns::typenum_t dst_typenum_t)
7584
}
7685
}
7786

78-
static inline int _result_typeid(int arg_typeid, const int *fn_output_id)
87+
inline int _result_typeid(int arg_typeid, const int *fn_output_id)
7988
{
8089
if (arg_typeid < 0 || arg_typeid >= td_ns::num_types) {
8190
throw py::value_error("Input typeid " + std::to_string(arg_typeid) +
@@ -85,12 +94,7 @@ static inline int _result_typeid(int arg_typeid, const int *fn_output_id)
8594
return fn_output_id[arg_typeid];
8695
}
8796

88-
namespace dpctl
89-
{
90-
namespace tensor
91-
{
92-
namespace py_internal
93-
{
97+
} // end of anonymous namespace
9498

9599
template <typename output_typesT,
96100
typename contig_dispatchT,

0 commit comments

Comments
 (0)