@@ -456,3 +456,62 @@ def test_opdef_func():
456456
457457 with tf .compat .v1 .Session () as sess :
458458 assert sum_tf .eval () == np .r_ [3 ]
459+
460+
461+ @pytest .mark .usefixtures ("run_with_tensorflow" )
462+ @run_in_graph_mode
463+ def test_tensor_ops ():
464+
465+ with tf .Graph ().as_default ():
466+ x_tf = tf .compat .v1 .placeholder ('float' )
467+ y_tf = tf .compat .v1 .placeholder ('float' )
468+
469+ mul_tf = x_tf * y_tf
470+ rmul_tf = 1.0 * x_tf
471+ div_tf = x_tf / y_tf
472+ rdiv_tf = 1.0 / y_tf
473+ add_tf = x_tf + y_tf
474+ radd_tf = 1.0 + y_tf
475+ sub_tf = x_tf - y_tf
476+ rsub_tf = 1.0 - y_tf
477+ pow_tf = x_tf ** y_tf
478+ neg_tf = - x_tf
479+ abs_tf = abs (x_tf )
480+
481+ with tf .Graph ().as_default ():
482+ x_mt = mt .Placeholder ('float' )
483+ y_mt = mt .Placeholder ('float' )
484+
485+ mul_mt = x_mt * y_mt
486+ assert mul_mt .name == mul_tf .name
487+ assert mul_mt .op .type == mul_tf .op .type
488+ rmul_mt = 1.0 * x_mt
489+ assert rmul_mt .name == rmul_tf .name
490+ assert rmul_mt .op .type == rmul_tf .op .type
491+ div_mt = x_mt / y_mt
492+ assert div_mt .name == div_tf .name
493+ assert div_mt .op .type == div_tf .op .type
494+ rdiv_mt = 1.0 / y_mt
495+ assert rdiv_mt .name == rdiv_tf .name
496+ assert rdiv_mt .op .type == rdiv_tf .op .type
497+ add_mt = x_mt + y_mt
498+ assert add_mt .name == add_tf .name
499+ assert add_mt .op .type == add_tf .op .type
500+ radd_mt = 1.0 + y_mt
501+ assert radd_mt .name == radd_tf .name
502+ assert radd_mt .op .type == radd_tf .op .type
503+ sub_mt = x_mt - y_mt
504+ assert sub_mt .name == sub_tf .name
505+ assert sub_mt .op .type == sub_tf .op .type
506+ rsub_mt = 1.0 - y_mt
507+ assert rsub_mt .name == rsub_tf .name
508+ assert rsub_mt .op .type == rsub_tf .op .type
509+ pow_mt = x_mt ** y_mt
510+ assert pow_mt .name == pow_tf .name
511+ assert pow_mt .op .type == pow_tf .op .type
512+ neg_mt = - x_mt
513+ assert neg_mt .name == neg_tf .name
514+ assert neg_mt .op .type == neg_tf .op .type
515+ abs_mt = abs (x_mt )
516+ assert abs_mt .name == abs_tf .name
517+ assert abs_mt .op .type == abs_tf .op .type
0 commit comments