in core/maxframe/tensor/arithmetic/core.py [0:0]
def _call(self, x, out1=None, out2=None, out=None, where=None):
dtype = [r.dtype for r in self._fun(np.empty(1, dtype=x.dtype))]
out = out or (None, None)
out1 = out1 or out[0]
out2 = out2 or out[1]
x, out1, out2, where = self._process_inputs(x, out1, out2, where)
shape = x.shape
order1 = self._calc_order(x, out1)
order2 = self._calc_order(x, out2)
inputs = filter_inputs([x, out1, out2, where])
t1, t2 = self.new_tensors(
inputs,
shape,
kws=[
{"order": order1, "dtype": dtype[0], "side": "left"},
{"order": order2, "dtype": dtype[1], "side": "right"},
],
)
if out1 is None and out2 is None:
return ExecutableTuple([t1, t2])
if out1 is not None:
check_out_param(out1, t1, self.casting)
out1_shape, out1_dtype = out1.shape, out1.dtype
else:
out1_shape, out1_dtype = t1.shape, t1.dtype
if out2 is not None:
check_out_param(out2, t2, self.casting)
out2_shape, out2_dtype = out2.shape, out2.dtype
else:
out2_shape, out2_dtype = t2.shape, t2.dtype
# if `out` is specified, use out's dtype and shape
if t1.shape != out1_shape or t2.shape != out2_shape:
t1, t2 = self.new_tensor(
inputs,
[out1_shape, out2_shape],
kws=[
{"order": order1, "dtype": out1_dtype},
{"order": order2, "dtype": out2_dtype},
],
)
if out1 is not None:
out1.data = t1.data
else:
out1 = t1
if out2 is not None:
out2.data = t2.data
else:
out2 = t2
return ExecutableTuple([out1, out2])