Skip to content

Commit

Permalink
Fix Hessian/Functors test
Browse files Browse the repository at this point in the history
  • Loading branch information
MihailMihov committed Mar 19, 2024
1 parent 048a5f7 commit 562488d
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions test/Hessian/Functors.C
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// RUN: %cladclang -Xclang -plugin-arg-clad -Xclang -enable-tbr %s -I%S/../../include -oFunctors.out
// RUN: ./Functors.out | FileCheck -check-prefix=CHECK-EXEC %s
// CHECK-NOT: {{.*error|warning|note:.*}}
// XFAIL: target={{i586.*}}

#include "clad/Differentiator/Differentiator.h"

Expand All @@ -19,9 +18,9 @@ struct Experiment {

// CHECK: void operator_call_hessian(double i, double j, clad::array_ref<double> hessianMatrix) {
// CHECK-NEXT: Experiment _d_this;
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: Experiment _d_this0;
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }
};

Expand All @@ -37,9 +36,9 @@ struct ExperimentConst {

// CHECK: void operator_call_hessian(double i, double j, clad::array_ref<double> hessianMatrix) const {
// CHECK-NEXT: ExperimentConst _d_this;
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: ExperimentConst _d_this0;
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }
};

Expand All @@ -55,9 +54,9 @@ struct ExperimentVolatile {

// CHECK: void operator_call_hessian(double i, double j, clad::array_ref<double> hessianMatrix) volatile {
// CHECK-NEXT: volatile ExperimentVolatile _d_this;
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: volatile ExperimentVolatile _d_this0;
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }
};

Expand All @@ -73,9 +72,9 @@ struct ExperimentConstVolatile {

// CHECK: void operator_call_hessian(double i, double j, clad::array_ref<double> hessianMatrix) const volatile {
// CHECK-NEXT: volatile ExperimentConstVolatile _d_this;
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: volatile ExperimentConstVolatile _d_this0;
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }
};

Expand All @@ -93,9 +92,9 @@ namespace outer {

// CHECK: void operator_call_hessian(double i, double j, clad::array_ref<double> hessianMatrix) {
// CHECK-NEXT: outer::inner::ExperimentNNS _d_this;
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, &_d_this, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: outer::inner::ExperimentNNS _d_this0;
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, &_d_this0, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }
};

Expand All @@ -104,8 +103,8 @@ namespace outer {
};

// CHECK: inline void operator_call_hessian(double i, double j, clad::array_ref<double> hessianMatrix) const {
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }
}
}
Expand Down Expand Up @@ -141,17 +140,17 @@ int main() {
};

// CHECK: inline void operator_call_hessian(double i, double j, clad::array_ref<double> hessianMatrix) const {
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, j, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: this->operator_call_darg1_grad(i, j, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }

auto lambdaWithCapture = [&](double i, double jj) {
return x*i*i*jj + y*i*jj*jj;
};

// CHECK: inline void operator_call_hessian(double i, double jj, clad::array_ref<double> hessianMatrix) const {
// CHECK-NEXT: this->operator_call_darg0_grad(i, jj, hessianMatrix.slice(0UL, 1UL), hessianMatrix.slice(1UL, 1UL));
// CHECK-NEXT: this->operator_call_darg1_grad(i, jj, hessianMatrix.slice(2UL, 1UL), hessianMatrix.slice(3UL, 1UL));
// CHECK-NEXT: this->operator_call_darg0_grad(i, jj, hessianMatrix.slice({{0U|0UL}}, {{1U|1UL}}), hessianMatrix.slice({{1U|1UL}}, {{1U|1UL}}));
// CHECK-NEXT: this->operator_call_darg1_grad(i, jj, hessianMatrix.slice({{2U|2UL}}, {{1U|1UL}}), hessianMatrix.slice({{3U|3UL}}, {{1U|1UL}}));
// CHECK-NEXT: }

auto lambdaNNS = outer::inner::lambdaNNS;
Expand Down Expand Up @@ -195,4 +194,4 @@ int main() {
TEST(E_NNS); // CHECK-EXEC: {108.00, 174.00, 174.00, 70.00}, {108.00, 174.00, 174.00, 70.00}
TEST(E_NNS_Again); // CHECK-EXEC: {108.00, 174.00, 174.00, 70.00}, {108.00, 174.00, 174.00, 70.00}
TEST(lambdaWithCapture); // CHECK-EXEC: {108.00, 174.00, 174.00, 70.00}, {108.00, 174.00, 174.00, 70.00}
}
}

0 comments on commit 562488d

Please sign in to comment.