42 return (f1 < f2) ? f1 : f2;
54 float input[1*1*2*3] = {
55 -3, 2.5, 2, -2.1, 7.8, 100
64 operands[0].
data = input;
65 operands[0].
dims[0] = 1;
66 operands[0].
dims[1] = 1;
67 operands[0].
dims[2] = 2;
68 operands[0].
dims[3] = 3;
74 output = operands[1].
data;
75 for (
int i = 0;
i <
sizeof(input) /
sizeof(
float);
i++) {
77 if (fabs(output[i] - expected_output) >
EPSON) {
78 printf(
"op %d, at index %d, output: %f, expected_output: %f (%s:%d)\n",
79 op, i, output[i], expected_output, __FILE__, __LINE__);
94 float input[1*1*2*3] = {
95 -3, 2.5, 2, -2.1, 7.8, 100
104 operands[0].
data = input;
105 operands[0].
dims[0] = 1;
106 operands[0].
dims[1] = 1;
107 operands[0].
dims[2] = 2;
108 operands[0].
dims[3] = 3;
111 input_indexes[0] = 0;
114 output = operands[1].
data;
115 for (
int i = 0;
i <
sizeof(input) /
sizeof(
float);
i++) {
117 if (fabs(output[i] - expected_output) >
EPSON) {
118 printf(
"op %d, at index %d, output: %f, expected_output: %f (%s:%d)\n",
119 op, i, output[i], expected_output, __FILE__, __LINE__);
134 float input0[1*1*2*3] = {
135 -3, 2.5, 2, -2.1, 7.8, 100
137 float input1[1*1*2*3] = {
138 -1, 2, 3, -21, 8, 10.0
146 operands[0].
data = input0;
147 operands[0].
dims[0] = 1;
148 operands[0].
dims[1] = 1;
149 operands[0].
dims[2] = 2;
150 operands[0].
dims[3] = 3;
151 operands[1].
data = input1;
152 operands[1].
dims[0] = 1;
153 operands[1].
dims[1] = 1;
154 operands[1].
dims[2] = 2;
155 operands[1].
dims[3] = 3;
158 input_indexes[0] = 0;
159 input_indexes[1] = 1;
162 output = operands[2].
data;
163 for (
int i = 0;
i <
sizeof(input0) /
sizeof(
float);
i++) {
164 float expected_output =
get_expected(input0[
i], input1[i], op);
165 if (fabs(output[i] - expected_output) >
EPSON) {
166 printf(
"op %d, at index %d, output: %f, expected_output: %f (%s:%d)\n",
167 op, i, output[i], expected_output, __FILE__, __LINE__);
191 int main(
int argc,
char **argv)
static int test(DNNMathBinaryOperation op)
static float get_expected(float f1, float f2, DNNMathBinaryOperation op)
static int test_broadcast_input1(DNNMathBinaryOperation op)
static int test_broadcast_input0(DNNMathBinaryOperation op)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
DNN inference functions interface for native backend.
int dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters)
#define i(width, name, range_min, range_max)
void * data
data pointer with data length in bytes.
simple assert() macros that are a bit more flexible than ISO C assert().
int32_t dims[4]
there are two memory layouts, NHWC or NCHW, so we use dims, dims[0] is Number.
DNNMathBinaryOperation bin_op
int main(int argc, char **argv)
static int op(uint8_t **dst, const uint8_t *dst_end, GetByteContext *gb, int pixel, int count, int *x, int width, int linesize)
Perform decode operation.
static int test_no_broadcast(DNNMathBinaryOperation op)