tensorflow/core/common_runtime/eval_const_tensor.cc
// Returns the int value corresponding to the input src at the i'th edge if the
// input src contains a scalar tensor.
Returns the int value corresponding to the input src at the i'th edge if the
input src contains a scalar tensor.
Returns the int value corresponding to the input src at the i ' th edge if the input src contains a scalar tensor .
Status EvaluateConstantIntFromScalarEdge(const Node& node, int input_idx,
                                         int64* output, bool* success) {
  *success = false;
  Tensor scalar;
  const Edge* edge;
  TF_RETURN_IF_ERROR(node.input_edge(input_idx, &edge));
  TF_RETURN_IF_ERROR(EvaluateConstantNode(*edge->src(), &scalar, success));
  if (success && scalar.NumElements() == 1) {
    if (scalar.dtype() == DT_INT32) {
      *output = scalar.scalar<int32>()();
    } else if (scalar.dtype() == DT_INT64) {
      *output = scalar.scalar<int64_t>()();
    } else {
      *success = false;
    }
  }
  return Status::OK();
}
Status EvaluateConstantIntFromScalarEdge ( const Node & node , int input_idx , int64 * output , bool * success ) { * success = false ; Tensor scalar ; const Edge * edge ; TF_RETURN_IF_ERROR ( node . input_edge ( input_idx , & edge ) ) ; TF_RETURN_IF_ERROR ( EvaluateConstantNode ( * edge -> src ( ) , & scalar , success ) ) ; if ( success && scalar . NumElements ( ) == 1 ) { if ( scalar . dtype ( ) == DT_INT32 ) { * output = scalar . scalar < int32 > ( ) ( ) ; } else if ( scalar . dtype ( ) == DT_INT64 ) { * output = scalar . scalar < int64_t > ( ) ( ) ; } else { * success = false ; } } return Status :: OK ( ) ; }
Returns the int value corresponding to the input src at the i'th edge if the
input src contains a scalar tensor.
Returns the int value corresponding to the input src at the i ' th edge if the input src contains a scalar tensor .