Skip to content

Commit

Permalink
Added docs folder
Browse files Browse the repository at this point in the history
  • Loading branch information
Iainmon committed Aug 6, 2024
1 parent 5417d0d commit eda8fcf
Show file tree
Hide file tree
Showing 72 changed files with 13,289 additions and 97 deletions.
25 changes: 14 additions & 11 deletions ModuleSpec.chpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,46 @@ import Time;


// Construct the model from specification.
var m: owned Module(real) = modelFromSpecFile("scripts/models/cnn/specification.json");
var model: owned Module(real) = modelFromSpecFile("scripts/models/cnn/specification.json");

// Print the model's structure.
writeln(m.signature);
writeln(model.signature);

// Load the weights into the model.
m.loadPyTorchDump("scripts/models/cnn/");
model.loadPyTorchDump("scripts/models/cnn/");

// Load an array of images.
config const imageCount = 1;
var images = forall i in 0..<imageCount do Tensor.load("data/datasets/mnist/image_idx_" + i:string + ".chdata");
config const numImages = 1;
var images = forall i in 0..<numImages do Tensor.load("data/datasets/mnist/image_idx_" + i:string + ".chdata");

// Create array of output results.
var preds: [images.domain] int;
var preds: [0..<numImages] int;



config const numTimes = 1;
var time: real;
for i in 0..<numTimes {
var st = new Time.stopwatch();

st.start();
forall (img,pred) in zip(images, preds) {
var output: Tensor(real) = m(img);
pred = output.argmax();
pred = model(img).argmax();
}
const tm = st.elapsed();
st.stop();

const tm = st.elapsed();
writeln("Time: ", tm, " seconds.");
time = tm;
time += tm;
}

time /= numTimes;

config const printResults = false;
if printResults {
for i in images.domain {
writeln((i, preds[i]));
}
}

writeln("The last inference batch took ", time, " ms.");
writeln("The average inference time for batch of size ", numImages, " was ", time, " seconds.");
4 changes: 4 additions & 0 deletions docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 88f41822c6ec599496c47c238ba72239
tags: 645f666f9bcd5a90fca523b33c5a78b7
23 changes: 23 additions & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
chpldoc documentation
=====================

Contents:

.. toctree::
:hidden:

self

.. toctree::
:maxdepth: 1
:glob:

modules/**


Indices and tables
==================

* :ref:`genindex`
* :chpl:chplref:`chplmodindex`
* :ref:`search`
Loading

0 comments on commit eda8fcf

Please sign in to comment.