Commit 727dcd94 authored by Thomas Purcell's avatar Thomas Purcell
Browse files

Add tests for MPI-op

Since MPI is not being used in the runners
parent d7b01807
......@@ -1061,11 +1061,11 @@ void FeatureSpace::sis(std::shared_ptr<LossFunction> loss)
// Generate features on the fly and get the best features for this rank
if(_n_rung_generate > 0)
{
#ifdef PARAMETERIZE
#ifdef PARAMETERIZE
_phi.resize(_n_feat);
_phi.insert(_phi.end(), _phi_reparam.begin() + _start_rung_reparam.back(), _phi_reparam.end());
_scores.resize(_phi.size());
#endif
#endif
start_time = omp_get_wtime();
phi_sel.resize(cur_feat_local);
scores_sel.resize(cur_feat_local);
......
......@@ -12,22 +12,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "gtest/gtest.h"
#include <utils/compare_features.hpp>
#include <feature_creation/node/ModelNode.hpp>
#include "feature_creation/node/ModelNode.hpp"
#include "mpi_interface/MPI_Ops.hpp"
#include "utils/compare_features.hpp"
namespace {
//test mean calculations
TEST(CompFeats, CompFeatTest)
{
std::vector<double> val_1 = {1.0, 2.0, 3.0, 4.0};
std::vector<double> val_2 = {2.0, 2.0, 3.0, 4.0};
std::vector<double> val_2 = {2.0, 1.0, 3.0, 4.0};
std::vector<double> val_3 = {2.0, 4.0, 6.0, 8.0};
std::vector<double> target = {1.0, 3.0, 5.0, 6.0};
std::vector<double> scores = {0.9897782665572893};
std::vector<node_ptr> selected(1);
std::vector<node_sc_pair> mpi_op_sel(1);
node_value_arrs::initialize_values_arr({4}, {0}, 1, 0, false);
selected[0] = std::make_shared<FeatureNode>(0, "A", val_3, std::vector<double>(), Unit());
mpi_op_sel[0] = mpi_reduce_op::make_node_sc_pair(selected[0], scores[0]);
node_value_arrs::initialize_d_matrix_arr();
node_value_arrs::resize_d_matrix_arr(1);
......@@ -36,13 +40,36 @@ namespace {
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_pearson_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_max_corr_1_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_pearson_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_max_corr_1(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman(val_1.data(), 4, 1.0, scores, 0.9897782665572893, 1, 0));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_feat_list(val_1.data(), 4, 1.0, selected, scores, 0.9897782665572893));
EXPECT_FALSE(comp_feats::valid_feature_against_selected_spearman_mpi_op(val_1.data(), 4, 1.0, mpi_op_sel, 0.9897782665572893));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_max_corr_1(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_max_corr_1_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman(val_2.data(), 4, 1.0, scores, 0.9028289727756884, 1, 0));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_feat_list(val_2.data(), 4, 1.0, selected, scores, 0.9028289727756884));
EXPECT_TRUE(comp_feats::valid_feature_against_selected_spearman_mpi_op(val_2.data(), 4, 1.0, mpi_op_sel, 0.9028289727756884));
node_value_arrs::finalize_values_arr();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment