History

dnn_backend_native_layer_mathunary: add round support

Mingyu Yin committed 6 years ago

Commit 4ed6bca1 parent ed39d285 files · +11 −2Browse files

Unified · Split

5 files
  1. libavfilter/dnn/dnn_backend_native_layer_mathunary.c +4 −0
  2. libavfilter/dnn/dnn_backend_native_layer_mathunary.h +1 −0
  3. tests/dnn/dnn-layer-mathunary-test.c +4 −0
  4. tools/python/convert_from_tensorflow.py +1 −1
  5. tools/python/convert_header.py +1 −1
libavfilter/dnn/dnn_backend_native_layer_mathunary.c+4−0
@@ -138,6 +138,10 @@ int dnn_execute_layer_math_unary(DnnOperand *operands, const int32_t *input_oper · 137 unmodified lines
138138 for (int i = 0; i < dims_count; ++i)
139139 dst[i] = floor(src[i]);
140140 return 0;
141+ case DMUO_ROUND:
142+ for (int i = 0; i < dims_count; ++i)
143+ dst[i] = round(src[i]);
144+ return 0;
141145 default:
142146 return -1;
143147 }
libavfilter/dnn/dnn_backend_native_layer_mathunary.h+1−0
@@ -45,6 +45,7 @@ typedef enum { · 44 unmodified lines
4545 DMUO_ATANH = 12,
4646 DMUO_CEIL = 13,
4747 DMUO_FLOOR = 14,
48+ DMUO_ROUND = 15,
4849 DMUO_COUNT
4950 } DNNMathUnaryOperation;
5051
tests/dnn/dnn-layer-mathunary-test.c+4−0
@@ -60,6 +60,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) · 59 unmodified lines
6060 return ceil(f);
6161 case DMUO_FLOOR:
6262 return floor(f);
63+ case DMUO_ROUND:
64+ return round(f);
6365 default:
6466 av_assert0(!"not supported yet");
6567 return 0.f;
@@ -136,5 +138,7 @@ int main(int agrc, char **argv) · 70 unmodified lines
136138 return 1;
137139 if (test(DMUO_FLOOR))
138140 return 1;
141+ if (test(DMUO_ROUND))
142+ return 1;
139143 return 0;
140144 }
tools/python/convert_from_tensorflow.py+1−1
@@ -76,7 +76,7 @@ class TFConverter: · 75 unmodified lines
7676 self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4}
7777 self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4,
7878 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10,
79− 'Acosh':11, 'Atanh':12, 'Ceil':13, 'Floor':14}
79+ 'Acosh':11, 'Atanh':12, 'Ceil':13, 'Floor':14, 'Round':15}
8080 self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2}
8181 self.name_operand_dict = {}
8282
tools/python/convert_header.py+1−1
@@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' · 22 unmodified lines
2323 major = 1
2424
2525 # increase minor when we don't have to re-convert the model file
26−minor = 20
26+minor = 21

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t