-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up SimpleDomain quite a bit.
- Loading branch information
Showing
103 changed files
with
10,172 additions
and
1,715 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
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,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) | ||
|
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,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)?)) | ||
|
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,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
43
docs/_sources/modules/examples/MultiLocaleInference.rst.txt
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,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 | ||
|
Oops, something went wrong.