Coverage Report

Created: 2019-07-03 22:50

/home/liu/buildslave/linux-x64-runtests/build/lib/nnc/cmd/softmax/ccv_nnc_softmax.c
Line
Count
Source
1
#include <ccv.h>
2
#include <nnc/ccv_nnc.h>
3
#include <nnc/ccv_nnc_internal.h>
4
5
static int _ccv_nnc_arbitary_inplace(const int input_idx, const int input_size, const int output_idx, const int output_size)
6
7
{
7
7
  return 1;
8
7
}
9
10
static int _ccv_nnc_allow_graident_inplace(const int input_idx, const int input_size, const int output_idx, const int output_size)
11
6
{
12
6
  return (input_idx == 0 && 
output_idx == 02
);
13
6
}
14
15
static int _ccv_nnc_softmax_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)
16
16
{
17
16
  if ((input_bitmasks[0] & 1u) == 1u && 
output_bitmasks[0] == 1u8
)
18
8
    return 1;
19
8
  return 0;
20
8
}
21
22
static int _ccv_nnc_softmax_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)
23
26
{
24
26
  if ((input_bitmasks[0] & 5u) == 5u && 
output_bitmasks[0] == 1u10
)
25
10
    return 1;
26
16
  return 0;
27
16
}
28
29
REGISTER_COMMAND(CCV_NNC_SOFTMAX_FORWARD)(ccv_nnc_cmd_registry_t* const registry)
30
  FIND_BACKEND(ccv_nnc_softmax_cpu_ref.c, gpu/ccv_nnc_softmax_gpu_cudnn.cu)
31
1
{
32
1
  registry->bitmask = _ccv_nnc_softmax_forw_bitmask;
33
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_forward_from_inputs;
34
1
  registry->allow_inplace = _ccv_nnc_arbitary_inplace;
35
1
}
36
37
REGISTER_COMMAND(CCV_NNC_SOFTMAX_BACKWARD)(ccv_nnc_cmd_registry_t* const registry)
38
  FIND_BACKEND(ccv_nnc_softmax_cpu_ref.c, gpu/ccv_nnc_softmax_gpu_cudnn.cu)
39
1
{
40
1
  registry->flags = CCV_NNC_CMD_ATTR_NULL_IS_ONES;
41
1
  registry->bitmask = _ccv_nnc_softmax_back_bitmask;
42
1
  registry->tensor_auto = ccv_nnc_hint_tensor_auto_backward_from_gradient;
43
1
  registry->allow_inplace = _ccv_nnc_allow_graident_inplace;
44
1
}
45
46
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_SOFTMAX_FORWARD)
47
#define CMD_SOFTMAX_FORWARD() ccv_nnc_cmd(CCV_NNC_SOFTMAX_FORWARD, 0, ccv_nnc_cmd_auto, 0)
48
//@REGISTER_EASY_COMMAND_MACRO(CCV_NNC_SOFTMAX_BACKWARD)
49
#define CMD_SOFTMAX_BACKWARD() ccv_nnc_cmd(CCV_NNC_SOFTMAX_BACKWARD, 0, ccv_nnc_cmd_auto, 0)