You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: API_CHANGELOG.md
+10-1Lines changed: 10 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,14 @@ This is obsolete. Use getRegion('name') instead.
121
121
| VectorFileEffector | FileOutputRegion |
122
122
| VectorFileSensor | FileInputRegion |
123
123
124
+
* Timing for data move PR# 956
125
+
Originally data is moved from output to input through the links just before executing a region.
126
+
Now, the data is moved just after execution of a region. The effect is that the internal values
127
+
of the Input buffers between iterations was the value just used in the previous execute. It is
128
+
now the input buffer contains the value to be used by the next execution.
129
+
130
+
There should be no effect on applications unless they are looking at the values of the internal
131
+
input buffers.
124
132
125
133
## Python API Changes
126
134
@@ -147,4 +155,5 @@ mostly just a thin wrapper around the C++ library.
147
155
- Classifier::learn(SDR, label)
148
156
The `label` argument can now be an unsigned integer (the label index) or it can be a vector containing a set of label indexes that relate to this pattern.
149
157
This was done because syntax such as `{4}` passed as the label, intended to create a vector with one element, is now being rejected by at least one compiler.
150
-
So, just pass the label index directly if there is only one.
158
+
So, just pass the label index directly if there is only one.
Copy file name to clipboardExpand all lines: docs/NetworkAPI_Links.md
+24-14Lines changed: 24 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,9 @@
3
3
Network API is all about experimenting and building apps from the HTM building blocks (or regions) which are wrappers around the htm algorithms. See [Network API Regions](NetworkAPI_Regions.md). But to be useful, we also need to be able to connect up those building blocks so that data can flow between them. We do that with links.
4
4
5
5
## Data Flow
6
-
A link is a data path with buffers on both ends. The buffer on the source end of the link are assiciated with an output of a region. The buffer on the destination end of the link is associated with an input to a region. On each iteration of a run, each region is executed. As a region is executed, it will first move the data in the buffer on the source side to the buffer on the destination side of any links connected to its inputs. Then it will call the underlining algorithm to generated some output. That output is moved to the output buffer.
6
+
A link is a data path with buffers on both ends. The buffer on the source end of the link are assiciated with an output of a region. The buffer on the destination end of the link is associated with an input to a region.
7
+
8
+
When a region is executed, it will call the underlining algorithm using data from the input buffer to generated some output. That output is moved to the output buffer. After each region is executed its outputs are propogated through all links assigned to that output.
7
9
8
10
Here is an example of a NetworkAPI configuration using JSON syntax:
9
11
```
@@ -14,18 +16,18 @@ Here is an example of a NetworkAPI configuration using JSON syntax:
14
16
{addRegion: {name: "fileOutput", type "FileOutputRegion", params: {outputFile: "result.csv"}
The app, in a loop, would set a value in the parameter "sensedValue" on the encoder then call `run(1)`.
21
23
22
24
As you can see in this diagram, on a single iteration of a run, data will flow through the blocks from one to another.
23
25

24
-
The regions are executed in the order that they are declared in the configuration. Here is basicly what happens:
25
-
- The encoder has no inputs so no data is moved. The encoder is executed and using the current value of the parameter SensedValue, produces data in the "encoded" output of the encoder.
26
-
- The sp region has a link to an input so the encoder's 'encoded' output buffer is moved to the buffer of the 'bottomUpIn' input of the SP as specified in the link. The SP is executed with that input and produces an output in sp.bottomUpOut.
27
-
- The tm region has a link so the buffer in sp.bottomUpOut is moved to tm.bottomUpIn. TM is executed and produces data on several outputs.
28
-
-The FileOutput region has a link so the buffer in tm.bottomUpOut is moved to fileOutput.DataOut. Then the FileOutput region is executed and saves the data into the file.
26
+
The regions are executed in the order that they are declared in the configuration (modified by the phase into which they may be placed). Here is basicly what happens:
27
+
- The encoder has no links connected to its inputs. The encoder is executed and using the current value of the parameter SensedValue, produces data in the "encoded" output of the encoder. That data is then distributed along the output link to connected input buffer named "bottomUpIn" of the sp region.
28
+
- The SP is executed with that input and produces an output in sp.bottomUpOut. The sp region has a link connected to its output so the buffer in sp.bottomUpOut is moved to tm.bottomUpIn.
29
+
-TM is executed and produces data on several outputs but only one has a link. The FileOutput region is connected from TM with a link so the buffer in tm.bottomUpOut is moved to fileOutput.DataOut.
30
+
- Then the FileOutput region is executed and saves the data in its input buffer fileOutput.DataIn, into the file.
29
31
30
32
So the data cascades through the links.
31
33
@@ -39,13 +41,14 @@ The syntax for a Link declaration using JSON format:
39
41
addLink: {src: "<srcName>.<srcOutput>",
40
42
dest: "<destName>.<destInput>",
41
43
dim: [<dimensions>],
44
+
mode: [<"overwrite" or "<fanin>"]
42
45
delay: <propogationDelay>}
43
46
}
44
47
```
45
48
46
49
The syntax for a Link declaration using C++ calls:
- The optional `dim` parameter is only required for the special case of the "INPUT" source discussed later.
58
61
62
+
- The optional `mode` parameter is only needed if there are more than one link connected to the destination buffer. A value of "overwrite" means the outputs from each link will overwrite the entire input buffer. The last output to execute wins. A value of "fanin" means put the outputs from each link into separate portions of the input buffer. See more about the Fan-In condition below. If not given, the mode is "fanin".
63
+
59
64
- The `srcOutput` and `destInput` are the targets of the link on their respecitive regions. For backward compatability, if either is not given or blank (not recomended), they are the ones identified as the default for the region in the Spec.
60
65
61
66
- The optional `delay` argument is propogation delay parameter to set the number of iterations to delay the buffer movements.
@@ -89,15 +94,15 @@ For example, if the source buffer consist of a C-type array of Real32 values and
89
94
## Fan-In
90
95
There may be times when more than one region output should be connected to a single input of a region. To implement, configure a link for each output and indicate the same target input.
91
96
92
-
When this occurs, the data from each source is converted to the type of the destination and then their buffers are concatinated. So, the input buffer size will be the sum of the widths of all of the source buffers.
97
+
If the `overwrite` mode was not specified, the data from each source is converted to the type of the destination and then their buffers are concatinated. So, the input buffer size will be the sum of the widths of all of the source buffers.
93
98
94
99
This is convenent for the construction of an app that employs multiple encoders to encode independent variables. It is the concatination of the encoder outputs that should be presented to the SP to turn this into a true SDR.
95
100
96
101
## Fan-Out
97
-
There may be times that a single source output will be connected to multiple destination inputs. To implement, use one link per input and reference the same source output. The data is moved to a destination input when that destination region is executed.
102
+
There may be times that a single source output will be connected to multiple destination inputs. To implement, use one link per input and reference the same source output. The data is moved to a destination input when that source region is executed.
98
103
99
104
## Propogation Delay
100
-
The link also has the feature of being able to delay the propogation of an output buffer by a number of run iterations. This is configured by setting the link property `propogationDelay` to the number of run iterations to delay. Normally this is 0 and there is no delay. The propogationDelay queue is rotated at the beginning of the run so the source being propogated to the input is the buffer at the top of the queue.
105
+
The link also has the feature of being able to delay the propogation of an output buffer by a number of run iterations. This is configured by setting the link property `propogationDelay` to the number of run iterations to delay. Normally this is 0 and there is no delay. The propogationDelay queue is rotated after an output is generated. The value in the output buffer is placed into the bottom of the queue and the value being propogated to the input is the buffer at the top of the queue.
101
106
102
107
For example. If the propogationDelay is set to 2 then the propogation will be something like this:
103
108
```
@@ -157,12 +162,17 @@ Sometimes we want the app to provide the data that will be in the input buffer o
157
162
158
163
The source_name argument is an identifier of your choice that matches the link which will be used. This allows the app to provide multiple streams of data, each with their own source_name and their own corresponding link.
159
164
160
-
Since the link will not be able to infer the dimensions on this source, this link declaration must include the dimsions of the data that the app will be providing. This dimension will be available for the link to infer the dimensions of the input which is the target of the link.
165
+
Since the link will not be able to infer the dimensions on this source, this link declaration must include the dimensions of the data that the app will be providing. This dimension will be available for the link to infer the dimensions of the input which is the target of the link. For example, use `"{dim: [<dimensions>]}"` as the link parameter.
161
166
162
-
Here is an example that might show up in a JSON configuration for NetworkAPI. Our `<source_name>` field is `source1` in this case and a call to setInputData( ... ) to feed data to this link must use `source1` as the first argument.
167
+
Here is an example that might show up in a JSON configuration for NetworkAPI. Our `<source_name>` field is `source1` in this case and a call to setInputData( ... ) to feed data to this link must use `source1` as the first argument.
0 commit comments