From ec6b258f314a1e4f76f38d7ef29918a9892a93d2 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 12 Mar 2024 00:18:36 +0530 Subject: [PATCH 1/9] TEST: Ported integration_tests/lnn from LPython --- .../lnn/perceptron/perceptron_main.hpp | 123 ++++++++++++++++++ .../lnn/regression/regression_main.hpp | 114 ++++++++++++++++ integration_tests/lnn/utils/utils_main.hpp | 56 ++++++++ 3 files changed, 293 insertions(+) create mode 100644 integration_tests/lnn/perceptron/perceptron_main.hpp create mode 100644 integration_tests/lnn/regression/regression_main.hpp create mode 100644 integration_tests/lnn/utils/utils_main.hpp diff --git a/integration_tests/lnn/perceptron/perceptron_main.hpp b/integration_tests/lnn/perceptron/perceptron_main.hpp new file mode 100644 index 0000000..18b78ac --- /dev/null +++ b/integration_tests/lnn/perceptron/perceptron_main.hpp @@ -0,0 +1,123 @@ +#include +#include + +struct Perceptron { + int32_t no_of_inputs; + std::vector weights; + double learn_rate; + int32_t iterations_limit; + double des_accuracy; + double cur_accuracy; + int32_t epochs_cnt; +}; + +int32_t predict_perceptron(const struct Perceptron& p, const std::vector& input_vector); +int32_t activation_function(double value); +double test_perceptron(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs); + +std::vector get_inp_vec_with_bias(std::vector& a) { + std::vector b = {}; + size_t i; + for( i = 0; i < a.size(); i++ ) { + b.push_back(a[i]); + } + b.push_back(1.0); + return b; +} + +std::vector init_weights(int32_t size) { + std::vector weights = {}; + int32_t i; + for( i = 0; i < size; i++ ) { + weights.push_back(0.0); + } + weights.push_back(0.0); + return weights; +} + +void init_perceptron(struct Perceptron& p, int32_t n, double rate, + int32_t iterations_limit, double des_accuracy) { + if (n < 1 or n > 1000) { + std::cout << "no_of_inputs must be between [1, 1000]" << std::endl; + exit(2); + } + p.no_of_inputs = n; + p.weights = init_weights(n); + p.learn_rate = rate; + p.iterations_limit = iterations_limit; + p.des_accuracy = des_accuracy; + p.cur_accuracy = 0.0; + p.epochs_cnt = 0; +} + +void train_perceptron(struct Perceptron& p, const std::vector& input_vector, int32_t actual_output) { + int32_t predicted_output = predict_perceptron(p, input_vector); + int32_t error = actual_output - predicted_output; + size_t i; + for( i = 0; i < input_vector.size(); i++ ) { + p.weights[i] += p.learn_rate * double(error) * double(input_vector[i]); + } +} + +int32_t predict_perceptron(const struct Perceptron& p, const std::vector& input_vector) { + double weighted_sum = 0.0; + size_t i = 0; + for( i = 0; i < input_vector.size(); i++ ) { + weighted_sum = weighted_sum + p.weights[i] * double(input_vector[i]); + } + return activation_function(weighted_sum); +} + +int32_t activation_function(double value) { + if ( value >= 0.0 ) { + return 1; + } + return -1; +} + +void train_epoch(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs) { + size_t i; + for( i = 0; i < input_vectors.size(); i++ ) { + std::vector input_vector = get_inp_vec_with_bias(input_vectors[i]); + if( predict_perceptron(p, input_vector) != outputs[i] ) { + train_perceptron(p, input_vector, outputs[i]); + } + } +} + +void train_dataset(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs) { + p.cur_accuracy = 0.0; + p.epochs_cnt = 0; + while( p.cur_accuracy < p.des_accuracy and p.epochs_cnt < p.iterations_limit ) { + p.epochs_cnt += 1; + train_epoch(p, input_vectors, outputs); + p.cur_accuracy = test_perceptron(p, input_vectors, outputs); + } +} + +double test_perceptron(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs) { + int32_t correctly_classified_cnt = 0; + size_t i; + for( i = 0; i < input_vectors.size(); i++ ) { + std::vector input_vector = get_inp_vec_with_bias(input_vectors[i]); + if( predict_perceptron(p, input_vector) == outputs[i] ) { + correctly_classified_cnt += 1; + } + } + return (correctly_classified_cnt / input_vectors.size()) * 100.0; +} + +void print_perceptron(struct Perceptron& p) { + std::cout<<"weights = ["; + int32_t i; + for( i = 0; i < p.no_of_inputs; i++ ) { + std::cout< + +struct Perceptron { + int32_t no_of_inputs; + std::vector weights; + double learn_rate; + int32_t iterations_limit; + double err_limit; + double err; + int32_t epochs_cnt; +}; + +double predict_perceptron(struct Perceptron& p, std::vector& input_vector); +double activation_function(double value); +double test_perceptron(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs); + +std::vector get_inp_vec_with_bias(std::vector& a) { + std::vector b = {}; + size_t i; + for( i = 0; i < a.size(); i++ ) { + b.push_back(a[i]); + } + b.push_back(1.0); + return b; +} + +std::vector init_weights(int32_t size) { + std::vector weights = {}; + int32_t i; + for( i = 0; i < size; i++ ) { + weights.push_back(0.0); + } + weights.push_back(0.0); + return weights; +} + +void init_perceptron(struct Perceptron& p, int32_t n, double rate, int32_t iterations_limit, double err_limit) { + p.no_of_inputs = n; + p.weights = init_weights(n); + p.learn_rate = rate; + p.iterations_limit = iterations_limit; + p.err_limit = err_limit; + p.err = 1.0; + p.epochs_cnt = 0; +} + +void train_perceptron(struct Perceptron& p, std::vector& input_vector, double actual_output) { + double predicted_output = predict_perceptron(p, input_vector); + double error = actual_output - predicted_output; + int32_t i; + for( i = 0; i < input_vector.size(); i++ ) { + p.weights[i] += p.learn_rate * error * input_vector[i]; + } +} + +double predict_perceptron(struct Perceptron& p, std::vector& input_vector) { + double weighted_sum = 0.0; + int32_t i = 0; + for( i = 0; i < input_vector.size(); i++ ) { + weighted_sum = weighted_sum + p.weights[i] * input_vector[i]; + } + return activation_function(weighted_sum); +} + +double activation_function(double value) { + return value; +} + +void train_epoch(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs) { + int32_t i; + for( i = 0; i < input_vectors.size(); i++ ) { + std::vector input_vector = get_inp_vec_with_bias(input_vectors[i]); + if ( predict_perceptron(p, input_vector) != outputs[i] ) { + train_perceptron(p, input_vector, outputs[i]); + } + } +} + +void train_dataset(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs) { + double prev_err = 0.0; + p.err = 1.0; + p.epochs_cnt = 0; + while( abs(p.err - prev_err) >= p.err_limit and p.epochs_cnt < p.iterations_limit ) { + p.epochs_cnt += 1; + train_epoch(p, input_vectors, outputs); + prev_err = p.err; + p.err = test_perceptron(p, input_vectors, outputs); + } +} + +double test_perceptron(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs) { + double err = 0.0; + int32_t i; + for( i = 0; i < input_vectors.size(); i++ ) { + std::vector input_vector = get_inp_vec_with_bias(input_vectors[i]); + err = err + pow((outputs[i] - predict_perceptron(p, input_vector)), 2.0); + } + return err; +} + +void print_perceptron(struct Perceptron& p) { + std::cout << "weights = ["; + int32_t i; + for( i = 0; i < p.no_of_inputs; i++ ) { + std::cout << p.weights[i] << ", "; + } + std::cout << p.weights[p.no_of_inputs] << "\n"; + std::cout << "learn_rate = "; + std::cout << p.learn_rate << "\n"; + std::cout << "error = "; + std::cout << p.err << "\n"; + std::cout << "epochs_cnt = "; + std::cout << p.epochs_cnt << "\n"; +} diff --git a/integration_tests/lnn/utils/utils_main.hpp b/integration_tests/lnn/utils/utils_main.hpp new file mode 100644 index 0000000..445598d --- /dev/null +++ b/integration_tests/lnn/utils/utils_main.hpp @@ -0,0 +1,56 @@ +#include + +double normalize(double value, double leftMin, double leftMax, double rightMin, double rightMax) { + // Figure out how 'wide' each range is + double leftSpan = leftMax - leftMin; + double rightSpan = rightMax - rightMin; + + // Convert the left range into a 0-1 range (float) + double valueScaled = (value - leftMin) / leftSpan; + + // Convert the 0-1 range into a value in the right range. + return rightMin + (valueScaled * rightSpan); +} + +void normalize_input_vectors(std::vector>& input_vectors) { + int32_t rows = input_vectors.size(); + int32_t cols = input_vectors[0].size(); + + int32_t j; + for( j = 0; j < cols; j++ ) { + double colMinVal = input_vectors[0][j]; + double colMaxVal = input_vectors[0][j]; + int32_t i; + for( i = 0; i < rows; i++ ) { + if( input_vectors[i][j] > colMaxVal ) { + colMaxVal = input_vectors[i][j]; + } + if( input_vectors[i][j] < colMinVal ) { + colMinVal = input_vectors[i][j]; + } + } + + for( i = 0; i < rows; i++ ) { + input_vectors[i][j] = normalize(input_vectors[i][j], colMinVal, colMaxVal, -1.0, 1.0); + } + } +} + +void normalize_output_vector(std::vector& output_vector) { + int32_t rows = output_vector.size(); + double colMinVal = output_vector[0]; + double colMaxVal = output_vector[0]; + int32_t i; + for( i = 0; i < rows; i++ ) { + if( output_vector[i] > colMaxVal ) { + colMaxVal = output_vector[i]; + } + if( output_vector[i] < colMinVal ) { + colMinVal = output_vector[i]; + } + } + + for( i = 0; i < rows; i++ ) { + output_vector[i] = normalize(output_vector[i], colMinVal, colMaxVal, -1.0, 1.0); + } +} From 1a409ff78e8f9508f96566fe28f552a57acf629a Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 12 Mar 2024 00:19:18 +0530 Subject: [PATCH 2/9] TEST: Ported integration_tests/lpdraw from LPython --- integration_tests/lpdraw/draw.hpp | 127 ++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 integration_tests/lpdraw/draw.hpp diff --git a/integration_tests/lpdraw/draw.hpp b/integration_tests/lpdraw/draw.hpp new file mode 100644 index 0000000..d205f47 --- /dev/null +++ b/integration_tests/lpdraw/draw.hpp @@ -0,0 +1,127 @@ +#include +#include + +void Pixel(int32_t H, int32_t W, xt::xtensor& Screen, int32_t x, int32_t y) { + if( x >= 0 and y >= 0 and x < W and y < H ) { + Screen(H - 1 - y, x) = 255; + } +} + +void Clear(int32_t H, int32_t W, xt::xtensor& Screen) { + int32_t i; + int32_t j; + for( i = 0; i < H; i++ ) { + for( j = 0; j < W; j++ ) { + Screen(i, j) = 0; + } + } +} + +void DisplayTerminal(int32_t H, int32_t W, xt::xtensor& Screen) { + int32_t i, j; + + std::cout<<"+"; + for( i = 0; i < W; i++ ) { + std::cout<<"-"; + } + std::cout<<"+\n"; + + for( i = 0; i < H; i++ ) { + std::cout<<"|"; + for( j = 0; j < W; j++ ) { + if( bool(Screen(i, j)) ) { + std::cout<<"."; + } else { + std::cout<<" "; + } + } + std::cout<<"|"; + } + + std::cout<<"+"; + for( i = 0; i < W; i++ ) { + std::cout<<"-"; + } + std::cout<<"+"; +} + +void Display(int32_t H, int32_t W, xt::xtensor& Screen) { + int32_t i, j; + + std::cout<<"P2"; + std::cout<& Screen, int32_t x1, int32_t y1, int32_t x2, int32_t y2) { + int32_t dx = abs(x2 - x1); + int32_t dy = abs(y2 - y1); + + int32_t sx, sy; + + if( x1 < x2 ) { + sx = 1; + } else { + sx = -1; + } + + if( y1 < y2 ) { + sy = 1; + } else { + sy = -1; + } + + int32_t err = dx - dy; + + while( x1 != x2 or y1 != y2 ) { + Pixel(H, W, Screen, x1, y1); + int32_t e2 = 2 * err; + + if( e2 > -dy ) { + err -= dy; + x1 += sx; + } + + if( x1 == x2 and y1 == y2 ) { + Pixel(H, W, Screen, x1, y1); + break; + } + + if( e2 < dx ) { + err += dx; + y1 += sy; + } + } +} + +void Circle(int32_t H, int32_t W, xt::xtensor& Screen, int32_t x, int32_t y, double r) { + int32_t x0 = r; + int32_t y0 = 0; + int32_t err = 0; + + while( x0 >= y0 ) { + Pixel(H, W, Screen, x + x0, y + y0); + Pixel(H, W, Screen, x - x0, y + y0); + Pixel(H, W, Screen, x + x0, y - y0); + Pixel(H, W, Screen, x - x0, y - y0); + Pixel(H, W, Screen, x + y0, y + x0); + Pixel(H, W, Screen, x - y0, y + x0); + Pixel(H, W, Screen, x + y0, y - x0); + Pixel(H, W, Screen, x - y0, y - x0); + + if( err <= 0 ) { + y0 += 1; + err += 2 * y0 + 1; + } + if( err > 0 ) { + x0 -= 1; + err -= 2 * x0 + 1; + } + } +} From 46de059d8afb72428d1817a6bcc87cf20d6dd811 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 12 Mar 2024 00:19:48 +0530 Subject: [PATCH 3/9] TEST: Ported integration_tests/test_pkg_lnn_01.py from LPython --- integration_tests/test_pkg_lnn_01.cpp | 115 ++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 integration_tests/test_pkg_lnn_01.cpp diff --git a/integration_tests/test_pkg_lnn_01.cpp b/integration_tests/test_pkg_lnn_01.cpp new file mode 100644 index 0000000..883cf81 --- /dev/null +++ b/integration_tests/test_pkg_lnn_01.cpp @@ -0,0 +1,115 @@ +#include "lnn/perceptron/perceptron_main.hpp" +#include "lnn/utils/utils_main.hpp" +#include "lpdraw/draw.hpp" + +#define assert_(cond) if( !(cond) ) { \ + exit(2); \ +} \ + +double compute_decision_boundary(struct Perceptron& p, double x) { + double bias = p.weights[-1]; + double slope = (-p.weights[0] / p.weights[1]); + double intercept = (-bias / p.weights[1]); + return slope * x + intercept; +} + +void plot_graph(struct Perceptron& p, std::vector>& input_vectors, std::vector& outputs) { + const int32_t Width = 500; // x-axis limits [0, 499] + const int32_t Height = 500; // y-axis limits [0, 499] + xt::xtensor Screen = xt::empty({Height, Width}); + Clear(Height, Width, Screen); + + double x1 = 2.0; + double y1 = compute_decision_boundary(p, x1); + double x2 = -2.0; + double y2 = compute_decision_boundary(p, x2); + + // center the graph using the following offset + double scale_offset = Width / 4; + double shift_offset = Width / 2; + x1 *= scale_offset; + y1 *= scale_offset; + x2 *= scale_offset; + y2 *= scale_offset; + + // print (x1, y1, x2, y2) + Line(Height, Width, Screen, int(x1 + shift_offset), int(y1 + shift_offset), int(x2 + shift_offset), int(y2 + shift_offset)); + + int32_t i; + int32_t point_size = 5; + for( i = 0; i < input_vectors.size(); i++ ) { + input_vectors[i][0] *= scale_offset; + input_vectors[i][1] *= scale_offset; + input_vectors[i][0] += shift_offset; + input_vectors[i][1] += shift_offset; + if( outputs[i] == 1 ) { + int32_t x = input_vectors[i][0]; + int32_t y = input_vectors[i][1]; + Line(Height, Width, Screen, x - point_size, y, x + point_size, y); + Line(Height, Width, Screen, x, y - point_size, x, y + point_size); + } else { + Circle(Height, Width, Screen, int32_t(input_vectors[i][0]), int32_t(input_vectors[i][1]), double(point_size)); + } + } + + Display(Height, Width, Screen); +} + +void main0() { + struct Perceptron p; + p.no_of_inputs = 0; + p.weights = {0.0}; + p.learn_rate = 0.0; + p.iterations_limit = 0.0; + p.des_accuracy = 0.0; + p.cur_accuracy = 0.0; + p.epochs_cnt = 0; + + init_perceptron(p, 2, 0.05, 10000, 90.0); + print_perceptron(p); + std::cout<<"=================================\n"; + + std::vector> input_vectors = {{-1.0, -1.0}, {-1.0, 1.0}, {1.0, -1.0}, {1.0, 1.0}}; + std::vector outputs = {1, 1, 1, -1}; + + normalize_input_vectors(input_vectors); + train_dataset(p, input_vectors, outputs); + print_perceptron(p); + + assert_( p.cur_accuracy > 50.0 ); + assert_( p.epochs_cnt > 1 ); + + plot_graph(p, input_vectors, outputs); +} + +void main1() { + struct Perceptron p; + p.no_of_inputs = 0; + p.weights = {0.0}; + p.learn_rate = 0.0; + p.iterations_limit = 0.0; + p.des_accuracy = 0.0; + p.cur_accuracy = 0.0; + p.epochs_cnt = 0; + + init_perceptron(p, 2, 0.05, 10000, 90.0); + print_perceptron(p); + std::cout<<"=================================\n"; + + std::vector> input_vectors = {{-1.0, -1.0}, {-1.0, 1.0}, {1.0, -1.0}, {1.0, 1.0}, {1.5, 1.0}}; + std::vector outputs = {1, 1, -1, 1, -1}; + + normalize_input_vectors(input_vectors); + train_dataset(p, input_vectors, outputs); + print_perceptron(p); + + assert_( p.cur_accuracy > 50.0 ); + assert_( p.epochs_cnt > 1 ); + + plot_graph(p, input_vectors, outputs); +} + +int main() { + main0(); + main1(); +} From bec2026db2709b5ed90a35203941d22b21de1ede Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 12 Mar 2024 00:20:12 +0530 Subject: [PATCH 4/9] DEV: Print function name in error message --- src/libasr/asr_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libasr/asr_utils.h b/src/libasr/asr_utils.h index b5c3b56..742c165 100644 --- a/src/libasr/asr_utils.h +++ b/src/libasr/asr_utils.h @@ -4570,7 +4570,7 @@ static inline void Call_t_body(Allocator& al, ASR::symbol_t* a_name, /*TODO: Remove this if check once intrinsic procedures are implemented correctly*/ LCOMPILERS_ASSERT_MSG( ASRUtils::check_equal_type(arg_type, orig_arg_type), "ASRUtils::check_equal_type(" + ASRUtils::get_type_code(arg_type) + ", " + - ASRUtils::get_type_code(orig_arg_type) + ")"); + ASRUtils::get_type_code(orig_arg_type) + ") in a call to " + ASRUtils::symbol_name(a_name)); } } if( ASRUtils::is_array(arg_type) && ASRUtils::is_array(orig_arg_type) ) { From 71b4927dec1657fddc5c7c1a88043868beea5022 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 12 Mar 2024 00:21:09 +0530 Subject: [PATCH 5/9] DEV: Additional features and bug fixes --- src/lc/clang_ast_to_asr.cpp | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/lc/clang_ast_to_asr.cpp b/src/lc/clang_ast_to_asr.cpp index 4eaf8ce..2ef374f 100644 --- a/src/lc/clang_ast_to_asr.cpp +++ b/src/lc/clang_ast_to_asr.cpp @@ -712,6 +712,10 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor::TraverseImplicitCastExpr(x); return true; @@ -860,8 +864,12 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitorsize() - 1; i >= 0; i-- ) { print_args_vec.push_back(al, print_args->p[i]); } + ASR::expr_t* empty_string = ASRUtils::EXPR( + ASR::make_StringConstant_t(al, Lloc(x), s2c(al, ""), + ASRUtils::TYPE(ASR::make_Character_t(al, Lloc(x), 1, 1, nullptr)) + )); tmp = ASR::make_Print_t(al, Lloc(x), print_args_vec.p, - print_args_vec.size(), nullptr, nullptr); + print_args_vec.size(), empty_string, empty_string); print_args = nullptr; is_stmt_created = true; } @@ -1837,10 +1845,10 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor(*ASRUtils::expr_type(left)) && ASR::is_a(*left)) || (ASR::is_a(*ASRUtils::expr_type(right)) && @@ -2195,7 +2208,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitorbase.loc, 4)); ASR::ttype_t* dest_type_left = dest_type; if( ASRUtils::is_array(left_type) ) { @@ -2447,6 +2460,8 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitorgetOpcode() == clang::BinaryOperatorKind::BO_SubAssign ) { CreateBinOp(x_lhs, x_rhs, ASR::binopType::Sub, Lloc(x)); + } else if( x->getOpcode() == clang::BinaryOperatorKind::BO_MulAssign ) { + CreateBinOp(x_lhs, x_rhs, ASR::binopType::Mul, Lloc(x)); } else { throw std::runtime_error(x->getOpcodeStr().str() + " is not yet supported in CompoundAssignOperator."); } @@ -2563,6 +2578,10 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitorgetCond(); TraverseStmt(if_cond); ASR::expr_t* test = ASRUtils::EXPR(tmp.get()); + if( !ASRUtils::is_logical(*ASRUtils::expr_type(test)) ) { + test = CastingUtil::perform_casting(test, ASRUtils::expr_type(test), + ASRUtils::TYPE(ASR::make_Logical_t(al, Lloc(x), 1)), al, Lloc(x)); + } Vec then_body; then_body.reserve(al, 1); Vec*current_body_copy = current_body; From 076bedb9d9e40b762c6aa6206ba036655b2a46b3 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 12 Mar 2024 00:21:27 +0530 Subject: [PATCH 6/9] DEV: Push back print value if no change happens --- src/libasr/pass/replace_symbolic.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libasr/pass/replace_symbolic.cpp b/src/libasr/pass/replace_symbolic.cpp index 4b856c2..43a828f 100644 --- a/src/libasr/pass/replace_symbolic.cpp +++ b/src/libasr/pass/replace_symbolic.cpp @@ -1501,6 +1501,8 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor(*ASRUtils::expr_type(val))) { ASR::expr_t* function_call = process_attributes(al, x.base.base.loc, val, module_scope); print_tmp.push_back(function_call); + } else { + print_tmp.push_back(x.m_values[i]); } } else if (ASR::is_a(*val)) { ASR::Cast_t* cast_t = ASR::down_cast(val); @@ -1546,6 +1548,8 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor(*val)) { ASR::ListItem_t* list_item = ASR::down_cast(val); @@ -1564,6 +1568,8 @@ class ReplaceSymbolicVisitor : public PassUtils::PassVisitor Date: Tue, 12 Mar 2024 00:22:27 +0530 Subject: [PATCH 7/9] TEST: Register test_pkg_lnn_01.cpp --- integration_tests/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration_tests/CMakeLists.txt b/integration_tests/CMakeLists.txt index 7dcca26..d1c3d73 100644 --- a/integration_tests/CMakeLists.txt +++ b/integration_tests/CMakeLists.txt @@ -237,3 +237,5 @@ RUN(NAME vector_01.cpp LABELS gcc llvm NOFAST) RUN(NAME vector_02.cpp LABELS gcc llvm NOFAST) RUN(NAME loop_01.cpp LABELS gcc llvm NOFAST) + +RUN(NAME test_pkg_lnn_01.cpp LABELS gcc llvm NOFAST) From 8428d489bef68a0769ee975d201d6022b5fa3370 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Tue, 12 Mar 2024 14:35:33 +0530 Subject: [PATCH 8/9] DEV: Fix result type of ComplexCompare node --- src/lc/clang_ast_to_asr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lc/clang_ast_to_asr.cpp b/src/lc/clang_ast_to_asr.cpp index 2ef374f..8db3f2e 100644 --- a/src/lc/clang_ast_to_asr.cpp +++ b/src/lc/clang_ast_to_asr.cpp @@ -1835,7 +1835,7 @@ class ClangASTtoASRVisitor: public clang::RecursiveASTVisitor Date: Tue, 12 Mar 2024 14:36:20 +0530 Subject: [PATCH 9/9] TEST: Updated reference tests --- tests/reference/asr-array_04-f95b8eb.json | 2 +- tests/reference/asr-array_04-f95b8eb.stdout | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/reference/asr-array_04-f95b8eb.json b/tests/reference/asr-array_04-f95b8eb.json index 26bc93d..49a148b 100644 --- a/tests/reference/asr-array_04-f95b8eb.json +++ b/tests/reference/asr-array_04-f95b8eb.json @@ -6,7 +6,7 @@ "outfile": null, "outfile_hash": null, "stdout": "asr-array_04-f95b8eb.stdout", - "stdout_hash": "527842cbdfdfac8d3cf494d61c760428aa51ec431fcf2b3e5d2827cd", + "stdout_hash": "ecd1c3d056e6792b7c6ec0baa0730c74d60745d34d459ffb6122aee1", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/asr-array_04-f95b8eb.stdout b/tests/reference/asr-array_04-f95b8eb.stdout index 904fee3..e69a5b7 100644 --- a/tests/reference/asr-array_04-f95b8eb.stdout +++ b/tests/reference/asr-array_04-f95b8eb.stdout @@ -307,13 +307,25 @@ (Print [(Var 2 arr1) (Var 2 arr2)] - () - () + (StringConstant + "" + (Character 1 1 ()) + ) + (StringConstant + "" + (Character 1 1 ()) + ) ) (Print [(Var 2 res)] - () - () + (StringConstant + "" + (Character 1 1 ()) + ) + (StringConstant + "" + (Character 1 1 ()) + ) ) (= (Var 2 __return_var)