Skip to content

Commit 766952f

Browse files
committed
Fix comments
1 parent 34d5fca commit 766952f

3 files changed

Lines changed: 3 additions & 22 deletions

File tree

demos/tinystories/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ chai_add_executable(TinyStoriesTestConv2d
1111
chai_add_executable(OliverHowTo
1212
${CMAKE_CURRENT_SOURCE_DIR}/oh2.chpl
1313
${PROJECT_ROOT_DIR}/lib
14-
)
14+
)
Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,22 @@
1-
// testArgmaxDecode.chpl
2-
use ChAI; // Likely needed for core types or general setup
3-
use NDArray; // Where your ndarray type and argmaxDecode method are defined
1+
use ChAI;
2+
use NDArray;
43

54
proc main() {
6-
// 1. Create a Chapel array with some values
7-
// Use real(32) to match typical float precision in LibTorch/ChAI
85
var chapArray: [0..2] real(32) = [1.0, 7.0, 3.0]; // Expected argmax index: 1
96

10-
// 2. Construct an ndarray from the Chapel array.
11-
// This will use your existing `proc init(const Arr: [])` in NDArray.chpl
127
var myNdArray = new ndarray(chapArray);
138

14-
// 3. Call the argmaxDecode method on the ndarray instance
15-
// The `this._tensorHandle` will be created/accessed via `toBridgeTensor`
16-
// or the implicit cast `operator :` before calling Bridge.argmaxdecode.
179
var argmaxIndex = myNdArray.argmaxDecode();
1810

19-
// 4. Print the result
2011
writeln("Chapel array: ", chapArray);
2112
writeln("Argmax index: ", argmaxIndex); // Should print 1 for the example above
2213

23-
// Test with another example
2414
var chapArray2: [0..3] real(32) = [10.0, 5.0, 20.0, 15.0]; // Expected argmax index: 2
2515
var myNdArray2 = new ndarray(chapArray2);
2616
var argmaxIndex2 = myNdArray2.argmaxDecode();
2717
writeln("Chapel array 2: ", chapArray2);
2818
writeln("Argmax index 2: ", argmaxIndex2); // Should print 2
2919

30-
// You can keep the accelerator checks for good measure
3120
if Bridge.acceleratorAvailable() then
3221
writeln("Accelerator (CUDA/MPS) is available!");
3322
else
@@ -38,8 +27,4 @@ proc main() {
3827
Bridge.debugCpuOnlyMode(false);
3928
writeln("Debug CPU only mode is OFF. Accelerator available: ", Bridge.acceleratorAvailable());
4029

41-
// IMPORTANT: Ensure tensors are freed!
42-
// If `myNdArray`'s deinit() correctly calls Bridge.freeBridgeTensorHandle,
43-
// then memory will be managed. If not, you might need explicit calls or a
44-
// more robust memory management strategy.
4530
}

demos/tinystories/testConv2d.chpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use ChAI;
22
use NDArray;
33

44
proc main() {
5-
// Construct input tensor: shape (1, 1, 5, 5) for batch=1, channels=1, height=5, width=5
65
var inputData: [0..0, 0..0, 0..4, 0..4] real =
76
[[[ [1.0, 2.0, 3.0, 4.0, 5.0],
87
[6.0, 7.0, 8.0, 9.0, 10.0],
@@ -12,19 +11,16 @@ proc main() {
1211

1312
var input = new ndarray(real, inputData.domain, inputData);
1413

15-
// Kernel tensor: shape (1, 1, 3, 3)
1614
var kernelData: [0..0, 0..0, 0..2, 0..2] real =
1715
[[[ [1.0, 0.0, -1.0],
1816
[1.0, 0.0, -1.0],
1917
[1.0, 0.0, -1.0] ]]];
2018

2119
var kernel = new ndarray(real, kernelData.domain, kernelData);
2220

23-
// Bias tensor: shape (1)
2421
var biasData: [0..0] real = [0.0];
2522
var bias = new ndarray(real, biasData.domain, biasData);
2623

27-
// Call conv2d with stride=1, padding=1 (same padding)
2824
var output = input.conv2d(kernel, bias, 1:int(32), 1:int(32));
2925

3026
writeln("Output shape: ", output.domain);

0 commit comments

Comments
 (0)