MCPcopy Create free account
hub / github.com/numpy/numpy / try_binary_elide

Function try_binary_elide

numpy/core/src/multiarray/temp_elide.c:339–364  ·  view source on GitHub ↗

* try eliding a binary op, if commutative is true also try swapped arguments */

Source from the content-addressed store, hash-verified

337 * try eliding a binary op, if commutative is true also try swapped arguments
338 */
339NPY_NO_EXPORT int
340try_binary_elide(PyObject * m1, PyObject * m2,
341 PyObject * (inplace_op)(PyArrayObject * m1, PyObject * m2),
342 PyObject ** res, int commutative)
343{
344 /* set when no elision can be done independent of argument order */
345 int cannot = 0;
346 if (can_elide_temp(m1, m2, &cannot)) {
347 *res = inplace_op((PyArrayObject *)m1, m2);
348#if NPY_ELIDE_DEBUG != 0
349 puts("elided temporary in binary op");
350#endif
351 return 1;
352 }
353 else if (commutative && !cannot) {
354 if (can_elide_temp(m2, m1, &cannot)) {
355 *res = inplace_op((PyArrayObject *)m2, m1);
356#if NPY_ELIDE_DEBUG != 0
357 puts("elided temporary in commutative binary op");
358#endif
359 return 1;
360 }
361 }
362 *res = NULL;
363 return 0;
364}
365
366/* try elide unary temporary */
367NPY_NO_EXPORT int

Callers 10

array_addFunction · 0.85
array_subtractFunction · 0.85
array_multiplyFunction · 0.85
array_left_shiftFunction · 0.85
array_right_shiftFunction · 0.85
array_bitwise_andFunction · 0.85
array_bitwise_orFunction · 0.85
array_bitwise_xorFunction · 0.85
array_floor_divideFunction · 0.85
array_true_divideFunction · 0.85

Calls 1

can_elide_tempFunction · 0.85

Tested by

no test coverage detected