From 1e9ba65f263a15f1f9cf9b9484047ea51237187a Mon Sep 17 00:00:00 2001 From: Eric Kunze Date: Wed, 17 Feb 2021 19:23:39 -0800 Subject: Consistency cleanup Attempt to get consistent across the pseudocode. Change the data types to all be intN_t instead of some cases of intN. Use float_t as the general floating point data type. Be consistent on use of the term "floating-point" Move general pseudocode helpers to their own section. Change-Id: Ie77666cd3ee438c71f39c62b9c424fe687b0bb51 Signed-off-by: Eric Kunze --- chapters/activation_funcs.adoc | 61 +++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 31 deletions(-) (limited to 'chapters/activation_funcs.adoc') 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(input, shape, index) - acc = apply_clip(value, min_val, max_val) - tensor_write(output, shape, index, acc) +for_each(index in shape) { + value = tensor_read(input, shape, index); + acc = apply_clip(value, min_val, max_val); + tensor_write(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(input, shape, index) - acc = apply_clip(value, 0, max_val) - tensor_write(output, shape, index, acc) +for_each(index in shape) { + in_t value = tensor_read(input, shape, index); + acc = apply_clip(value, 0, max_val); + tensor_write(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 |=== -- cgit v1.2.1