@@ -44,7 +44,7 @@ template <typename Functor>
4444struct UnaryFunctor <SYCLDevice, Functor> {
4545 void operator ()(const SYCLDevice& d, typename Functor::tout_type out,
4646 typename Functor::tin_type in) {
47- LOG ( FATAL ) << " UnaryFunctor::operator() NOT IMPLEMENTED ! " ;
47+ To32Bit (out). device (d) = To32Bit (in). unaryExpr ( typename Functor::func ()) ;
4848 }
4949};
5050
@@ -54,19 +54,21 @@ struct BinaryFunctor<SYCLDevice, Functor, NDIMS, has_errors> {
5454 void operator ()(const SYCLDevice& d, typename Functor::tout_type out,
5555 typename Functor::tin_type in0,
5656 typename Functor::tin_type in1, bool * error) {
57- Assign (d, out, in0.binaryExpr (in1, typename Functor::func () ));
57+ To32Bit (out). device (d) = To32Bit ( in0) .binaryExpr (in1, typename Functor::func ());
5858 }
5959
6060 void Left (const SYCLDevice& d, typename Functor::tout_type out,
6161 typename Functor::tscalar_type scalar,
6262 typename Functor::tin_type in, bool * error) {
63- LOG (FATAL ) << " BinaryFunctor::Left NOT IMPLEMENTED ! " ;
63+ typedef typename Functor::func Binary;
64+ To32Bit (out).device (d) = To32Bit (in).binaryExpr (typename Functor::tin_type (scalar.data (),in.dimensions ()), Binary ());
6465 }
6566
6667 void Right (const SYCLDevice& d, typename Functor::tout_type out,
6768 typename Functor::tin_type in,
6869 typename Functor::tscalar_type scalar, bool * error) {
69- LOG (FATAL ) << " BinaryFunctor::Right NOT IMPLEMENTED ! " ;
70+ typedef typename Functor::func Binary;
71+ To32Bit (out).device (d) = To32Bit (in).binaryExpr (typename Functor::tin_type (scalar.data (),in.dimensions ()), Binary ());
7072 }
7173
7274 void BCast (const SYCLDevice& d,
@@ -76,7 +78,25 @@ struct BinaryFunctor<SYCLDevice, Functor, NDIMS, has_errors> {
7678 typename TTypes<typename Functor::in_type, NDIMS >::ConstTensor in1,
7779 typename Eigen::array<Eigen::DenseIndex, NDIMS > bcast1,
7880 bool * error) {
79- LOG (FATAL ) << " BinaryFunctor::BCast NOT IMPLEMENTED " ;
81+ typedef typename Functor::in_type T;
82+ typename Functor::func func;
83+ if ((NDIMS == 2 ) && Functor::use_bcast_optimization &&
84+ use_bcast_optimization<T>::value) {
85+ const bool bcast0_all_one = AllOne<NDIMS >(bcast0);
86+ const bool bcast1_all_one = AllOne<NDIMS >(bcast1);
87+ if (bcast0_all_one && !bcast1_all_one) {
88+ To32Bit (out).device (d) =
89+ To32Bit (in0).binaryExpr (To32Bit (in1).broadcast (bcast1), func);
90+ return ;
91+ }
92+ if (!bcast0_all_one && bcast1_all_one) {
93+ To32Bit (out).device (d) =
94+ To32Bit (in0).broadcast (bcast0).binaryExpr (To32Bit (in1), func);
95+ return ;
96+ }
97+ }
98+ To32Bit (out).device (d) = To32Bit (in0).broadcast (bcast0).binaryExpr (
99+ To32Bit (in1).broadcast (bcast1), func);
80100 }
81101};
82102
0 commit comments