Skip to content

Commit

Permalink
Reuse logical operations from dpctl.tensor (#1464)
Browse files Browse the repository at this point in the history
* Reuse logical operations from dpctl.tensor

* Apply the comment

* Removed unused backend code
  • Loading branch information
antonwolfy authored Jul 9, 2023
1 parent fd9ce2b commit f294dfd
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 488 deletions.
58 changes: 2 additions & 56 deletions dpnp/backend/include/dpnp_gen_1arg_1type_tbl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,60 +104,6 @@ MACRO_1ARG_1TYPE_OP(dpnp_square_c,

#undef MACRO_1ARG_1TYPE_OP

#elif defined(MACRO_1ARG_1TYPE_LOGIC_OP)

/*
* This header file contains single argument element wise functions definitions
*
* Macro `MACRO_1ARG_1TYPE_LOGIC_OP` must be defined before usage
*
* Parameters:
* - public name of the function and kernel name
* - operation used to calculate the result
*
*/

#ifdef _SECTION_DOCUMENTATION_GENERATION_

#define MACRO_1ARG_1TYPE_LOGIC_OP(__name__, __operation__) \
/** @ingroup BACKEND_API */ \
/** @brief Per element operation function __name__ */ \
/** */ \
/** Function "__name__" executes operator "__operation__" over \
* corresponding elements of input array */ \
/** */ \
/** @param[in] q_ref Reference to SYCL queue. */ \
/** @param[out] result_out Output array. */ \
/** @param[in] result_size Output array size. */ \
/** @param[in] result_ndim Number of output array \
* dimensions. */ \
/** @param[in] result_shape Output array shape. */ \
/** @param[in] result_strides Output array strides. */ \
/** @param[in] input1_in Input array 1. */ \
/** @param[in] input1_size Input array 1 size. */ \
/** @param[in] input1_ndim Number of input array 1 \
* dimensions. */ \
/** @param[in] input1_shape Input array 1 shape. */ \
/** @param[in] input1_strides Input array 1 strides. */ \
/** @param[in] where Where condition. */ \
/** @param[in] dep_event_vec_ref Reference to vector of SYCL \
* events. */ \
template <typename _DataType_input1> \
DPCTLSyclEventRef __name__( \
DPCTLSyclQueueRef q_ref, void *result_out, const size_t result_size, \
const size_t result_ndim, const shape_elem_type *result_shape, \
const shape_elem_type *result_strides, const void *input1_in, \
const size_t input1_size, const size_t input1_ndim, \
const shape_elem_type *input1_shape, \
const shape_elem_type *input1_strides, const size_t *where, \
const DPCTLEventVectorRef dep_event_vec_ref);

#endif // _SECTION_DOCUMENTATION_GENERATION_

MACRO_1ARG_1TYPE_LOGIC_OP(dpnp_logical_not_c, !input1_elem)

#undef MACRO_1ARG_1TYPE_LOGIC_OP

#else
#error "MACRO_1ARG_1TYPE_OP or MACRO_1ARG_1TYPE_LOGIC_OP is not defined"
#endif // MACRO_1ARG_1TYPE_OP || MACRO_1ARG_1TYPE_LOGIC_OP
#error "MACRO_1ARG_1TYPE_OP is not defined"
#endif // MACRO_1ARG_1TYPE_OP
4 changes: 0 additions & 4 deletions dpnp/backend/include/dpnp_gen_2arg_2type_tbl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_greater_c, input1_elem > input2_elem)
MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_greater_equal_c, input1_elem >= input2_elem)
MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_less_c, input1_elem < input2_elem)
MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_less_equal_c, input1_elem <= input2_elem)
MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_logical_and_c, input1_elem &&input2_elem)
MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_logical_or_c, input1_elem || input2_elem)
MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_logical_xor_c,
(!!input1_elem) != (!!input2_elem))
MACRO_2ARG_2TYPES_LOGIC_OP(dpnp_not_equal_c, input1_elem != input2_elem)

#undef MACRO_2ARG_2TYPES_LOGIC_OP
10 changes: 1 addition & 9 deletions dpnp/backend/include/dpnp_iface_fptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,7 @@ enum class DPNPFuncName : size_t
DPNP_FN_LOG1P, /**< Used in numpy.log1p() impl */
DPNP_FN_LOG1P_EXT, /**< Used in numpy.log1p() impl, requires extra
parameters */
DPNP_FN_LOGICAL_AND_EXT, /**< Used in numpy.logical_and() impl, requires
extra parameters */
DPNP_FN_LOGICAL_NOT_EXT, /**< Used in numpy.logical_not() impl, requires
extra parameters */
DPNP_FN_LOGICAL_OR_EXT, /**< Used in numpy.logical_or() impl, requires extra
parameters */
DPNP_FN_LOGICAL_XOR_EXT, /**< Used in numpy.logical_xor() impl, requires
extra parameters */
DPNP_FN_MATMUL, /**< Used in numpy.matmul() impl */
DPNP_FN_MATMUL, /**< Used in numpy.matmul() impl */
DPNP_FN_MATMUL_EXT, /**< Used in numpy.matmul() impl, requires extra
parameters */
DPNP_FN_MATRIX_RANK, /**< Used in numpy.linalg.matrix_rank() impl */
Expand Down
Loading

0 comments on commit f294dfd

Please sign in to comment.