Code quality: renamed math_expression -> expression_tree

This commit is contained in:
Philippe Tillet
2015-12-19 02:55:24 -05:00
parent 5a035b91a2
commit d9eb51d04a
37 changed files with 557 additions and 565 deletions

View File

@@ -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)

View File

@@ -62,7 +62,7 @@ namespace detail
std::shared_ptr<sc::driver::Context> make_context(sc::driver::Device const & dev)
{ return std::shared_ptr<sc::driver::Context>(new sc::driver::Context(dev)); }
bp::object enqueue(sc::math_expression const & expression, unsigned int queue_id, bp::list dependencies, bool tune, int label, std::string const & program_name, bool force_recompile)
bp::object enqueue(sc::expression_tree const & expression, unsigned int queue_id, bp::list dependencies, bool tune, int label, std::string const & program_name, bool force_recompile)
{
std::list<sc::driver::Event> events;
std::vector<sc::driver::Event> cdependencies = tools::to_vector<sc::driver::Event>(dependencies);
@@ -70,7 +70,7 @@ namespace detail
sc::execution_options_type execution_options(queue_id, &events, &cdependencies);
sc::dispatcher_options_type dispatcher_options(tune, label);
sc::compilation_options_type compilation_options(program_name, force_recompile);
sc::math_expression::container_type::value_type root = expression.tree()[expression.root()];
sc::expression_tree::container_type::value_type root = expression.tree()[expression.root()];
if(sc::detail::is_assignment(root.op))
{
sc::execute(sc::execution_handler(expression, execution_options, dispatcher_options, compilation_options), isaac::profiles::get(execution_options.queue(expression.context())));

View File

@@ -13,7 +13,7 @@ namespace tpt = isaac::templates;
namespace detail
{
bp::list input_sizes(tpt::base & temp, sc::math_expression const & tree)
bp::list input_sizes(tpt::base & temp, sc::expression_tree const & tree)
{
std::vector<isaac::int_t> tmp = temp.input_sizes(tree);
return tools::to_list(tmp.begin(), tmp.end());