tensorflow/core/grappler/optimizers/arithmetic_optimizer.cc
// GetElementUnexhaustive tries to get the value of an element in a tensor and
// turn it into complex128 type. It only check for a limited number of data
// types, so it's unexhaustive.
GetElementUnexhaustive tries to get the value of an element in a tensor and
turn it into complex128 type. It only check for a limited number of data
types, so it's unexhaustive.
GetElementUnexhaustive tries to get the value of an element in a tensor and turn it into complex128 type . It only check for a limited number of data types so it ' s unexhaustive .
bool GetElementUnexhaustive(const Tensor& t, int i, const std::set<int>& dtypes,
                            complex128* element) {
  if (dtypes.find(t.dtype()) == dtypes.end()) return false;
  switch (t.dtype()) {
    case DT_BFLOAT16:
      *element = complex128(t.flat<bfloat16>()(i));
      return true;
    case DT_HALF:
      *element = complex128(static_cast<double>(t.flat<Eigen::half>()(i)), 0);
      return true;
    case DT_INT32:
      *element = complex128(t.flat<int32>()(i));
      return true;
    case DT_INT64:
      *element = complex128(t.flat<int64_t>()(i));
      return true;
    case DT_FLOAT:
      *element = complex128(t.flat<float>()(i));
      return true;
    case DT_DOUBLE:
      *element = complex128(t.flat<double>()(i));
      return true;
    case DT_COMPLEX64:
      *element = complex128(t.flat<complex64>()(i));
      return true;
    case DT_COMPLEX128:
      *element = t.flat<complex128>()(i);
      return true;
    default:
      return false;
  }
}
bool GetElementUnexhaustive ( const Tensor & t , int i , const std :: set < int > & dtypes , complex128 * element ) { if ( dtypes . find ( t . dtype ( ) ) == dtypes . end ( ) ) return false ; switch ( t . dtype ( ) ) { case DT_BFLOAT16 : * element = complex128 ( t . flat < bfloat16 > ( ) ( i ) ) ; return true ; case DT_HALF : * element = complex128 ( static_cast < double > ( t . flat < Eigen :: half > ( ) ( i ) ) , 0 ) ; return true ; case DT_INT32 : * element = complex128 ( t . flat < int32 > ( ) ( i ) ) ; return true ; case DT_INT64 : * element = complex128 ( t . flat < int64_t > ( ) ( i ) ) ; return true ; case DT_FLOAT : * element = complex128 ( t . flat < float > ( ) ( i ) ) ; return true ; case DT_DOUBLE : * element = complex128 ( t . flat < double > ( ) ( i ) ) ; return true ; case DT_COMPLEX64 : * element = complex128 ( t . flat < complex64 > ( ) ( i ) ) ; return true ; case DT_COMPLEX128 : * element = t . flat < complex128 > ( ) ( i ) ; return true ; default : return false ; } }
GetElementUnexhaustive tries to get the value of an element in a tensor and
turn it into complex128 type.
GetElementUnexhaustive tries to get the value of an element in a tensor and turn it into complex128 type .