36 #include "depthwise.hpp"
45 template <
class OutputStage>
46 using ConstraintFn = std::function<bool(
const DepthwiseArgs &,
const OutputStage &)>;
48 using GenericConstraintFn = std::function<bool(
const DepthwiseArgs &,
const void *)>;
50 GenericConstraintFn make_constraint(
const GenericConstraintFn &f) __attribute__ ((unused));
51 GenericConstraintFn make_constraint(
const GenericConstraintFn &f)
56 template <
typename ... Fs>
57 GenericConstraintFn make_constraint(
const GenericConstraintFn &f, Fs ... fs)
59 return [f, fs...] (
const DepthwiseArgs &
args,
const void *os) ->
bool {
60 return f(
args, os) && make_constraint(fs...)(
args, os);
64 template <
typename OutputStage=Nothing,
typename ... Fs>
65 ConstraintFn<OutputStage> constraint(Fs ... fs)
67 return [fs...] (
const DepthwiseArgs &
args,
const OutputStage &os) ->
bool {
68 return make_constraint(fs...)(
args, &os);
73 template <
class Strategy>
76 return ((
args.kernel_rows == Strategy::kernel_rows) &&
77 (
args.kernel_cols == Strategy::kernel_cols) &&
78 (
args.stride_rows == Strategy::stride_rows) &&
79 (
args.stride_cols == Strategy::stride_cols));
82 bool cpu_has_dot_product(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
83 bool cpu_has_dot_product(
const DepthwiseArgs &
args,
const void *)
85 return args.cpu_info->has_dotprod();
88 bool cpu_has_sme(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
89 bool cpu_has_sme(
const DepthwiseArgs &
args,
const void *)
91 return args.cpu_info->has_sme();
94 bool cpu_has_sme2(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
95 bool cpu_has_sme2(
const DepthwiseArgs &
args,
const void *)
97 return args.cpu_info->has_sme2();
100 bool cpu_has_sve(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
101 bool cpu_has_sve(
const DepthwiseArgs &
args,
const void *)
103 return args.cpu_info->has_sve();
106 bool cpu_has_sve2(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
107 bool cpu_has_sve2(
const DepthwiseArgs &
args,
const void *)
109 return args.cpu_info->has_sve2();
112 bool cpu_has_fp16(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
113 bool cpu_has_fp16(
const DepthwiseArgs &
args,
const void *)
115 return args.cpu_info->has_fp16();
118 bool has_no_channel_multiplier(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
119 bool has_no_channel_multiplier(
const DepthwiseArgs &
args,
const void *)
121 return args.channel_multiplier == 1;
124 bool has_channel_multiplier(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
125 bool has_channel_multiplier(
const DepthwiseArgs &
args,
const void *)
127 return args.channel_multiplier > 1;
133 bool no_prime_right_pad(
const DepthwiseArgs &
args,
const void *) __attribute__ ((unused));
134 bool no_prime_right_pad(
const DepthwiseArgs &
args,
const void *)
136 return (
args.input_cols +
args.padding.left) >= (
args.kernel_cols - 1);
139 bool qp_has_no_left_shift(
const DepthwiseArgs &
args,
const void *_qp) __attribute__ ((unused));
140 bool qp_has_no_left_shift(
const DepthwiseArgs &,
const void *_qp)
144 (qp->per_channel_left_shifts ==
nullptr) :
145 (qp->per_layer_left_shift == 0);
148 bool qp_zero_a_offset(
const DepthwiseArgs &
args,
const void *_qp) __attribute__ ((unused));
149 bool qp_zero_a_offset(
const DepthwiseArgs &,
const void *_qp)
155 template <
typename T>
bool qp_skip_clamp(
const DepthwiseArgs &
args,
const void *_qp) __attribute__ ((unused));
156 template <
typename T>
bool qp_skip_clamp(
const DepthwiseArgs &,
const void *_qp)
159 return (qp->minval == std::numeric_limits<T>::min() &&
160 qp->maxval == std::numeric_limits<T>::max());