Coverage Report

Created: 2021-04-05 03:19

/home/liu/buildslave/linux-x64-runtests/build/lib/nnc/cmd/swish/ccv_nnc_swish.c
Line
Count
Source (jump to first uncovered line)
1
#include "ccv.h"
2
#include "nnc/ccv_nnc.h"
3
#include "nnc/ccv_nnc_internal.h"
4
5
static int _ccv_nnc_swish_allow_first_replace(const int input_idx, const int input_size, const int output_idx, const int output_size)
6
9
{
7
9
  return input_idx == 0 && 
output_idx == 06
;
8
9
}
9
10
static int _ccv_nnc_swish_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)
11
0
{
12
0
  if ((input_bitmasks[0] & 1u) == 1u && output_bitmasks[0] == 1u)
13
0
    return 1;
14
0
  return 0;
15
0
}
16
17
static int _ccv_nnc_swish_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)
18
12
{
19
12
  if ((input_bitmasks[0] & 3u) == ((1u << 0) | (1u << 1)) && 
output_bitmasks[0] == 1u6
)
20
6
    return 1;
21
6
  return 0;
22
6
}
23
24
REGISTER_COMMAND(CCV_NNC_SWISH_FORWARD)(ccv_nnc_cmd_registry_t* const registry)
25
  FIND_BACKEND(ccv_nnc_swish_cpu_ref.c, gpu/ccv_nnc_swish_gpu_ref.cu)
26
1
{
27
1
  registry->bitmask = _ccv_nnc_swish_forw_bitmask;
28
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_forward_from_inputs;
29
1
  registry->allow_inplace = _ccv_nnc_swish_allow_first_replace;
30
1
}
31
32
REGISTER_COMMAND(CCV_NNC_SWISH_BACKWARD)(ccv_nnc_cmd_registry_t* const registry)
33
  FIND_BACKEND(ccv_nnc_swish_cpu_ref.c, gpu/ccv_nnc_swish_gpu_ref.cu)
34
1
{
35
1
  registry->bitmask = _ccv_nnc_swish_back_bitmask;
36
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_backward_from_gradient;
37
1
  registry->allow_inplace = _ccv_nnc_swish_allow_first_replace;
38
1
}
39
40
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_SWISH_FORWARD)
41
#define CMD_SWISH_FORWARD() ccv_nnc_cmd(CCV_NNC_SWISH_FORWARD, 0, ccv_nnc_cmd_auto, 0)
42
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_SWISH_BACKWARD)
43
#define CMD_SWISH_BACKWARD() ccv_nnc_cmd(CCV_NNC_SWISH_BACKWARD, 0, ccv_nnc_cmd_auto, 0)