@@ -625,6 +625,52 @@ def test_qnn_backend_cumsum(self):
625625 index += 1
626626 self .lower_module_and_test_output (module , sample_input )
627627
628+ def test_qnn_backend_div_mode (self ):
629+ test_comb = [
630+ {
631+ QCOM_MODULE : [
632+ DivMode (rounding_mode = None ), # noqa: F405
633+ DivMode (rounding_mode = "trunc" ), # noqa: F405
634+ DivMode (rounding_mode = "floor" ), # noqa: F405
635+ ],
636+ QCOM_SAMPLE_INPUTS : [
637+ (
638+ torch .tensor ([7.0 , 5.0 , - 3.0 , 8.0 , 1.0 , 9.0 ]).reshape (2 , 3 ),
639+ torch .tensor ([2.0 , 3.0 , 2.0 , 5.0 , 4.0 , 2.0 ]).reshape (2 , 3 ),
640+ ),
641+ ],
642+ },
643+ ]
644+
645+ index = 0
646+ for comb in test_comb :
647+ for module in comb [QCOM_MODULE ]:
648+ for sample_input in comb [QCOM_SAMPLE_INPUTS ]:
649+ with self .subTest (i = index ):
650+ index += 1
651+ self .lower_module_and_test_output (module , sample_input )
652+
653+ def test_qnn_backend_div_scalar_mode (self ):
654+ test_comb = [
655+ {
656+ QCOM_MODULE : [
657+ DivScalarMode (scalar = 2.0 , rounding_mode = "trunc" ), # noqa: F405
658+ DivScalarMode (scalar = 3.0 , rounding_mode = "floor" ), # noqa: F405
659+ ],
660+ QCOM_SAMPLE_INPUTS : [
661+ (torch .tensor ([7.0 , 5.0 , - 3.0 , 8.0 , 1.0 , 9.0 ]).reshape (2 , 3 ),),
662+ ],
663+ },
664+ ]
665+
666+ index = 0
667+ for comb in test_comb :
668+ for module in comb [QCOM_MODULE ]:
669+ for sample_input in comb [QCOM_SAMPLE_INPUTS ]:
670+ with self .subTest (i = index ):
671+ index += 1
672+ self .lower_module_and_test_output (module , sample_input )
673+
628674 def test_qnn_backend_einsum_outer_product (self ):
629675 module = EinsumOuterProduct () # noqa: F405
630676 x = torch .randn (5 )
@@ -3346,6 +3392,54 @@ def test_qnn_backend_cumsum(self):
33463392 module = self .get_qdq_module (module , sample_input )
33473393 self .lower_module_and_test_output (module , sample_input )
33483394
3395+ def test_qnn_backend_div_mode (self ):
3396+ test_comb = [
3397+ {
3398+ QCOM_MODULE : [
3399+ DivMode (rounding_mode = None ), # noqa: F405
3400+ DivMode (rounding_mode = "trunc" ), # noqa: F405
3401+ DivMode (rounding_mode = "floor" ), # noqa: F405
3402+ ],
3403+ QCOM_SAMPLE_INPUTS : [
3404+ (
3405+ torch .tensor ([7.0 , 5.0 , - 3.0 , 8.0 , 1.0 , 9.0 ]).reshape (2 , 3 ),
3406+ torch .tensor ([2.0 , 3.0 , 2.0 , 5.0 , 4.0 , 2.0 ]).reshape (2 , 3 ),
3407+ ),
3408+ ],
3409+ },
3410+ ]
3411+
3412+ index = 0
3413+ for comb in test_comb :
3414+ for module in comb [QCOM_MODULE ]:
3415+ for sample_input in comb [QCOM_SAMPLE_INPUTS ]:
3416+ with self .subTest (i = index ):
3417+ index += 1
3418+ qdq_module = self .get_qdq_module (module , sample_input )
3419+ self .lower_module_and_test_output (qdq_module , sample_input )
3420+
3421+ def test_qnn_backend_div_scalar_mode (self ):
3422+ test_comb = [
3423+ {
3424+ QCOM_MODULE : [
3425+ DivScalarMode (scalar = 2.0 , rounding_mode = "trunc" ), # noqa: F405
3426+ DivScalarMode (scalar = 3.0 , rounding_mode = "floor" ), # noqa: F405
3427+ ],
3428+ QCOM_SAMPLE_INPUTS : [
3429+ (torch .tensor ([7.0 , 5.0 , - 3.0 , 8.0 , 1.0 , 9.0 ]).reshape (2 , 3 ),),
3430+ ],
3431+ },
3432+ ]
3433+
3434+ index = 0
3435+ for comb in test_comb :
3436+ for module in comb [QCOM_MODULE ]:
3437+ for sample_input in comb [QCOM_SAMPLE_INPUTS ]:
3438+ with self .subTest (i = index ):
3439+ index += 1
3440+ qdq_module = self .get_qdq_module (module , sample_input )
3441+ self .lower_module_and_test_output (qdq_module , sample_input )
3442+
33493443 def test_qnn_backend_einsum_outer_product (self ):
33503444 module = EinsumOuterProduct () # noqa: F405
33513445 x = torch .randn (5 )
0 commit comments