Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
benchmark/vector/float32/vector_operations/float32x4_vector_exp.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Approx. 20 seconds (MacBook Air mid 2017) | ||
|
||
import 'package:benchmark_harness/benchmark_harness.dart'; | ||
import 'package:ml_linalg/dtype.dart'; | ||
import 'package:ml_linalg/vector.dart'; | ||
|
||
const amountOfElements = 10000000; | ||
|
||
class Float32x4VectorExpBenchmark extends BenchmarkBase { | ||
Float32x4VectorExpBenchmark() | ||
: super('Vector `exp` method; $amountOfElements elements'); | ||
|
||
Vector vector; | ||
|
||
static void main() { | ||
Float32x4VectorExpBenchmark().report(); | ||
} | ||
|
||
@override | ||
void run() { | ||
vector.exp(); | ||
} | ||
|
||
@override | ||
void setup() { | ||
vector = Vector.randomFilled(amountOfElements, | ||
seed: 1, | ||
min: -1000, | ||
max: 1000, | ||
dtype: DType.float32, | ||
); | ||
} | ||
} | ||
|
||
void main() { | ||
Float32x4VectorExpBenchmark.main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:ml_linalg/dtype.dart'; | ||
|
||
import 'exp_test_group_factory.dart'; | ||
|
||
void main() { | ||
matrixExpTestGroupFactory(DType.float32); | ||
matrixExpTestGroupFactory(DType.float64); | ||
} |
26 changes: 26 additions & 0 deletions
26
test/integration_test/matrix/methods/exp/exp_test_group_factory.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import 'dart:math' as math; | ||
import 'package:ml_linalg/dtype.dart'; | ||
import 'package:ml_linalg/linalg.dart'; | ||
import 'package:ml_tech/unit_testing/matchers/iterable_2d_almost_equal_to.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../../../dtype_to_title.dart'; | ||
|
||
void matrixExpTestGroupFactory(DType dtype) => | ||
group(dtypeToMatrixTestTitle[dtype], () { | ||
group('exp method', () { | ||
test('should raise euler\'s numbers to elements of matrix', () { | ||
final matrix = Matrix.fromList([ | ||
[1, 2, 3, 4], | ||
[5, 6, 7, 8], | ||
], dtype: dtype); | ||
final result = matrix.exp(); | ||
|
||
expect(result, iterable2dAlmostEqualTo([ | ||
[math.exp(1), math.exp(2), math.exp(3), math.exp(4)], | ||
[math.exp(5), math.exp(6), math.exp(7), math.exp(8)], | ||
], 1e-3)); | ||
expect(result.dtype, dtype); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import 'package:ml_linalg/dtype.dart'; | ||
|
||
import 'exp_test_group_factory.dart'; | ||
|
||
void main() { | ||
vectorExpTestGroupFactory(DType.float32); | ||
vectorExpTestGroupFactory(DType.float64); | ||
} |
20 changes: 20 additions & 0 deletions
20
test/integration_test/vector/methods/exp/exp_test_group_factory.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import 'package:ml_linalg/dtype.dart'; | ||
import 'package:ml_linalg/vector.dart'; | ||
import 'package:ml_tech/unit_testing/matchers/iterable_almost_equal_to.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import '../../../../dtype_to_title.dart'; | ||
|
||
void vectorExpTestGroupFactory(DType dtype) => | ||
group(dtypeToVectorTestTitle[dtype], () { | ||
group('exp method', () { | ||
test('should raise euler\'s numbers to elements of vector', () { | ||
final vector = Vector.fromList([1.0, 2.0, 3.0, 4.0, 5.0], | ||
dtype: dtype); | ||
final result = vector.exp(); | ||
|
||
expect(result, iterableAlmostEqualTo([ | ||
2.7182, 7.3890, 20.08553, 54.5981, 148.4131], 1e-3)); | ||
}); | ||
}); | ||
}); |