@@ -105,8 +105,8 @@ Tensor& float_power_out(Tensor& result, const Tensor& base, Scalar exp) {
105105
106106 // Note: need the casts inside the ternary because conversion functions return e.g. c10::complex,
107107 // which causes a complex scalar to always be returned.
108- exp = (dtype == at::kComplexDouble ) ? Scalar (exp.toComplexDouble ()) : Scalar (exp.toDouble ());
109- return at::pow_out (result, base.to (dtype), exp );
108+ auto casted_exp = (dtype == at::kComplexDouble ) ? Scalar (exp.toComplexDouble ()) : Scalar (exp.toDouble ());
109+ return at::pow_out (result, base.to (dtype), casted_exp );
110110}
111111
112112Tensor& float_power_out (Tensor& result, Scalar base, const Tensor& exp) {
@@ -115,20 +115,20 @@ Tensor& float_power_out(Tensor& result, Scalar base, const Tensor& exp) {
115115 " the output given to float_power has dtype " , result.scalar_type (),
116116 " but the operation's result requires dtype " , dtype);
117117
118- base = (dtype == at::kComplexDouble ) ? Scalar (base.toComplexDouble ()) : Scalar (base.toDouble ());
119- return at::pow_out (result, base , exp.to (dtype));
118+ auto casted_base = (dtype == at::kComplexDouble ) ? Scalar (base.toComplexDouble ()) : Scalar (base.toDouble ());
119+ return at::pow_out (result, casted_base , exp.to (dtype));
120120}
121121
122122Tensor float_power (const Tensor& base, Scalar exp) {
123123 auto dtype = (at::isComplexType (base.scalar_type ()) || exp.isComplex ()) ? at::kComplexDouble : at::kDouble ;
124- exp = (dtype == at::kComplexDouble ) ? Scalar (exp.toComplexDouble ()) : Scalar (exp.toDouble ());
125- return at::pow (base.to (dtype), exp );
124+ auto casted_exp = (dtype == at::kComplexDouble ) ? Scalar (exp.toComplexDouble ()) : Scalar (exp.toDouble ());
125+ return at::pow (base.to (dtype), casted_exp );
126126}
127127
128128Tensor float_power (Scalar base, const Tensor& exp) {
129129 auto dtype = (at::isComplexType (exp.scalar_type ()) || base.isComplex ()) ? at::kComplexDouble : at::kDouble ;
130- base = (dtype == at::kComplexDouble ) ? Scalar (base.toComplexDouble ()) : Scalar (base.toDouble ());
131- return at::pow (base , exp.to (dtype));
130+ auto casted_base = (dtype == at::kComplexDouble ) ? Scalar (base.toComplexDouble ()) : Scalar (base.toDouble ());
131+ return at::pow (casted_base , exp.to (dtype));
132132}
133133
134134Tensor float_power (const Tensor& base, const Tensor& exp) {
@@ -151,8 +151,8 @@ Tensor& float_power_(Tensor& base, Scalar exp) {
151151 " the base given to float_power_ has dtype " , base.scalar_type (),
152152 " but the operation's result requires dtype " , dtype);
153153
154- exp = (dtype == at::kComplexDouble ) ? Scalar (exp.toComplexDouble ()) : Scalar (exp.toDouble ());
155- return base.pow_ (exp );
154+ auto casted_exp = (dtype == at::kComplexDouble ) ? Scalar (exp.toComplexDouble ()) : Scalar (exp.toDouble ());
155+ return base.pow_ (casted_exp );
156156}
157157
158158} // namespace native
0 commit comments