archimedes_test/lib/src/test/splat/tensor_test.dart

37 lines
985 B
Dart
Raw Normal View History

import 'package:archimedes_test/src/splat/tensor.dart';
import 'package:collection/collection.dart';
import 'package:test/test.dart';
void main() {
group('stack', () {
test('A random tensor can be generated', () {
Tensor generated = Tensor.random([2, 4]);
expect(generated.length, equals(2));
expect(generated[0].length, equals(4));
});
test("A tensor can be stacked", () {
Tensor x = Tensor(const DelegatingList([
DelegatingList([0.3367, 0.1288, 0.2345]),
DelegatingList([0.2303, -1.1229, -0.1863])
]));
expect(Tensor.stack(x)[0], equals(x));
2024-12-13 09:45:59 -08:00
expect(
Tensor.stack(x),
equals(Tensor.fromList([
[
[
[0.3367, 0.1288, 0.2345],
[0.3367, 0.1288, 0.2345],
],
[
[0.2303, -1.1229, -0.1863],
[0.2303, -1.1229, -0.1863]
]
]
])));
});
});
}