@@ -484,3 +484,51 @@ TEST_F(OpClampTensorOutTest, SmokeTest) {
484
484
op_clamp_tensor_out (in, min, max, out);
485
485
EXPECT_TENSOR_EQ (out, expected);
486
486
}
487
+
488
+ TEST_F (OpClampTensorOutTest, DowncastingSmokeTest) {
489
+ TensorFactory<ScalarType::Byte> tf_in;
490
+ TensorFactory<ScalarType::Short> tf_min;
491
+ TensorFactory<ScalarType::Int> tf_max;
492
+ TensorFactory<ScalarType::Char> tf_out;
493
+
494
+ Tensor in = tf_in.make ({}, {5 });
495
+ Tensor min = tf_min.make ({}, {-129 });
496
+ Tensor max = tf_max.make ({}, {300 });
497
+ Tensor out = tf_out.zeros ({});
498
+ Tensor expected = tf_out.make ({}, {5 });
499
+
500
+ op_clamp_tensor_out (in, min, max, out);
501
+ EXPECT_TENSOR_EQ (out, expected);
502
+ }
503
+
504
+ TEST_F (OpClampTensorOutTest, DowncastingSmokeTest2) {
505
+ TensorFactory<ScalarType::Short> tf_in;
506
+ TensorFactory<ScalarType::Short> tf_min;
507
+ TensorFactory<ScalarType::Int> tf_max;
508
+ TensorFactory<ScalarType::Char> tf_out;
509
+
510
+ Tensor in = tf_in.make ({}, {301 });
511
+ Tensor min = tf_min.make ({}, {-129 });
512
+ Tensor max = tf_max.make ({}, {300 });
513
+ Tensor out = tf_out.zeros ({});
514
+ Tensor expected = tf_out.make ({}, {44 });
515
+
516
+ op_clamp_tensor_out (in, min, max, out);
517
+ EXPECT_TENSOR_EQ (out, expected);
518
+ }
519
+
520
+ TEST_F (OpClampTensorOutTest, DowncastingSmokeTest3) {
521
+ TensorFactory<ScalarType::Short> tf_in;
522
+ TensorFactory<ScalarType::Short> tf_min;
523
+ TensorFactory<ScalarType::Int> tf_max;
524
+ TensorFactory<ScalarType::Char> tf_out;
525
+
526
+ Tensor in = tf_in.make ({}, {45 });
527
+ Tensor min = tf_min.make ({}, {-129 });
528
+ Tensor max = tf_max.make ({}, {300 });
529
+ Tensor out = tf_out.zeros ({});
530
+ Tensor expected = tf_out.make ({}, {45 });
531
+
532
+ op_clamp_tensor_out (in, min, max, out);
533
+ EXPECT_TENSOR_EQ (out, expected);
534
+ }
0 commit comments