@@ -767,34 +767,16 @@ def perform(self, node, inputs, output_storage):
767
767
for i , (variable , storage , nout ) in enumerate (
768
768
zip (variables , output_storage , node .outputs )
769
769
):
770
- if getattr (variable , "dtype" , "" ) == "object" :
771
- # Since numpy 1.6, function created with numpy.frompyfunc
772
- # always return an ndarray with dtype object
773
- variable = np .asarray (variable , dtype = nout .dtype )
770
+ storage [0 ] = variable = np .asarray (variable , dtype = nout .dtype )
774
771
775
772
if i in self .inplace_pattern :
776
773
odat = inputs [self .inplace_pattern [i ]]
777
774
odat [...] = variable
778
775
storage [0 ] = odat
779
776
780
- # Sometimes NumPy return a Python type.
781
- # Some PyTensor op return a different dtype like floor, ceil,
782
- # trunc, eq, ...
783
- elif not isinstance (variable , np .ndarray ) or variable .dtype != nout .dtype :
784
- variable = np .asarray (variable , nout .dtype )
785
- # The next line is needed for numpy 1.9. Otherwise
786
- # there are tests that fail in DebugMode.
787
- # Normally we would call pytensor.misc._asarray, but it
788
- # is faster to inline the code. We know that the dtype
789
- # are the same string, just different typenum.
790
- if np .dtype (nout .dtype ).num != variable .dtype .num :
791
- variable = variable .view (dtype = nout .dtype )
792
- storage [0 ] = variable
793
777
# numpy.real return a view!
794
- elif not variable .flags .owndata :
778
+ if not variable .flags .owndata :
795
779
storage [0 ] = variable .copy ()
796
- else :
797
- storage [0 ] = variable
798
780
799
781
@staticmethod
800
782
def _check_runtime_broadcast (node , inputs ):
0 commit comments