aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominic Symes <dominic.symes@arm.com>2022-10-07 15:03:01 +0100
committerEric Kunze <eric.kunze@arm.com>2022-10-19 15:18:09 +0000
commit0205d99cbff58797bf6602ee5718d50c00d8309b (patch)
treef0dac55564e41bdb0a38a7c335a41c5dcf8b43ce
parent2ceeaa24618c3499636182cc9a89265e0d70717f (diff)
downloadspecification-0205d99cbff58797bf6602ee5718d50c00d8309b.tar.gz
Define the index type for tensor co-ordinates
Tensor co-ordinate indices are signed 32-bit values in this version of the specification. Signed-off-by: Dominic Symes <dominic.symes@arm.com> Change-Id: I6b8dde500ef9c4c4c5688c1a43f8d658863e4a49
-rw-r--r--chapters/comparison.adoc12
-rw-r--r--chapters/data_layout.adoc12
-rw-r--r--chapters/ewise_binary.adoc64
-rw-r--r--chapters/ewise_ternary.adoc6
-rw-r--r--chapters/introduction.adoc11
-rw-r--r--chapters/pseudocode.adoc25
-rw-r--r--chapters/reduction.adoc12
-rw-r--r--chapters/tensor_ops.adoc52
8 files changed, 99 insertions, 95 deletions
diff --git a/chapters/comparison.adoc b/chapters/comparison.adoc
index 9bc28ad..00ecdd9 100644
--- a/chapters/comparison.adoc
+++ b/chapters/comparison.adoc
@@ -20,8 +20,8 @@ include::{generated}/operators/EQUAL.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_t value1 = tensor_read<in_t>(input1, shape1, index1);
in_t value2 = tensor_read<in_t>(input2, shape2, index2);
out_t result;
@@ -44,8 +44,8 @@ include::{generated}/operators/GREATER.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_t value1 = tensor_read<in_t>(input1, shape1, index1);
in_t value2 = tensor_read<in_t>(input2, shape2, index2);
out_t result;
@@ -68,8 +68,8 @@ include::{generated}/operators/GREATER_EQUAL.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_t value1 = tensor_read<in_t>(input1, shape1, index1);
in_t value2 = tensor_read<in_t>(input2, shape2, index2);
out_t result;
diff --git a/chapters/data_layout.adoc b/chapters/data_layout.adoc
index 65a426b..530c2e9 100644
--- a/chapters/data_layout.adoc
+++ b/chapters/data_layout.adoc
@@ -29,7 +29,7 @@ for_each(input_shape in shapes1) {
}
}
for_each(index1 in shape) {
- index2 = index1;
+ dim_t index2 = index1;
for (tensor t = 0; t < length(input1); t++) {
// Continue to concatenate along axis from each tensor
// For each output location, we are looking for the
@@ -63,7 +63,7 @@ for (i = 0; i < rank(shape); i++) {
ERROR_IF(shape[i] != padding[i, 0] + shape1[i] + padding[i, 1]);
}
for_each(index in shape) {
- index1 = index;
+ dim_t index1 = index;
bool_t is_pad = false;
for(i = 0; i < rank(shape); i++) {
index1[i] = index1[i] - padding[i,0];
@@ -112,7 +112,7 @@ include::{generated}/operators/REVERSE.adoc[]
----
ERROR_IF(axis < 0 || axis >= rank(shape));
for_each(index in shape) {
- tmp_index = index;
+ dim_t tmp_index = index;
tmp_index[axis] = shape[axis] - 1 - index[axis];
in_out_t value = tensor_read<in_out_t>(input, shape, tmp_index);
tensor_write<in_out_t>(output, shape, index, value);
@@ -142,7 +142,7 @@ for_each(index in rank(input1)) {
}
for_each(index in shape) {
- tmp_index = index;
+ dim_t tmp_index = index;
for(i = 0; i < rank(shape); i++) {
tmp_index[i] = index[i] + start[i];
}
@@ -162,7 +162,7 @@ include::{generated}/operators/TILE.adoc[]
[source,c++]
----
for_each(index in shape) {
- tmp_index = index;
+ dim_t tmp_index = index;
for(i = 0; i < rank(shape); i++) {
ERROR_IF(shape1[i] * multiples[i] != shape[i]);
tmp_index[i] = index[i] % shape1[i];
@@ -199,7 +199,7 @@ for(i = 0; i < rank(shape); i++) {
}
for_each(index in shape) {
- tmp_index = index;
+ dim_t tmp_index = index;
for(i = 0; i < rank(shape); i++) {
tmp_index[perms[i]] = index[i]
}
diff --git a/chapters/ewise_binary.adoc b/chapters/ewise_binary.adoc
index dcd44b4..bf16469 100644
--- a/chapters/ewise_binary.adoc
+++ b/chapters/ewise_binary.adoc
@@ -21,8 +21,8 @@ include::{generated}/operators/ADD.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = apply_add<in_out_t>(value1, value2);
@@ -42,8 +42,8 @@ include::{generated}/operators/ARITHMETIC_RIGHT_SHIFT.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
@@ -73,8 +73,8 @@ include::{generated}/operators/BITWISE_AND.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = value1 & value2;
@@ -94,8 +94,8 @@ include::{generated}/operators/BITWISE_OR.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = value1 | value2;
@@ -115,8 +115,8 @@ include::{generated}/operators/BITWISE_XOR.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = value1 ^ value2;
@@ -139,8 +139,8 @@ include::{generated}/operators/INTDIV.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
REQUIRE(value2 != 0);
@@ -164,8 +164,8 @@ include::{generated}/operators/LOGICAL_AND.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = value1 && value2;
@@ -185,8 +185,8 @@ include::{generated}/operators/LOGICAL_LEFT_SHIFT.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
REQUIRE(0 <= value2 && value2 <= 31);
@@ -207,8 +207,8 @@ include::{generated}/operators/LOGICAL_RIGHT_SHIFT.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
REQUIRE(0 <= value2 && value2 <= 31);
@@ -229,8 +229,8 @@ include::{generated}/operators/LOGICAL_OR.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = value1 || value2;
@@ -250,8 +250,8 @@ include::{generated}/operators/LOGICAL_XOR.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = value1 != value2;
@@ -271,8 +271,8 @@ include::{generated}/operators/MAXIMUM.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = apply_max(value1, value2);
@@ -292,8 +292,8 @@ include::{generated}/operators/MINIMUM.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = apply_min(value1, value2);
@@ -314,8 +314,8 @@ include::{generated}/operators/MUL.adoc[]
----
ERROR_IF(in_t != int32_t && shift > 0);
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_t value1 = tensor_read<in_t>(input1, shape1, index1);
in_t value2 = tensor_read<in_t>(input2, shape2, index2);
out_t result;
@@ -344,8 +344,8 @@ include::{generated}/operators/POW.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = apply_pow<in_out_t>(value1, value2);
@@ -365,8 +365,8 @@ include::{generated}/operators/SUB.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
in_out_t value1 = tensor_read<in_out_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t result = apply_sub<in_out_t>(value1, value2);
diff --git a/chapters/ewise_ternary.adoc b/chapters/ewise_ternary.adoc
index 5cd1409..0391ea6 100644
--- a/chapters/ewise_ternary.adoc
+++ b/chapters/ewise_ternary.adoc
@@ -20,9 +20,9 @@ include::{generated}/operators/SELECT.adoc[]
[source,c++]
----
for_each(index in shape) {
- index1 = apply_broadcast(shape, shape1, index);
- index2 = apply_broadcast(shape, shape2, index);
- index3 = apply_broadcast(shape, shape3, index);
+ dim_t index1 = apply_broadcast(shape, shape1, index);
+ dim_t index2 = apply_broadcast(shape, shape2, index);
+ dim_t index3 = apply_broadcast(shape, shape3, index);
cmp_t value1 = tensor_read<cmp_t>(input1, shape1, index1);
in_out_t value2 = tensor_read<in_out_t>(input2, shape2, index2);
in_out_t value3 = tensor_read<in_out_t>(input3, shape3, index3);
diff --git a/chapters/introduction.adoc b/chapters/introduction.adoc
index be475d4..848359b 100644
--- a/chapters/introduction.adoc
+++ b/chapters/introduction.adoc
@@ -190,13 +190,16 @@ Each element in the tensor shape describes the number of elements in the dimensi
The tensor shape in each dimension must be greater than or equal to 1.
For tensor access information, see <<Tensor Access Helpers>>.
Tensor dimensions are given in the pseudocode as type dim_t.
-dim_t is a vector of int32_t values, with the length of the vector defining the rank of the tensor.
+dim_t is a vector of index_t values, with the length of the vector defining the rank of the tensor.
Tensor elements are addressed using dim_t values, where each element of the vector indicates the offset of the requested element within the corresponding dimension.
==== Tensor size limit
-Tensor size is limited by the data type size_t. In this version of the specification, size_t is defined as (1<<32) - 1, and can be represented with an unsigned 32-bit integer.
-
+The tensor overall size in elements is limited by the data type size_t.
+In this version of the specification, size_t is defined as an unsigned 32-bit integer representing size from 1 to (1<<32) - 1.
+A tensor dimension co-ordinate is limited by the data type index_t.
+In this version of the specification, index_t is defined as a signed 32-bit integer.
+Indices used to access tensors must be non-negative.
==== Data Layouts
@@ -349,7 +352,7 @@ The values to achieve a scaling of 1.0 are shift=30, multiplier=1<<30 for apply_
[source,c++]
----
-int32_t apply_scale_32(int32_t value, int32_t multipler, uint6_t shift, bool_t double_round=false) {
+int32_t apply_scale_32(int32_t value, int32_t multiplier, uint6_t shift, bool_t double_round=false) {
REQUIRE(multiplier >= 0);
REQUIRE(2 <= shift && shift <= 62);
REQUIRE(value >= (-1 << (shift - 1)) && value < (1 << (shift - 1));
diff --git a/chapters/pseudocode.adoc b/chapters/pseudocode.adoc
index 1d6c2f2..b931822 100644
--- a/chapters/pseudocode.adoc
+++ b/chapters/pseudocode.adoc
@@ -56,11 +56,9 @@ void ERROR_IF(condition) {
[source,c++]
----
+// Convert tensor index co-ordinates to an element offset
size_t tensor_index_to_offset(dim_t shape, dim_t index) {
- // Ensure this is a proper tensor with each dimension having size >= 1
- for_each(dimension_size in shape) {
- REQUIRE(dimension_size >= 1);
- }
+ size_t size = tensor_size(shape); // check tensor shape is valid
size_t offset = 0;
for (int32_t i = 0; i < rank(shape); i++) {
REQUIRE(index[i] >= 0 && index[i] < shape[i]);
@@ -69,21 +67,24 @@ size_t tensor_index_to_offset(dim_t shape, dim_t index) {
return offset;
}
+// Convert an element offset to tensor index co-ordinates
dim_t tensor_offset_to_index(dim_t shape, size_t offset) {
- // Index is a dim_t with rank equal to the rank of shape
- dim_t index(rank(shape));
- for(int32_t r = rank(shape1) - 1; r >= 0; r--) {
- index[r] = offset % shape1[r];
- calculated_index /= shape[r];
+ size_t size = tensor_size(shape); // check tensor shape is valid
+ REQUIRE(offset < size);
+ dim_t index(rank(shape)); // index has rank(shape) indicies
+ for(int32_t i = rank(shape) - 1; i >= 0; i--) {
+ index[i] = offset % shape[i];
+ offset /= shape[i];
}
return index;
}
-// Input is the shape of the given tensor
+// Check the tensor shape is valid and return the tensor size in elements
size_t tensor_size(dim_t shape) {
size_t size = 1;
- for (int32_t i=0; i < rank(shape); i++) {
- size *= input[i];
+ for (int32_t i = 0; i < rank(shape); i++) {
+ REQUIRE(1 <= shape[i] && shape[i] <= maximum<size_t> / size);
+ size *= shape[i];
}
return size;
}
diff --git a/chapters/reduction.adoc b/chapters/reduction.adoc
index cd1db7b..3746460 100644
--- a/chapters/reduction.adoc
+++ b/chapters/reduction.adoc
@@ -27,7 +27,7 @@ for_each(index in shape) {
tensor_write<in_out_t>(output, shape, index, true);
}
for_each(index in shape1) {
- out_index = index;
+ dim_t out_index = index;
out_index[axis] = 0;
in_out_t value = tensor_read<in_out_t>(input, shape1, index);
in_out_t state = tensor_read<in_out_t>(output, shape, out_index);
@@ -54,7 +54,7 @@ for_each(index in shape) {
tensor_write<in_out_t>(output, shape, index, false);
}
for_each(index in shape1) {
- out_index = index;
+ dim_t out_index = index;
out_index[axis] = 0;
in_out_t value = tensor_read<in_out_t>(input, shape1, index);
in_out_t state = tensor_read<in_out_t>(output, shape, out_index);
@@ -79,7 +79,7 @@ for_each(index in shape) {
tensor_write<in_out_t>(output, shape, index, minimum<in_out_t>);
}
for_each(index in shape1) {
- out_index = index;
+ dim_t out_index = index;
out_index[axis] = 0;
in_out_t value = tensor_read<in_out_t>(input, shape1, index);
in_out_t state = tensor_read<in_out_t>(output, shape, out_index);
@@ -104,7 +104,7 @@ for_each(index in shape) {
tensor_write<in_out_t>(output, shape, index, maximum<in_out_t>);
}
for_each(index in shape1) {
- out_index = index;
+ dim_t out_index = index;
out_index[axis] = 0;
in_out_t value = tensor_read<in_out_t>(input, shape1, index);
in_out_t state = tensor_read<in_out_t>(output, shape, out_index);
@@ -129,7 +129,7 @@ for_each(index in shape) {
tensor_write<in_out_t>(output, shape, index, 1.0);
}
for_each(index in shape1) {
- out_index = index;
+ dim_t out_index = index;
out_index[axis] = 0;
in_out_t value = tensor_read<in_out_t>(input, shape1, index);
in_out_t state = tensor_read<in_out_t>(output, shape, out_index);
@@ -154,7 +154,7 @@ for_each(index in shape) {
tensor_write<in_out_t>(output, shape, index, 0);
}
for_each(index in shape1) {
- out_index = index;
+ dim_t out_index = index;
out_index[axis] = 0;
in_out_t value = tensor_read<in_out_t>(input, shape1, index);
in_out_t state = tensor_read<in_out_t>(output, shape, out_index);
diff --git a/chapters/tensor_ops.adoc b/chapters/tensor_ops.adoc
index ca936d4..3ebb2c2 100644
--- a/chapters/tensor_ops.adoc
+++ b/chapters/tensor_ops.adoc
@@ -36,11 +36,11 @@ for_each(left_index in left_shape) {
in_t max_value = minimum_value<in_t>;
out_t max_index = 0;
for (i = 0; i < shape[axis]; i++) {
- index = flatten(left_index, [i], right_index);
+ dim_t index = flatten(left_index, [i], right_index);
in_t value = tensor_read<in_t>(input, shape1, index);
if (value > max_value) { max_value = value; max_index = i; }
}
- index = flatten(left_index, right_index);
+ dim_t index = flatten(left_index, right_index);
tensor_write<out_t>(output, shape, index, max_index);
}
}
@@ -74,11 +74,11 @@ for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW, 0 <= c < C ) {
in_out_t output_val;
acc_t acc = 0;
int count = 0;
- iy = oy * stride_y - pad_top;
- ix = ox * stride_x - pad_left;
+ index_t iy = oy * stride_y - pad_top;
+ index_t ix = ox * stride_x - pad_left;
for_each(0 <= ky < kernel_y, 0 <= kx < kernel_x) {
- y = iy + ky;
- x = ix + kx;
+ index_t y = iy + ky;
+ index_t x = ix + kx;
// Only values from the input tensor are used to calculate the
// average, padding does not count
if (0 <= y < IH and 0 <= x < IW) {
@@ -120,11 +120,11 @@ ERROR_IF(OW != idiv_check(IW - 1 + pad_left + pad_right - (KW - 1) * dilation_x,
pad = flatten([0,0], pad, [0,0]);
for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW; 0 <= oc < OC) {
out_t acc = 0;
- iy = oy * stride_y - pad_top;
- ix = ox * stride_x - pad_left;
+ index_t iy = oy * stride_y - pad_top;
+ index_t ix = ox * stride_x - pad_left;
for_each(0 <= ky < KH, 0 <= kx < KW, 0 <= ic < IC) {
- y = iy + ky * dilation_y;
- x = ix + kx * dilation_x;
+ index_t y = iy + ky * dilation_y;
+ index_t x = ix + kx * dilation_x;
if (0 <= y < IH && 0 <= x < IW) {
out_t value = tensor_read<in_t>(input, [N,IH,IW,IC], [n,y,x,ic]);
out_t weight = tensor_read<weight_t>(weight, [OC,KH,KW,IC], [oc,ky,kx,ic]);
@@ -160,13 +160,13 @@ ERROR_IF(OW != idiv_check(IW - 1 + pad_left + pad_right - (KW - 1) * dilation_x,
pad = flatten([0,0], pad, [0,0]);
for_each(0 <= n < N, 0 <= od < OD, 0 <= oy < OH, 0 <= ox < OW; 0 <= oc < OC) {
out_t acc = 0;
- id = od * stride_d - pad_d0;
- iy = oy * stride_y - pad_top;
- ix = ox * stride_x - pad_left;
+ index_t id = od * stride_d - pad_d0;
+ index_t iy = oy * stride_y - pad_top;
+ index_t ix = ox * stride_x - pad_left;
for_each(0 <= kd < KD, 0 <= ky < KH, 0 <= kx < KW, 0 <= ic < IC) {
- d = id + kd * dilation_d;
- y = iy + ky * dilation_y;
- x = ix + kx * dilation_x;
+ index_t d = id + kd * dilation_d;
+ index_t y = iy + ky * dilation_y;
+ index_t x = ix + kx * dilation_x;
if (0 <= x < IW && 0 <= y < IH && 0 <= d < ID) {
out_t value = tensor_read<in_t>(input, [N,ID,IH,IW,IC], [n,d,y,x,ic]);
out_t weight = tensor_read<weight_t>(weight,[OC,KD,KH,KW,IC],[oc,kd,ky,kx,ic]);
@@ -201,11 +201,11 @@ ERROR_IF(OW != idiv_check(IW - 1 + pad_left + pad_right - (KW - 1) * dilation_x,
pad = flatten([0,0], pad, [0,0]);
for_each(0 <= n < N, 0 <= oy < OH, 0 <= ox < OW; 0 <= c < C, 0 <= m < M) {
out_t acc = 0;
- iy = oy * stride_y - pad_top;
- ix = ox * stride_x - pad_left;
+ index_t iy = oy * stride_y - pad_top;
+ index_t ix = ox * stride_x - pad_left;
for_each(0 <= ky < KH, 0 <= kx < KW) {
- y = iy + ky * dilation_y;
- x = ix + kx * dilation_x;
+ index_t y = iy + ky * dilation_y;
+ index_t x = ix + kx * dilation_x;
if (0 <= y < IH && 0 <= x < IW) {
out_t value = tensor_read<in_t>(input, [N,IH,IW,C], [n,y,x,c]);
out_t weight = tensor_read<weight_t>(weight, [KH,KW,C,M], [ky,kx,c,m]);
@@ -338,11 +338,11 @@ ERROR_IF(OW != idiv_check(IW + pad_left + pad_right - kernel_x, stride_x) + 1);
for_each(0 <= n < N, 0 <= oy < H, 0 <= ox < W, 0 <= c < C ) {
in_out_t acc = minimum_value<in_out_t>;
- iy = oy * stride_y - pad_top;
- ix = ox * stride_x - pad_left;
+ index_t iy = oy * stride_y - pad_top;
+ index_t ix = ox * stride_x - pad_left;
for_each( 0 <= ky < kernel_y, 0 <= kx < kernel_x ) {
- y = iy + ky;
- x = ix + kx;
+ index_t y = iy + ky;
+ index_t x = ix + kx;
if (y >= 0 && y < IH && x >= 0 && x < IW) {
in_out_t value = tensor_read<in_out_t>(input, [N,IH,IW,C], [n,y,x,c]);
acc = apply_max(acc, value);
@@ -407,8 +407,8 @@ for_each(index in out_shape) {
}
for_each(0 <= n < N, 0 <= iy < IH, 0 <= ix < IW, 0 <= oc < OC,
0 <= ic < IC, 0 <= ky < KH, 0 <= kx < KW) {
- oy = iy * stride_y + out_pad_top + ky;
- ox = ix * stride_x + out_pad_left + kx;
+ index_t oy = iy * stride_y + out_pad_top + ky;
+ index_t ox = ix * stride_x + out_pad_left + kx;
if (oy >= 0 && oy < OH && ox >= 0 && ox < OW) {
out_t acc = tensor_read<out_t>(output, [N,OH,OW,OC], [n,oy,ox,oc]);
out_t value = tensor_read<in_t>(input, [N,IH,IW,IC], [n,iy,ix,ic]);