Skip to content

Commit

Permalink
Cleaned up SimpleDomain quite a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
Iainmon committed Aug 26, 2024
1 parent 7fbda3c commit d3f116e
Show file tree
Hide file tree
Showing 103 changed files with 10,172 additions and 1,715 deletions.
File renamed without changes.
File renamed without changes.
25 changes: 25 additions & 0 deletions docs/_sources/modules/examples/ConvLayerTest.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. default-domain:: chpl

.. module:: ConvLayerTest

ConvLayerTest
=============
**Usage**

.. code-block:: chapel
use ConvLayerTest;
or

.. code-block:: chapel
import ConvLayerTest;
.. data:: var t: Tensor(real) = Tensor.arange(1, 8, 8)

.. data:: var conv = new Conv2D(1, 1, 3, 1)

.. data:: var output = conv(t)

71 changes: 71 additions & 0 deletions docs/_sources/modules/examples/MNISTNet.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.. default-domain:: chpl

.. module:: MNISTNet

MNISTNet
========
**Usage**

.. code-block:: chapel
use MNISTNet;
or

.. code-block:: chapel
import MNISTNet;
.. data:: config param layerDebug = false

.. type:: type dtype = real(32)

.. class:: CNN : Module(?)

.. attribute:: var conv1: owned(Conv2D(eltType))

.. attribute:: var conv2: owned(Conv2D(eltType))

.. attribute:: var dropout1: owned(Dropout(eltType))

.. attribute:: var dropout2: owned(Dropout(eltType))

.. attribute:: var flatten: owned(Flatten(eltType))

.. attribute:: var fc1: owned(Linear(eltType))

.. attribute:: var fc2: owned(Linear(eltType))

.. method:: proc init(type eltType = dtype)

.. method:: override proc forward( input: Tensor(eltType)) : Tensor(eltType)

.. data:: config const diag = false

.. data:: var cnn = new CNN(dtype)

.. data:: var model = Network.loadModel(specFile = "scripts/models/cnn/specification.json", weightsFolder = "scripts/models/cnn/", dtype = dtype)

.. data:: config const testImgSize = 28

.. data:: var img = Tensor.load("data/datasets/mnist/image_idx_0_7_7.chdata")

.. data:: const modelPath = "data/models/mnist_cnn/"

.. data:: config const imageCount = 0

.. data:: var images = forall i in 0..<imageCount do Tensor.load("data/datasets/mnist/image_idx_" + i : string + ".chdata") : dtype

.. data:: var preds: [images.domain] int

.. data:: config const numTimes = 1

.. data:: var conv1 = new Conv2D(real, channels = 1, features = 32, kernel = 3, stride = 1)

.. data:: var conv2 = new Conv2D(real, channels = 32, features = 64, kernel = 3, stride = 1)

.. data:: config const printResults = false

.. data:: var cnn2 = new Sequential(real, (new Conv2D(real, channels = 1, features = 32, kernel = 3, stride = 1)?, new Conv2D(real, channels = 32, features = 64, kernel = 3, stride = 1)?, new Dropout(real, 0.25)?, new Dropout(real, 0.5)?, new Flatten(real)?, new Linear(real, 9216, 128)?, new Linear(real, 128, 10)?))

35 changes: 35 additions & 0 deletions docs/_sources/modules/examples/ModuleSpec.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.. default-domain:: chpl

.. module:: ModuleSpec

ModuleSpec
==========
**Usage**

.. code-block:: chapel
use ModuleSpec;
or

.. code-block:: chapel
import ModuleSpec;
.. data:: config const detach = true

.. data:: var model: owned(Module(real)) = modelFromSpecFile("scripts/models/cnn/specification.json")

.. data:: config const numImages = 1

.. data:: var images = forall i in 0..<numImages do Tensor.load("data/datasets/mnist/image_idx_" + i : string + ".chdata")

.. data:: var preds: [0..<numImages] int

.. data:: config const numTimes = 1

.. data:: var time: real

.. data:: config const printResults = false

43 changes: 43 additions & 0 deletions docs/_sources/modules/examples/MultiLocaleInference.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
.. default-domain:: chpl

.. module:: MultiLocaleInference

MultiLocaleInference
====================
**Usage**

.. code-block:: chapel
use MultiLocaleInference;
or

.. code-block:: chapel
import MultiLocaleInference;
.. data:: config const detach = true

.. type:: type dtype = real(32)

.. data:: config const numImages = 1

.. data:: const imagesD = blockDist.createDomain({0..<numImages})

.. data:: var images = forall i in imagesD do Tensor.load("data/datasets/mnist/image_idx_" + i : string + ".chdata") : dtype

.. data:: const localeModelsD = blockDist.createDomain(Locales.domain)

.. data:: var localeModels = forall li in localeModelsD do loadModel(specFile = "scripts/models/cnn/specification.json", weightsFolder = "scripts/models/cnn/", dtype = dtype)

.. data:: var preds: [imagesD] int

.. data:: config const numTries = 1

.. data:: var totalTime: real

.. data:: const averageTime = totalTime / numTries

.. data:: config const printResults = false

Loading

0 comments on commit d3f116e

Please sign in to comment.