def clip_strategy_vta(attrs, inputs, out_type, target): strategy = OpStrategy() strategy.add_implementation(compute_clip_vta, _strategy.wrap_topi_schedule( topi.generic.schedule_injective), name="clip.vta") return strategy
def conv2d_strategy_ethosu(attrs, inputs, out_type, target): strategy = OpStrategy() strategy.add_implementation( create_ethosu_conv2d_compute, _strategy.wrap_topi_schedule(schedule_injective), name="ethosu_conv2d", ) return strategy
def multiply_strategy_vta(attrs, inputs, out_type, target): strategy = OpStrategy() strategy.add_implementation( _strategy.wrap_topi_compute(multiply_packed), _strategy.wrap_topi_schedule(schedule_multiply_packed), name="multiply.vta", ) return strategy
def dense_strategy_vta(attrs, inputs, out_type, target): """dense vta strategy""" if inputs[0].shape == 4: # this implies the layout is packed strategy = OpStrategy() strategy.add_implementation( _strategy.wrap_compute_dense(dense_packed), _strategy.wrap_topi_schedule(schedule_dense_packed), name="dense_packed.vta") return strategy # If it's not packed, run on ARM CPU arm_tgt = tvm.target.arm_cpu(target.model) return _strategy.x86.dense_strategy_cpu(attrs, inputs, out_type, arm_tgt)
def conv2d_transpose_strategy_vta(attrs, inputs, out_type, target): """conv2d_transpose vta strategy""" dilation = topi.util.get_const_tuple(attrs.dilation) layout = attrs.data_layout assert dilation == (1, 1), "support for dilation limited to (1, 1)" if is_packed_layout(layout): strategy = OpStrategy() strategy.add_implementation( _strategy.wrap_compute_conv2d_transpose(conv2d_transpose_packed), _strategy.wrap_topi_schedule(schedule_conv2d_transpose_packed), name="conv2d_transpose_packed.vta") return strategy # If it's not packed, run on ARM CPU arm_tgt = tvm.target.arm_cpu(target.model) return _strategy.arm_cpu.conv2d_transpose_strategy_arm_cpu(attrs, inputs, out_type, arm_tgt)
def conv2d_strategy_vta(attrs, inputs, out_type, target): """conv2d vta strategy""" strategy = OpStrategy() kernel = inputs[1] dilation = topi.utils.get_const_tuple(attrs.dilation) groups = attrs.groups layout = attrs.data_layout assert dilation == (1, 1), "support for dilation limited to (1, 1)" if is_packed_layout(layout): if groups == 1: env = get_env() assert env.LOG_INP_WIDTH == 3, "only support 8bit inp for now" assert env.LOG_WGT_WIDTH == 3, "only support 8bit wgt for now" assert kernel.dtype == "int8" strategy.add_implementation( _strategy.wrap_compute_conv2d(conv2d_packed, True), _strategy.wrap_topi_schedule(schedule_conv2d_packed), name="conv2d_packed.vta", ) else: # group_conv2d strategy.add_implementation( _strategy.wrap_compute_conv2d(group_conv2d_packed, has_groups=True), _strategy.wrap_topi_schedule(schedule_group_conv2d_packed), name="group_conv2d_packed.vta", ) return strategy # If it's not packed, run on ARM CPU arm_tgt = tvm.target.arm_cpu(target.model) return _strategy.arm_cpu.conv2d_strategy_arm_cpu(attrs, inputs, out_type, arm_tgt)