42 return (f1 < f2) ? f1 : f2;
44 return (
float)((
int)(f1) % (
int)(f2));
56 float input[1*1*2*3] = {
57 -3, 2.5, 2, -2.1, 7.8, 100
66 operands[0].
data = input;
67 operands[0].
dims[0] = 1;
68 operands[0].
dims[1] = 1;
69 operands[0].
dims[2] = 2;
70 operands[0].
dims[3] = 3;
76 output = operands[1].
data;
77 for (
int i = 0;
i <
sizeof(input) /
sizeof(
float);
i++) {
79 if (
fabs(output[
i] - expected_output) >
EPSON) {
80 printf(
"op %d, at index %d, output: %f, expected_output: %f (%s:%d)\n",
81 op,
i, output[
i], expected_output, __FILE__, __LINE__);
96 float input[1*1*2*3] = {
97 -3, 2.5, 2, -2.1, 7.8, 100
106 operands[0].
data = input;
107 operands[0].
dims[0] = 1;
108 operands[0].
dims[1] = 1;
109 operands[0].
dims[2] = 2;
110 operands[0].
dims[3] = 3;
113 input_indexes[0] = 0;
116 output = operands[1].
data;
117 for (
int i = 0;
i <
sizeof(input) /
sizeof(
float);
i++) {
119 if (
fabs(output[
i] - expected_output) >
EPSON) {
120 printf(
"op %d, at index %d, output: %f, expected_output: %f (%s:%d)\n",
121 op,
i, output[
i], expected_output, __FILE__, __LINE__);
136 float input0[1*1*2*3] = {
137 -3, 2.5, 2, -2.1, 7.8, 100
139 float input1[1*1*2*3] = {
140 -1, 2, 3, -21, 8, 10.0
148 operands[0].
data = input0;
149 operands[0].
dims[0] = 1;
150 operands[0].
dims[1] = 1;
151 operands[0].
dims[2] = 2;
152 operands[0].
dims[3] = 3;
153 operands[1].
data = input1;
154 operands[1].
dims[0] = 1;
155 operands[1].
dims[1] = 1;
156 operands[1].
dims[2] = 2;
157 operands[1].
dims[3] = 3;
160 input_indexes[0] = 0;
161 input_indexes[1] = 1;
164 output = operands[2].
data;
165 for (
int i = 0;
i <
sizeof(input0) /
sizeof(
float);
i++) {
167 if (
fabs(output[
i] - expected_output) >
EPSON) {
168 printf(
"op %d, at index %d, output: %f, expected_output: %f (%s:%d)\n",
169 op,
i, output[
i], expected_output, __FILE__, __LINE__);
193 int main(
int argc,
char **argv)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static __device__ float fabs(float a)
int main(int argc, char **argv)
static float get_expected(float f1, float f2, DNNMathBinaryOperation op)
static int test_broadcast_input1(DNNMathBinaryOperation op)
static int test_broadcast_input0(DNNMathBinaryOperation op)
static int test_no_broadcast(DNNMathBinaryOperation op)
static int test(DNNMathBinaryOperation op)
int ff_dnn_execute_layer_math_binary(DnnOperand *operands, const int32_t *input_operand_indexes, int32_t output_operand_index, const void *parameters, NativeContext *ctx)
DNN inference functions interface for native backend.
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.
DNNMathBinaryOperation bin_op
void * data
data pointer with data length in bytes.
int32_t dims[4]
there are two memory layouts, NHWC or NCHW, so we use dims, dims[0] is Number.