def __init__(self, node_name, cname, pool_params, act_params, gen_ctrl=None, at_ver=3, force_relu=True): if gen_ctrl is None: self.gen_ctrl = GenCtrl(None, cname=cname) else: gen_ctrl.cname = cname self.gen_ctrl = gen_ctrl if act_params is not None: self.at_act_params = gen_active_at_params(act_params, force_relu=force_relu) else: self.at_act_params = NO_ACTIVATION self.at_globalpool_params = gen_globalpool_at_params(pool_params) in_dim = pool_params.in_dims[0] reduce_sz = reduce(lambda x, y: x * y, (sz for idx, sz in enumerate(in_dim.shape) if idx not in pool_params.axis), 1) #self.c = in_dim.size()/reduce_sz self.c = reduce_sz (self.h, self.w) = balanced_divisors(in_dim.size() / reduce_sz) self.cname = cname self.node_name = node_name self.at_ver = at_ver
def __init__(self, node_name, cname, params, qrec, gen_ctrl=None, at_ver=3): if gen_ctrl is None: self.gen_ctrl = GenCtrl(None, cname=cname) else: gen_ctrl.cname = cname self.gen_ctrl = gen_ctrl self.at_globalpool_params = gen_globalpool_at_params(params) in_dim = params.in_dims[0] reduce_sz = reduce( lambda x, y: x * y, (sz for idx, sz in enumerate(in_dim.shape) if idx not in params.axis)) #self.c = in_dim.size()/reduce_sz self.c = reduce_sz (self.h, self.w) = balanced_divisors(in_dim.size() / reduce_sz) self.in_q = qrec.in_qs[0] self.out_q = qrec.out_qs[0] self.cname = cname self.node_name = node_name self.at_ver = at_ver
def __init__(self, node_name, cname, pool_params, pool_q, act_params, act_q, force_relu, gen_ctrl=None): if gen_ctrl is None: self.gen_ctrl = gen_ctrl = GenCtrl(None, cname=cname) else: gen_ctrl.cname = cname self.gen_ctrl = gen_ctrl at_pool_params = gen_globalpool_at_params(pool_params) in_dim = pool_params.in_dims[0] out_dim = pool_params.out_dims[0] in_q = pool_q.in_qs[0] out_q = pool_q.out_qs[0] reduce_sz = reduce(lambda x, y: x * y, (sz for idx, sz in enumerate(in_dim.shape) if idx not in pool_params.axis), 1) #self.c = in_dim.size()/reduce_sz feat = reduce_sz height, width = balanced_divisors(in_dim.size() / reduce_sz) if act_params is not None: act_op = gen_activation_op( act_params.activation, force_relu=force_relu, asymmetric=act_q.in_qs[0].zero_point != 0) if out_dim is None: out_dim = act_params.out_dims[0].expand_to_chw() out_q = act_q.out_qs[0] else: act_op = "KOP_NONE" attrs = { 'in_size': in_q.dtype_bits // 8 if in_q.signed else -in_q.dtype_bits // 8, 'out_size': out_q.dtype_bits // 8 if out_q.signed else -out_q.dtype_bits // 8, 'feat': feat, 'width': width, 'height': height, 'kop_pool': at_pool_params.GlobalPoolOper, 'kop_act': act_op } extra_attrs = {'cname': cname, 'node_name': node_name} super().__init__(attrs, extra_attrs, gen_ctrl=gen_ctrl)
def __init__(self, node_name, cname, pool_params, act_params, act_q=None, gen_ctrl=None, at_ver=3, force_relu=True): if gen_ctrl is None: self.gen_ctrl = GenCtrl(None, cname=cname) else: gen_ctrl.cname = cname self.gen_ctrl = gen_ctrl if pool_params.ker_in_order and pool_params.ker_in_order[0] == [ "h", "w", "c" ]: self.gen_ctrl.hwc = 1 if act_params is not None: self.at_act_params = gen_active_at_params( act_params, force_relu=force_relu, asymmetric=act_q.in_qs[0].zero_point != 0) else: self.at_act_params = NO_ACTIVATION self.at_globalpool_params = gen_globalpool_at_params(pool_params) in_dim = pool_params.in_dims[0] reduce_sz = reduce(lambda x, y: x * y, (sz for idx, sz in enumerate(in_dim.shape) if idx not in pool_params.axis), 1) #self.c = in_dim.size()/reduce_sz self.c = reduce_sz (self.h, self.w) = balanced_divisors(in_dim.size() / reduce_sz) self.cname = cname self.node_name = node_name self.at_ver = at_ver