aboutsummaryrefslogtreecommitdiff
path: root/chapters/introduction.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'chapters/introduction.adoc')
-rw-r--r--chapters/introduction.adoc27
1 files changed, 14 insertions, 13 deletions
diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc
index acf3b69..93276f1 100644
--- a/chapters/introduction.adoc
+++ b/chapters/introduction.adoc
@@ -249,14 +249,17 @@ The tensor shape in each dimension must be greater than or equal to 1.
The following pseudocode represents the operations that will happen to data elements as they are read in to be processed, or have their results written out.
*Functionality of tensor read*
-If in_t is 8-bit then out_t=int16_t. Otherwise out_t is set to the same as in_t.
-If padding is specified, the size of the padding array should be 2 times the size of the shape.
-The padding array represents the before and after pair for each dimension.
+
+tensor_read reads a single data value out of the given tensor.
+The shape argument contains the shape of the tensor.
+Index is the coordinates within the tensor of the value to be read.
+zero_point is the zero point value to be added for int8 values.
+If in_t is 8-bit then out_t=int16_t to account for the zero_point subtraction.
+Otherwise out_t is the same as in_t.
[source,c++]
----
-out_t tensor_read<in_t>(in_t *address, dim_t shape, dim_t index, in_t zero_point=0, dim_t pad=NULL) {
- ERROR_IF((pad != NULL) && size(pad) != 2 * size(shape));
+out_t tensor_read<in_t>(in_t *address, dim_t shape, dim_t index, in_t zero_point=0) {
ERROR_IF(in_t != int8_t && zero_point != 0);
// Ensure this is a proper tensor with each dimension having size >= 1
for_each(dimension_size in shape) {
@@ -264,14 +267,7 @@ out_t tensor_read<in_t>(in_t *address, dim_t shape, dim_t index, in_t zero_point
}
unsigned offset = 0;
for (i = 0; i < rank(shape); i++) {
- if (index[i] < 0) {
- REQUIRE(pad && pad[2 * i] + index[i] >= 0);
- return 0;
- }
- if (index[i] >= shape[i]) {
- REQUIRE(pad && index[i] < shape[i] + pad[2 * i + 1]);
- return 0;
- }
+ REQUIRE(index[i] >= 0 && index[i] < shape[i]);
offset = offset * shape[i] + index[i];
}
return address[offset] - zero_point;
@@ -280,6 +276,11 @@ out_t tensor_read<in_t>(in_t *address, dim_t shape, dim_t index, in_t zero_point
*Functionality of tensor write*
+tensor_write writes a single data value into the given tensor.
+The shape argument contains the shape of the tensor.
+Index is the coordinates within the tensor of the value to be written.
+value is the value to be written to the given coordinate.
+
[source,c++]
----
tensor_write<type>(<type> *address, dim_t shape, dim_t index, <type> value) {