Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit 530e4e2

Browse files
committed
passing py::object by reference
1 parent 5ca13fe commit 530e4e2

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

src/EWBinOp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ namespace x {
113113
};
114114
} // namespace x
115115

116-
tensor_i::ptr_type EWBinOp::op(EWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object b)
116+
tensor_i::ptr_type EWBinOp::op(EWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object & b)
117117
{
118118
auto bb = x::mk_tx(b);
119119
return TypeDispatch<x::EWBinOp>(a, bb, op);

src/IEWBinOp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ namespace x {
6262
};
6363
} // namespace x
6464

65-
void IEWBinOp::op(IEWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object b)
65+
void IEWBinOp::op(IEWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object & b)
6666
{
6767
auto bb = x::mk_tx(b);
6868
TypeDispatch<x::IEWBinOp>(a, bb, op);

src/include/ddptensor/Operations.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ struct Creator
1515

1616
struct IEWBinOp
1717
{
18-
static void op(IEWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object b);
18+
static void op(IEWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object & b);
1919
};
2020

2121
struct EWBinOp
2222
{
23-
static tensor_i::ptr_type op(EWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object b);
23+
static tensor_i::ptr_type op(EWBinOpId op, x::DPTensorBaseX::ptr_type a, py::object & b);
2424
};
2525

2626
struct EWUnyOp

src/include/ddptensor/x.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ namespace x
271271

272272
static DPTensorBaseX::ptr_type mk_tx(py::object & b)
273273
{
274-
if(py::isinstance<x::DPTensorBaseX::ptr_type>(b)) {
275-
return b.cast<x::DPTensorBaseX::ptr_type>();
274+
if(py::isinstance<DPTensorBaseX>(b)) {
275+
return b.cast<DPTensorBaseX::ptr_type>();
276276
} else if(py::isinstance<py::float_>(b)) {
277-
return x::operatorx<double>::mk_tx(b);
277+
return operatorx<double>::mk_tx(b);
278278
} else if(py::isinstance<py::int_>(b)) {
279-
return x::operatorx<int64_t>::mk_tx(b);
279+
return operatorx<int64_t>::mk_tx(b);
280280
}
281281
throw std::runtime_error("Invalid right operand to elementwise binary operation");
282282
};

0 commit comments

Comments
 (0)