-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Matrix: 'fromList' and 'fromFlattenedList' speed up (#180)
- Loading branch information
Showing
8 changed files
with
72 additions
and
16 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
2 changes: 1 addition & 1 deletion
2
benchmark/matrix/float32/matrix_initializing/float32_matrix_from_flattened.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
40 changes: 40 additions & 0 deletions
40
benchmark/matrix/float32/matrix_initializing/float32_matrix_from_flattened_float32.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,40 @@ | ||
// Approx. 86 microsecond (MacBook Pro mid 2019), Dart VM version: 3.2.4 | ||
|
||
import 'dart:typed_data'; | ||
|
||
import 'package:benchmark_harness/benchmark_harness.dart'; | ||
import 'package:ml_linalg/dtype.dart'; | ||
import 'package:ml_linalg/matrix.dart'; | ||
import 'package:ml_linalg/vector.dart'; | ||
|
||
const numOfRows = 10000; | ||
const numOfColumns = 1000; | ||
|
||
class Float32MatrixFromFlattenedFloat32ListBenchmark extends BenchmarkBase { | ||
Float32MatrixFromFlattenedFloat32ListBenchmark() | ||
: super( | ||
'Matrix initialization (fromFlattenedList, source list is Float32List)'); | ||
|
||
late Float32List _source; | ||
|
||
static void main() { | ||
Float32MatrixFromFlattenedFloat32ListBenchmark().report(); | ||
} | ||
|
||
@override | ||
void run() { | ||
Matrix.fromFlattenedList(_source, numOfRows, numOfColumns, | ||
dtype: DType.float32); | ||
} | ||
|
||
@override | ||
void setup() { | ||
_source = Float32List.fromList(Vector.randomFilled(numOfRows * numOfColumns, | ||
min: -1000, max: 1000, seed: 12) | ||
.toList(growable: false)); | ||
} | ||
} | ||
|
||
void main() { | ||
Float32MatrixFromFlattenedFloat32ListBenchmark.main(); | ||
} |
2 changes: 1 addition & 1 deletion
2
benchmark/matrix/float32/matrix_initializing/float32_matrix_from_list.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
2 changes: 1 addition & 1 deletion
2
benchmark/matrix/float32/matrix_initializing/float32_matrix_from_rows.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
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