OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analyzer::MLPredictExpr Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::MLPredictExpr:
+ Collaboration diagram for Analyzer::MLPredictExpr:

Public Member Functions

 MLPredictExpr (const std::shared_ptr< Analyzer::Expr > &model, const std::vector< std::shared_ptr< Analyzer::Expr >> &regressors)
 
const Exprget_model_value () const
 
const std::vector
< std::shared_ptr
< Analyzer::Expr > > & 
get_regressor_values () const
 
std::shared_ptr< Analyzer::Exprdeep_copy () const override
 
void group_predicates (std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
 
void collect_rte_idx (std::set< int > &rte_idx_set) const override
 
void collect_column_var (std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
 
std::shared_ptr< Analyzer::Exprrewrite_with_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_with_child_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_agg_to_var (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
bool operator== (const Expr &rhs) const override
 
std::string toString () const override
 
void find_expr (std::function< bool(const Expr *)> f, std::list< const Expr * > &expr_list) const override
 
- Public Member Functions inherited from Analyzer::Expr
 Expr (SQLTypes t, bool notnull)
 
 Expr (SQLTypes t, int d, bool notnull)
 
 Expr (SQLTypes t, int d, int s, bool notnull)
 
 Expr (const SQLTypeInfo &ti, bool has_agg=false)
 
virtual ~Expr ()
 
std::shared_ptr< Analyzer::Exprget_shared_ptr ()
 
const SQLTypeInfoget_type_info () const
 
void set_type_info (const SQLTypeInfo &ti)
 
bool get_contains_agg () const
 
void set_contains_agg (bool a)
 
virtual std::shared_ptr
< Analyzer::Expr
add_cast (const SQLTypeInfo &new_type_info)
 
virtual void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const
 
virtual std::shared_ptr
< Analyzer::Expr
normalize_simple_predicate (int &rte_idx) const
 
virtual size_t get_num_column_vars (const bool include_agg) const
 
virtual void print () const
 
virtual void add_unique (std::list< const Expr * > &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Private Attributes

std::shared_ptr< Analyzer::Exprmodel_value_
 
std::vector< std::shared_ptr
< Analyzer::Expr > > 
regressor_values_
 

Additional Inherited Members

- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 707 of file Analyzer.h.

Constructor & Destructor Documentation

Analyzer::MLPredictExpr::MLPredictExpr ( const std::shared_ptr< Analyzer::Expr > &  model,
const std::vector< std::shared_ptr< Analyzer::Expr >> &  regressors 
)
inline

Definition at line 709 of file Analyzer.h.

711  : Expr(kDOUBLE, false), model_value_(model), regressor_values_(regressors) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775

Member Function Documentation

void Analyzer::MLPredictExpr::collect_column_var ( std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &  colvar_set,
bool  include_agg 
) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 729 of file Analyzer.h.

References regressor_values_.

732  {
733  for (const auto& regressor_value : regressor_values_) {
734  regressor_value->collect_column_var(colvar_set, include_agg);
735  }
736  }
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775
void Analyzer::MLPredictExpr::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 723 of file Analyzer.h.

References regressor_values_.

723  {
724  for (const auto& regressor_value : regressor_values_) {
725  regressor_value->collect_rte_idx(rte_idx_set);
726  }
727  }
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775
std::shared_ptr< Analyzer::Expr > Analyzer::MLPredictExpr::deep_copy ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 136 of file Analyzer.cpp.

References model_value_, and regressor_values_.

Referenced by DeepCopyVisitor::visitMLPredict().

136  {
137  std::vector<std::shared_ptr<Analyzer::Expr>> regressors_copy;
138  for (auto r : regressor_values_) {
139  regressors_copy.emplace_back(r->deep_copy());
140  }
141  return makeExpr<MLPredictExpr>(model_value_->deep_copy(), regressors_copy);
142 }
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775

+ Here is the caller graph for this function:

void Analyzer::MLPredictExpr::find_expr ( std::function< bool(const Expr *)>  f,
std::list< const Expr * > &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3289 of file Analyzer.cpp.

References Analyzer::Expr::add_unique(), f(), and regressor_values_.

3290  {
3291  if (f(this)) {
3292  add_unique(expr_list);
3293  return;
3294  }
3295  for (auto& r : regressor_values_) {
3296  r->find_expr(f, expr_list);
3297  }
3298 }
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:3248
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775
torch::Tensor f(torch::Tensor x, torch::Tensor W_target, torch::Tensor b_target)

+ Here is the call graph for this function:

const Expr* Analyzer::MLPredictExpr::get_model_value ( ) const
inline

Definition at line 713 of file Analyzer.h.

References model_value_.

Referenced by CodeGenerator::codegen(), operator==(), and ScalarExprVisitor< std::set< shared::TableKey > >::visitMLPredict().

713 { return model_value_.get(); }
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774

+ Here is the caller graph for this function:

const std::vector<std::shared_ptr<Analyzer::Expr> >& Analyzer::MLPredictExpr::get_regressor_values ( ) const
inline

Definition at line 714 of file Analyzer.h.

References regressor_values_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenLinRegPredict(), CodeGenerator::codegenTreeRegPredict(), operator==(), and ScalarExprVisitor< std::set< shared::TableKey > >::visitMLPredict().

714  {
715  return regressor_values_;
716  }
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775

+ Here is the caller graph for this function:

void Analyzer::MLPredictExpr::group_predicates ( std::list< const Expr * > &  scan_predicates,
std::list< const Expr * > &  join_predicates,
std::list< const Expr * > &  const_predicates 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1739 of file Analyzer.cpp.

References regressor_values_.

1741  {
1742  std::set<int> rte_idx_set;
1743  for (const auto& regressor_value : regressor_values_) {
1744  regressor_value->collect_rte_idx(rte_idx_set);
1745  }
1746  if (rte_idx_set.size() > 1) {
1747  join_predicates.push_back(this);
1748  } else if (rte_idx_set.size() == 1) {
1749  scan_predicates.push_back(this);
1750  } else {
1751  const_predicates.push_back(this);
1752  }
1753 }
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775
bool Analyzer::MLPredictExpr::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2413 of file Analyzer.cpp.

References get_model_value(), get_regressor_values(), model_value_, and regressor_values_.

2413  {
2414  if (typeid(rhs) != typeid(MLPredictExpr)) {
2415  return false;
2416  }
2417  const MLPredictExpr& rhs_cl = dynamic_cast<const MLPredictExpr&>(rhs);
2418  if (!(*model_value_ == *rhs_cl.get_model_value())) {
2419  return false;
2420  }
2421  auto rhs_regressor_values = rhs_cl.get_regressor_values();
2422  if (regressor_values_.size() != rhs_regressor_values.size()) {
2423  return false;
2424  }
2425  for (size_t regressor_idx = 0; regressor_idx < regressor_values_.size();
2426  ++regressor_idx) {
2427  if (!(*regressor_values_[regressor_idx] == *rhs_regressor_values[regressor_idx])) {
2428  return false;
2429  }
2430  }
2431  return true;
2432 }
MLPredictExpr(const std::shared_ptr< Analyzer::Expr > &model, const std::vector< std::shared_ptr< Analyzer::Expr >> &regressors)
Definition: Analyzer.h:709
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775

+ Here is the call graph for this function:

std::shared_ptr<Analyzer::Expr> Analyzer::MLPredictExpr::rewrite_agg_to_var ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 758 of file Analyzer.h.

References model_value_, and regressor_values_.

759  {
760  std::vector<std::shared_ptr<Analyzer::Expr>> new_regressor_values;
761  for (auto& r : regressor_values_) {
762  new_regressor_values.push_back(r->deep_copy());
763  }
764  return makeExpr<MLPredictExpr>(model_value_->rewrite_agg_to_var(tlist),
765  new_regressor_values);
766  }
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775
std::shared_ptr<Analyzer::Expr> Analyzer::MLPredictExpr::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 748 of file Analyzer.h.

References model_value_, and regressor_values_.

749  {
750  std::vector<std::shared_ptr<Analyzer::Expr>> new_regressor_values;
751  for (auto& r : regressor_values_) {
752  new_regressor_values.push_back(r->deep_copy());
753  }
754  return makeExpr<MLPredictExpr>(model_value_->rewrite_with_child_targetlist(tlist),
755  new_regressor_values);
756  }
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775
std::shared_ptr<Analyzer::Expr> Analyzer::MLPredictExpr::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 738 of file Analyzer.h.

References model_value_, and regressor_values_.

739  {
740  std::vector<std::shared_ptr<Analyzer::Expr>> new_regressor_values;
741  for (auto& r : regressor_values_) {
742  new_regressor_values.push_back(r->deep_copy());
743  }
744  return makeExpr<MLPredictExpr>(model_value_->rewrite_with_targetlist(tlist),
745  new_regressor_values);
746  }
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775
std::string Analyzer::MLPredictExpr::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 2857 of file Analyzer.cpp.

References model_value_, and regressor_values_.

2857  {
2858  std::stringstream ss;
2859  ss << "ML_PREDICT(Model: ";
2860  ss << model_value_->toString();
2861  ss << " Regressors: ";
2862  for (const auto& regressor_value : regressor_values_) {
2863  ss << regressor_value->toString() << " ";
2864  }
2865  ss << ") ";
2866  return ss.str();
2867 }
std::shared_ptr< Analyzer::Expr > model_value_
Definition: Analyzer.h:774
std::vector< std::shared_ptr< Analyzer::Expr > > regressor_values_
Definition: Analyzer.h:775

Member Data Documentation

std::shared_ptr<Analyzer::Expr> Analyzer::MLPredictExpr::model_value_
private
std::vector<std::shared_ptr<Analyzer::Expr> > Analyzer::MLPredictExpr::regressor_values_
private

The documentation for this class was generated from the following files: