Skip to content

Commit b1196b7

Browse files
committed
prod converter
1 parent 932466d commit b1196b7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cvxpy/reductions/solvers/nlp_solvers/diff_engine/converters.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,16 @@ def _convert_special_index(expr, children):
263263

264264
return _diffengine.make_index(children[0], d1, d2, idxs)
265265

266+
def _convert_prod(expr, children):
267+
axis = expr.axis
268+
if axis is None:
269+
return _diffengine.make_prod(children[0])
270+
elif axis == 0:
271+
return _diffengine.make_prod_axis_zero(children[0])
272+
elif axis == 1:
273+
raise NotImplementedError("Prod along axis=1 not yet supported")
274+
#return _diffengine.make_prod_axis_one(children[0])
275+
266276
# Mapping from CVXPY atom names to C diff engine functions
267277
# Converters receive (expr, children) where expr is the CVXPY expression
268278
ATOM_CONVERTERS = {
@@ -304,7 +314,7 @@ def _convert_special_index(expr, children):
304314
"reshape": _convert_reshape,
305315
"broadcast_to": _convert_broadcast,
306316
# Reductions returning scalar
307-
"Prod": lambda _expr, children: _diffengine.make_prod(children[0]),
317+
"Prod": _convert_prod,
308318
}
309319

310320

0 commit comments

Comments
 (0)