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
138 for (int i = 0; i < dims_count; ++i)138 for (int i = 0; i < dims_count; ++i)
139 dst[i] = floor(src[i]);139 dst[i] = floor(src[i]);
140 return 0;140 return 0;
141 case DMUO_ROUND:
142 for (int i = 0; i < dims_count; ++i)
143 dst[i] = round(src[i]);
144 return 0;
141 default:145 default:
142 return -1;146 return -1;
143 }147 }
libavfilter/dnn/dnn_backend_native_layer_mathunary.h+1−0
@@ -45,6 +45,7 @@ typedef enum { · 44 unmodified lines
45 DMUO_ATANH = 12,45 DMUO_ATANH = 12,
46 DMUO_CEIL = 13,46 DMUO_CEIL = 13,
47 DMUO_FLOOR = 14,47 DMUO_FLOOR = 14,
48 DMUO_ROUND = 15,
48 DMUO_COUNT49 DMUO_COUNT
49} DNNMathUnaryOperation;50} DNNMathUnaryOperation;
50 51
tests/dnn/dnn-layer-mathunary-test.c+4−0
@@ -60,6 +60,8 @@ static float get_expected(float f, DNNMathUnaryOperation op) · 59 unmodified lines
60 return ceil(f);60 return ceil(f);
61 case DMUO_FLOOR:61 case DMUO_FLOOR:
62 return floor(f);62 return floor(f);
63 case DMUO_ROUND:
64 return round(f);
63 default:65 default:
64 av_assert0(!"not supported yet");66 av_assert0(!"not supported yet");
65 return 0.f;67 return 0.f;
@@ -136,5 +138,7 @@ int main(int agrc, char **argv) · 70 unmodified lines
136 return 1;138 return 1;
137 if (test(DMUO_FLOOR))139 if (test(DMUO_FLOOR))
138 return 1;140 return 1;
141 if (test(DMUO_ROUND))
142 return 1;
139 return 0;143 return 0;
140}144}
tools/python/convert_from_tensorflow.py+1−1
@@ -76,7 +76,7 @@ class TFConverter: · 75 unmodified lines
76 self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4}76 self.mathbin2code = {'Sub':0, 'Add':1, 'Mul':2, 'RealDiv':3, 'Minimum':4}
77 self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4,77 self.mathun2code = {'Abs':0, 'Sin':1, 'Cos':2, 'Tan':3, 'Asin':4,
78 'Acos':5, 'Atan':6, 'Sinh':7, 'Cosh':8, 'Tanh':9, 'Asinh':10,78 '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}
80 self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2}80 self.mirrorpad_mode = {'CONSTANT':0, 'REFLECT':1, 'SYMMETRIC':2}
81 self.name_operand_dict = {}81 self.name_operand_dict = {}
82 82
tools/python/convert_header.py+1−1
@@ -23,4 +23,4 @@ str = 'FFMPEGDNNNATIVE' · 22 unmodified lines
23major = 123major = 1
24 24
25# increase minor when we don't have to re-convert the model file25# increase minor when we don't have to re-convert the model file
26minor = 2026minor = 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