Coverage Report

Created: 2021-04-05 03:19

/home/liu/buildslave/linux-x64-runtests/build/lib/nnc/cmd/compare/ccv_nnc_cmp.c
Line
Count
Source (jump to first uncovered line)
1
#include "ccv.h"
2
#include "ccv_internal.h"
3
#include "nnc/ccv_nnc.h"
4
#include "nnc/ccv_nnc_internal.h"
5
#include "nnc/ccv_nnc_easy.h"
6
7
static int _ccv_nnc_arbitary_inplace(const int input_idx, const int input_size, const int output_idx, const int output_size)
8
0
{
9
0
  return 1;
10
0
}
11
12
static int _ccv_nnc_cmp_forw_bitmask(const int input_size, const int output_size, const uint64_t* const input_bitmasks, const int input_bitmask_size, const uint64_t* const output_bitmasks, const int output_bitmask_size)
13
12
{
14
12
  if ((input_bitmasks[0] & 3u) == ((1u << 0) | (1u << 1)) && 
output_bitmasks[0] == 1u4
)
15
4
    return 1;
16
8
  return 0;
17
8
}
18
19
static int _ccv_nnc_cmp_back_bitmask(const int input_size, const int output_size, const uint64_t* const input_bitmasks, const int input_bitmask_size, const uint64_t* const output_bitmasks, const int output_bitmask_size)
20
0
{
21
0
  // w.r.t. both x and y, either way, need gradient, input x, input y.
22
0
  if ((input_bitmasks[0] & 7u) == 7u && output_bitmasks[0] == ((1u << 0) | (1u << 1)))
23
0
    return 1;
24
0
  return 0;
25
0
}
26
27
REGISTER_COMMAND(CCV_NNC_MIN_FORWARD)(ccv_nnc_cmd_registry_t* const registry)
28
  FIND_BACKEND(ccv_nnc_min_cpu_ref.c, gpu/ccv_nnc_min_gpu_ref.cu)
29
1
{
30
1
  registry->bitmask = _ccv_nnc_cmp_forw_bitmask;
31
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_forward_from_inputs;
32
1
  registry->allow_inplace = _ccv_nnc_arbitary_inplace;
33
1
}
34
35
REGISTER_COMMAND(CCV_NNC_MIN_BACKWARD)(ccv_nnc_cmd_registry_t* const registry)
36
  FIND_BACKEND(ccv_nnc_min_cpu_ref.c, gpu/ccv_nnc_min_gpu_ref.cu)
37
1
{
38
1
  registry->flags = CCV_NNC_CMD_ATTR_NULL_IS_ONES;
39
1
  registry->bitmask = _ccv_nnc_cmp_back_bitmask;
40
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_backward_from_gradient;
41
1
  registry->allow_inplace = _ccv_nnc_arbitary_inplace;
42
1
}
43
44
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_MIN_FORWARD)
45
#define CMD_MIN_FORWARD() ccv_nnc_cmd(CCV_NNC_MIN_FORWARD, 0, (ccv_nnc_cmd_param_t){.size={.dim={1,1,1}}}, 0)
46
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_MIN_BACKWARD)
47
#define CMD_MIN_BACKWARD() ccv_nnc_cmd(CCV_NNC_MIN_BACKWARD, 0, (ccv_nnc_cmd_param_t){.size={.dim={1,1,1}}}, 0)
48
49
REGISTER_COMMAND(CCV_NNC_MAX_FORWARD)(ccv_nnc_cmd_registry_t* const registry)
50
  FIND_BACKEND(ccv_nnc_max_cpu_ref.c, gpu/ccv_nnc_max_gpu_ref.cu)
51
1
{
52
1
  registry->bitmask = _ccv_nnc_cmp_forw_bitmask;
53
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_forward_from_inputs;
54
1
  registry->allow_inplace = _ccv_nnc_arbitary_inplace;
55
1
}
56
57
REGISTER_COMMAND(CCV_NNC_MAX_BACKWARD)(ccv_nnc_cmd_registry_t* const registry)
58
  FIND_BACKEND(ccv_nnc_max_cpu_ref.c, gpu/ccv_nnc_max_gpu_ref.cu)
59
1
{
60
1
  registry->flags = CCV_NNC_CMD_ATTR_NULL_IS_ONES;
61
1
  registry->bitmask = _ccv_nnc_cmp_back_bitmask;
62
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_backward_from_gradient;
63
1
  registry->allow_inplace = _ccv_nnc_arbitary_inplace;
64
1
}
65
66
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_MAX_FORWARD)
67
#define CMD_MAX_FORWARD() ccv_nnc_cmd(CCV_NNC_MAX_FORWARD, 0, (ccv_nnc_cmd_param_t){.size={.dim={1,1,1}}}, 0)
68
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_MAX_BACKWARD)
69
#define CMD_MAX_BACKWARD() ccv_nnc_cmd(CCV_NNC_MAX_BACKWARD, 0, (ccv_nnc_cmd_param_t){.size={.dim={1,1,1}}}, 0)