Skip to content

Commit 31343cb

Browse files
author
Vijay Vasudevan
committed
TensorFlow: add __pow__ python overload operator.
Change: 112175414
1 parent 63f9b3e commit 31343cb

3 files changed

Lines changed: 5 additions & 0 deletions

File tree

‎tensorflow/python/framework/ops.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ class Tensor(object):
192192
"__xor__",
193193
"__rxor__",
194194
"__getitem__",
195+
"__pow__",
196+
"__rpow__",
195197
# Unary.
196198
"__invert__",
197199
"__neg__",

‎tensorflow/python/kernel_tests/cwise_ops_test.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
_ADD = lambda x, y: x + y
3131
_SUB = lambda x, y: x - y
3232
_MUL = lambda x, y: x * y
33+
_POW = lambda x, y: x ** y
3334
_TRUEDIV = lambda x, y: x / y
3435
_FLOORDIV = lambda x, y: x // y
3536
_MOD = lambda x, y: x % y
@@ -1059,6 +1060,7 @@ def testOverload(self):
10591060
(np.add, _ADD),
10601061
(np.subtract, _SUB),
10611062
(np.multiply, _MUL),
1063+
(np.power, _POW),
10621064
(np.true_divide, _TRUEDIV),
10631065
(np.floor_divide, _FLOORDIV),
10641066
]

‎tensorflow/python/ops/math_ops.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,7 @@ def floordiv(x, y, name=None):
544544
_OverrideBinaryOperatorHelper(truediv, "truediv")
545545
_OverrideBinaryOperatorHelper(floordiv, "floordiv")
546546
_OverrideBinaryOperatorHelper(mod, "mod")
547+
_OverrideBinaryOperatorHelper(pow, "pow")
547548

548549

549550
def logical_xor(x, y, name="LogicalXor"):

0 commit comments

Comments
 (0)