@@ -443,6 +443,34 @@ static void tanh_f32(const float * restrict src,
443443 }
444444}
445445
446+ static void abs_f32 (const float * restrict src ,
447+ float * restrict dst ,
448+ const uint32_t num_rows ,
449+ const struct htp_unary_context * uctx ) {
450+ htp_unary_op_preamble ;
451+
452+ for (uint32_t ir = 0 ; ir < num_rows ; ir ++ ) {
453+ const uint8_t * restrict src_local = (const uint8_t * )src + (ir * src0_row_size_aligned );
454+ uint8_t * restrict dst_local = (uint8_t * )dst + (ir * dst_row_size_aligned );
455+
456+ hvx_abs_f32_aa (dst_local , src_local , ne0 );
457+ }
458+ }
459+
460+ static void log_f32 (const float * restrict src ,
461+ float * restrict dst ,
462+ const uint32_t num_rows ,
463+ const struct htp_unary_context * uctx ) {
464+ htp_unary_op_preamble ;
465+
466+ for (uint32_t ir = 0 ; ir < num_rows ; ir ++ ) {
467+ const uint8_t * restrict src_local = (const uint8_t * )src + (ir * src0_row_size_aligned );
468+ uint8_t * restrict dst_local = (uint8_t * )dst + (ir * dst_row_size_aligned );
469+
470+ hvx_log_f32_aa (dst_local , src_local , ne0 );
471+ }
472+ }
473+
446474#define DEFINE_UNARY_TASK (NAME , IS_RMS_NORM_MUL , IS_TRI , CORE_EXPR ) \
447475static void unary_task_f32_##NAME(unsigned int nth, unsigned int ith, void * data) { \
448476 const struct htp_unary_context * uctx = (const struct htp_unary_context *) data; \
@@ -603,6 +631,8 @@ DEFINE_UNARY_TASK(unary_silu, false, false, silu_f32(src0_vtcm, dst_vtcm, bl
603631DEFINE_UNARY_TASK (unary_gelu , false, false, gelu_f32 (src0_vtcm , dst_vtcm , block_size , uctx ))
604632DEFINE_UNARY_TASK (unary_softplus , false, false, softplus_f32 (src0_vtcm , dst_vtcm , block_size , uctx ))
605633DEFINE_UNARY_TASK (unary_tanh , false, false, tanh_f32 (src0_vtcm , dst_vtcm , block_size , uctx ))
634+ DEFINE_UNARY_TASK (unary_abs , false, false, abs_f32 (src0_vtcm , dst_vtcm , block_size , uctx ))
635+ DEFINE_UNARY_TASK (unary_log , false, false, log_f32 (src0_vtcm , dst_vtcm , block_size , uctx ))
606636DEFINE_UNARY_TASK (l2_norm , false, false, l2_norm_f32 (src0_vtcm , dst_vtcm , block_size , uctx ))
607637DEFINE_UNARY_TASK (tri , false, true, tri_f32 (src0_vtcm , dst_vtcm , block_size , ir , uctx ))
608638
@@ -850,6 +880,8 @@ DEFINE_UNARY_TILED_TASK(unary_silu, false, tile_silu_f32(dst_vtcm, src_vtcm,
850880DEFINE_UNARY_TILED_TASK (unary_gelu , false, tile_gelu_f32 (dst_vtcm , src_vtcm , tw ))
851881DEFINE_UNARY_TILED_TASK (unary_softplus , false, tile_unary_softplus_f32 (dst_vtcm , src_vtcm , tw ))
852882DEFINE_UNARY_TILED_TASK (unary_tanh , false, hvx_tanh_f32_aa (dst_vtcm , src_vtcm , tw ))
883+ DEFINE_UNARY_TILED_TASK (unary_abs , false, hvx_abs_f32_aa (dst_vtcm , src_vtcm , tw ))
884+ DEFINE_UNARY_TILED_TASK (unary_log , false, hvx_log_f32_aa (dst_vtcm , src_vtcm , tw ))
853885DEFINE_UNARY_TILED_TASK (tri , true, tri_apply_tile_f32 (src_vtcm , dst_vtcm , tw , col , i01 , ne0 , tri_ttype ))
854886
855887static int execute_op_unary_f32 (struct htp_ops_context * octx ) {
@@ -875,6 +907,8 @@ static int execute_op_unary_f32(struct htp_ops_context * octx) {
875907 case HTP_OP_UNARY_GELU : op_type = "gelu-f32" ; break ;
876908 case HTP_OP_UNARY_SOFTPLUS : op_type = "softplus-f32" ; break ;
877909 case HTP_OP_UNARY_TANH : op_type = "tanh-f32" ; break ;
910+ case HTP_OP_UNARY_ABS : op_type = "abs-f32" ; break ;
911+ case HTP_OP_UNARY_LOG : op_type = "log-f32" ; break ;
878912 case HTP_OP_L2_NORM : op_type = "l2norm-f32" ; break ;
879913 case HTP_OP_TRI : op_type = "tri-f32" ; break ;
880914
@@ -973,6 +1007,8 @@ static int execute_op_unary_f32(struct htp_ops_context * octx) {
9731007 case HTP_OP_UNARY_GELU : task_func = unary_task_f32_tiled_unary_gelu ; break ;
9741008 case HTP_OP_UNARY_SOFTPLUS : task_func = unary_task_f32_tiled_unary_softplus ; break ;
9751009 case HTP_OP_UNARY_TANH : task_func = unary_task_f32_tiled_unary_tanh ; break ;
1010+ case HTP_OP_UNARY_ABS : task_func = unary_task_f32_tiled_unary_abs ; break ;
1011+ case HTP_OP_UNARY_LOG : task_func = unary_task_f32_tiled_unary_log ; break ;
9761012 case HTP_OP_TRI : task_func = unary_task_f32_tiled_tri ; break ;
9771013 default : break ;
9781014 }
@@ -992,6 +1028,8 @@ static int execute_op_unary_f32(struct htp_ops_context * octx) {
9921028 case HTP_OP_UNARY_GELU : task_func = unary_task_f32_unary_gelu ; break ;
9931029 case HTP_OP_UNARY_SOFTPLUS : task_func = unary_task_f32_unary_softplus ; break ;
9941030 case HTP_OP_UNARY_TANH : task_func = unary_task_f32_unary_tanh ; break ;
1031+ case HTP_OP_UNARY_ABS : task_func = unary_task_f32_unary_abs ; break ;
1032+ case HTP_OP_UNARY_LOG : task_func = unary_task_f32_unary_log ; break ;
9951033 case HTP_OP_L2_NORM : task_func = unary_task_f32_l2_norm ; break ;
9961034 case HTP_OP_TRI : task_func = unary_task_f32_tri ; break ;
9971035 default : break ;
0 commit comments