Code quality: renamed math_expression -> expression_tree
This commit is contained in:
@@ -252,15 +252,15 @@ void export_core()
|
||||
#undef INSTANTIATE
|
||||
|
||||
bp::enum_<sc::expression_type>("operations")
|
||||
MAP_ENUM(AXPY_TYPE, sc)
|
||||
MAP_ENUM(GER_TYPE, sc)
|
||||
MAP_ENUM(DOT_TYPE, sc)
|
||||
MAP_ENUM(GEMV_N_TYPE, sc)
|
||||
MAP_ENUM(GEMV_T_TYPE, sc)
|
||||
MAP_ENUM(GEMM_NN_TYPE, sc)
|
||||
MAP_ENUM(GEMM_TN_TYPE, sc)
|
||||
MAP_ENUM(GEMM_NT_TYPE, sc)
|
||||
MAP_ENUM(GEMM_TT_TYPE, sc);
|
||||
MAP_ENUM(ELEMENTWISE_1D, sc)
|
||||
MAP_ENUM(ELEMENTWISE_2D, sc)
|
||||
MAP_ENUM(REDUCE_1D, sc)
|
||||
MAP_ENUM(REDUCE_2D_ROWS, sc)
|
||||
MAP_ENUM(REDUCE_2D_COLS, sc)
|
||||
MAP_ENUM(MATRIX_PRODUCT_NN, sc)
|
||||
MAP_ENUM(MATRIX_PRODUCT_TN, sc)
|
||||
MAP_ENUM(MATRIX_PRODUCT_NT, sc)
|
||||
MAP_ENUM(MATRIX_PRODUCT_TT, sc);
|
||||
|
||||
#define ADD_SCALAR_HANDLING(OP)\
|
||||
.def(bp::self OP int())\
|
||||
@@ -276,7 +276,7 @@ void export_core()
|
||||
.def(bp::self OP bp::self)\
|
||||
ADD_SCALAR_HANDLING(OP)
|
||||
|
||||
bp::class_<sc::math_expression >("math_expression", bp::no_init)
|
||||
bp::class_<sc::expression_tree >("expression_tree", bp::no_init)
|
||||
ADD_ARRAY_OPERATOR(+)
|
||||
ADD_ARRAY_OPERATOR(-)
|
||||
ADD_ARRAY_OPERATOR(*)
|
||||
@@ -287,7 +287,7 @@ void export_core()
|
||||
ADD_ARRAY_OPERATOR(<=)
|
||||
ADD_ARRAY_OPERATOR(==)
|
||||
ADD_ARRAY_OPERATOR(!=)
|
||||
.add_property("context", bp::make_function(&sc::math_expression::context, bp::return_internal_reference<>()))
|
||||
.add_property("context", bp::make_function(&sc::expression_tree::context, bp::return_internal_reference<>()))
|
||||
.def(bp::self_ns::abs(bp::self))
|
||||
// .def(bp::self_ns::pow(bp::self))
|
||||
;
|
||||
@@ -295,8 +295,8 @@ void export_core()
|
||||
|
||||
#define ADD_ARRAY_OPERATOR(OP) \
|
||||
.def(bp::self OP bp::self)\
|
||||
.def(bp::self OP bp::other<sc::math_expression>())\
|
||||
.def(bp::other<sc::math_expression>() OP bp::self) \
|
||||
.def(bp::self OP bp::other<sc::expression_tree>())\
|
||||
.def(bp::other<sc::expression_tree>() OP bp::self) \
|
||||
ADD_SCALAR_HANDLING(OP)
|
||||
|
||||
bp::class_<sc::array_base, boost::noncopyable>("array_base", bp::no_init)
|
||||
@@ -322,7 +322,7 @@ void export_core()
|
||||
bp::class_<sc::array,std::shared_ptr<sc::array>, bp::bases<sc::array_base> >
|
||||
( "array", bp::no_init)
|
||||
.def("__init__", bp::make_constructor(detail::create_array, bp::default_call_policies(), (bp::arg("obj"), bp::arg("dtype") = bp::scope().attr("float32"), bp::arg("context")= bp::object())))
|
||||
.def(bp::init<sc::math_expression>())
|
||||
.def(bp::init<sc::expression_tree>())
|
||||
;
|
||||
|
||||
bp::class_<sc::view, bp::bases<sc::array_base> >
|
||||
@@ -338,15 +338,15 @@ void export_core()
|
||||
bp::def("empty", &detail::create_empty_array, (bp::arg("shape"), bp::arg("dtype") = bp::scope().attr("float32"), bp::arg("context")=bp::object()));
|
||||
|
||||
//Assign
|
||||
bp::def("assign", static_cast<sc::math_expression (*)(sc::array_base const &, sc::array_base const &)>(&sc::assign));\
|
||||
bp::def("assign", static_cast<sc::math_expression (*)(sc::array_base const &, sc::math_expression const &)>(&sc::assign));\
|
||||
bp::def("assign", static_cast<sc::expression_tree (*)(sc::array_base const &, sc::array_base const &)>(&sc::assign));\
|
||||
bp::def("assign", static_cast<sc::expression_tree (*)(sc::array_base const &, sc::expression_tree const &)>(&sc::assign));\
|
||||
|
||||
//Binary
|
||||
#define MAP_FUNCTION(name) \
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::array_base const &, sc::array_base const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &, sc::array_base const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::array_base const &, sc::math_expression const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &, sc::math_expression const &)>(&sc::name));
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::array_base const &, sc::array_base const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::expression_tree const &, sc::array_base const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::array_base const &, sc::expression_tree const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::expression_tree const &, sc::expression_tree const &)>(&sc::name));
|
||||
|
||||
MAP_FUNCTION(maximum)
|
||||
MAP_FUNCTION(minimum)
|
||||
@@ -356,8 +356,8 @@ void export_core()
|
||||
|
||||
//Unary
|
||||
#define MAP_FUNCTION(name) \
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::array_base const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &)>(&sc::name));
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::array_base const &)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::expression_tree const &)>(&sc::name));
|
||||
|
||||
bp::def("zeros", &detail::create_zeros_array, (bp::arg("shape"), bp::arg("dtype") = bp::scope().attr("float32"), bp::arg("context")=bp::object()));
|
||||
|
||||
@@ -382,8 +382,8 @@ void export_core()
|
||||
/*--- Reduction operators----*/
|
||||
//---------------------------------------
|
||||
#define MAP_FUNCTION(name) \
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::array_base const &, sc::int_t)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::math_expression (*)(sc::math_expression const &, sc::int_t)>(&sc::name));
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::array_base const &, sc::int_t)>(&sc::name));\
|
||||
bp::def(#name, static_cast<sc::expression_tree (*)(sc::expression_tree const &, sc::int_t)>(&sc::name));
|
||||
|
||||
MAP_FUNCTION(sum)
|
||||
MAP_FUNCTION(max)
|
||||
|
Reference in New Issue
Block a user