aboutsummaryrefslogtreecommitdiff
path: root/chapters/activation_funcs.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'chapters/activation_funcs.adoc')
-rw-r--r--chapters/activation_funcs.adoc61
1 files changed, 30 insertions, 31 deletions
diff --git a/chapters/activation_funcs.adoc b/chapters/activation_funcs.adoc
index 3fc8bc0..5af849d 100644
--- a/chapters/activation_funcs.adoc
+++ b/chapters/activation_funcs.adoc
@@ -18,30 +18,29 @@ Clamp to an arbitrary minimum and maximum value. Note that the maximum and minim
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t*|Input|shape|Input tensor with rank from 1 to 4
+|Input|in_t*|Input|shape|Input tensor
|Attribute|in_t|min_val|-|minimum clip value
|Attribute|in_t|max_val|-|maximum clip value
-|Output|out_t*|Output|shape|Output tensor of same type and shape as input
+|Output|in_t*|Output|shape|Output tensor of same type and shape as input
|===
*Operation Function:*
....
-assert(rank(shape)<=4)
-for_each (index in shape) {
- value = tensor_read<in_t>(input, shape, index)
- acc = apply_clip(value, min_val, max_val)
- tensor_write<out_t>(output, shape, index, acc)
+for_each(index in shape) {
+ value = tensor_read<in_t>(input, shape, index);
+ acc = apply_clip<in_t>(value, min_val, max_val);
+ tensor_write<in_t>(output, shape, index, acc);
}
....
*Supported Data Types:*
|===
-|Profile|Mode|in_t|out_t
+|Profile|Mode|in_t
-|Any|signed 8|int8 |int8
-|Any|signed 16|int16|int16
-|MI, MT|float|float|float
+|Any|signed 8|int8_t
+|Any|signed 16|int16_t
+|MI, MT|floating-point|float_t
|===
==== RELUN
@@ -53,19 +52,19 @@ ReLU with a scalar maximum value.
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t*|Input|shape|Input tensor with rank from 1 to 4
+|Input|in_t*|Input|shape|Input tensor
|Attribute|in_t|max_val|-|maximum clip value
-|Output|out_t*|Output|shape|Output tensor of same type and shape as input
+|Output|in_t*|Output|shape|Output tensor of same type and shape as input
|===
*Operation Function:*
[source,c]
----
-for_each (index in shape) {
- in_t value = tensor_read<in_t>(input, shape, index)
- acc = apply_clip<in_t>(value, 0, max_val)
- tensor_write<in_t>(output, shape, index, acc)
+for_each(index in shape) {
+ in_t value = tensor_read<in_t>(input, shape, index);
+ acc = apply_clip<in_t>(value, 0, max_val);
+ tensor_write<in_t>(output, shape, index, acc);
}
----
@@ -74,8 +73,8 @@ for_each (index in shape) {
|===
|Profile|Mode|in_t
-|Any|signed 32|int32
-|MI, MT|float|float
+|Any|signed 32|int32_t
+|MI, MT|floating-point|float_t
|===
==== SIGMOID
@@ -90,9 +89,9 @@ The sigmoid table has 513 entries each of 16-bit precision and covering the inpu
[source,c]
....
int sigmoid_reference(int x) {|// input x range is -256 to + 256 inclusive
- F64 v = (double)x/(double)16;
- v = 1.0/(1.0+exp(-v));
- return round_to_nearest(32768.0 * v);
+ F64 v = (double)x / (double)16;
+ v = 1.0/(1.0 + exp(-v));
+ return round_to_nearest_int(32768.0 * v);
}
generate_lookup_table(&sigmoid_table, &sigmoid_reference);
@@ -103,16 +102,16 @@ generate_lookup_table(&sigmoid_table, &sigmoid_reference);
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t*|Input|shape|Input tensor with rank from 1 to 4
-|Output|out_t*|Output|shape|Output tensor of same type and shape as input
+|Input|in_t*|Input|shape|Input tensor
+|Output|in_t*|Output|shape|Output tensor of same type and shape as input
|===
*Supported Data Types:*
|===
-|Profile|Mode|in_t|out_t
+|Profile|Mode|in_t
-|MI, MT|float|float|float
+|MI, MT|floating-point|float_t
|===
==== TANH
@@ -130,7 +129,7 @@ int tanh_reference(int x) { // input x range is -256 to +256 inclusive
F64 v = (double)x/(double)32;
v = exp(-2.0*v);
v = (1.0-v)/(1.0+v);
- return round_to_nearest(32768.0 * v);
+ return round_to_nearest_int(32768.0 * v);
}
generate_lookup_table(&tanh_table, &tanh_reference);
@@ -141,14 +140,14 @@ generate_lookup_table(&tanh_table, &tanh_reference);
|===
|Argument|Type|Name|Shape|Description
-|Input|in_t*|Input|shape|Input tensor with rank from 1 to 4
-|Output|out_t*|Output|shape|Output tensor of same type and shape as input
+|Input|in_t*|Input|shape|Input tensor
+|Output|in_t*|Output|shape|Output tensor of same type and shape as input
|===
*Supported Data Types:*
|===
-|Profile|Mode|in_t|out_t
+|Profile|Mode|in_t
-|MI, MT|float|float|float
+|MI, MT|floating-point|float_t
|===