Skip to content

Commit f6f7fd0

Browse files
committed
Working on better optimizations. Improving PR and code.
1 parent b30c24f commit f6f7fd0

7 files changed

+943
-447
lines changed

src/ApproximationTables.cpp

Lines changed: 467 additions & 200 deletions
Large diffs are not rendered by default.

src/ApproximationTables.h

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,26 @@ namespace Halide {
99
namespace Internal {
1010

1111
struct Approximation {
12-
ApproximationPrecision::OptimizationObjective objective;
1312
struct Metrics {
1413
double mse;
1514
double mae;
1615
double mulpe;
17-
} metrics_f32, metrics_f64;
18-
std::vector<double> coefficients;
16+
} metrics_f16, metrics_f32, metrics_f64;
17+
18+
std::vector<double> p; // Polynomial in the numerator
19+
std::vector<double> q = {}; // Polynomial in the denominator (empty if not a Padé approximant)
20+
21+
const Metrics &metrics_for(Type type) const {
22+
if (type == Float(16)) {
23+
return metrics_f16;
24+
} else if (type == Float(32)) {
25+
return metrics_f32;
26+
} else if (type == Float(64)) {
27+
return metrics_f64;
28+
}
29+
internal_error << "No correct type found.";
30+
return metrics_f32;
31+
}
1932
};
2033

2134
const Approximation *best_atan_approximation(Halide::ApproximationPrecision precision, Type type);
@@ -24,7 +37,6 @@ const Approximation *best_cos_approximation(Halide::ApproximationPrecision preci
2437
const Approximation *best_tan_approximation(Halide::ApproximationPrecision precision, Type type);
2538
const Approximation *best_log_approximation(Halide::ApproximationPrecision precision, Type type);
2639
const Approximation *best_exp_approximation(Halide::ApproximationPrecision precision, Type type);
27-
const Approximation *best_expm1_approximation(Halide::ApproximationPrecision precision, Type type);
2840

2941
} // namespace Internal
3042
} // namespace Halide

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ target_sources(
5757
AlignLoads.h
5858
AllocationBoundsInference.h
5959
ApplySplit.h
60+
ApproximationTables.h
6061
Argument.h
6162
AssociativeOpsTable.h
6263
Associativity.h

0 commit comments

Comments
 (0)