tensorflow/c/experimental/saved_model/core/ops/restore_ops.cc
// Creates a Rank 1 string tensorhandle containing a single string `s`
Creates a Rank 1 string tensorhandle containing a single string `s`
Creates a Rank 1 string tensorhandle containing a single string ` s `
Status CreateStringVectorTensorHandle(ImmediateExecutionContext* ctx,
                                      const std::string& s,
                                      ImmediateTensorHandlePtr* out) {
  int64_t flat_shape[] = {1};
  AbstractTensorPtr tensor(ctx->CreateTensor(DT_STRING, flat_shape));
  if (tensor.get() == nullptr) {
    return errors::Internal(
        "Failed to create vector string tensor for checkpoint restore");
  }
  new (tensor->Data()) tstring(s);
  out->reset(ctx->CreateLocalHandle(tensor.get()));
  return Status();
}
Status CreateStringVectorTensorHandle ( ImmediateExecutionContext * ctx , const std :: string & s , ImmediateTensorHandlePtr * out ) { int64_t flat_shape [ ] = { 1 } ; AbstractTensorPtr tensor ( ctx -> CreateTensor ( DT_STRING , flat_shape ) ) ; if ( tensor . get ( ) == nullptr ) { return errors :: Internal ( " " ) ; } new ( tensor -> Data ( ) ) tstring ( s ) ; out -> reset ( ctx -> CreateLocalHandle ( tensor . get ( ) ) ) ; return Status ( ) ; }
Creates a Rank 1 string tensorhandle containing a single string `s`
Creates a Rank 1 string tensorhandle containing a single string ` s `
// Use placement new to construct the string, since we don't have // access to Tensor::flat. This is conceptually equivalent to: // tensor.flat<tstring>()(0) = s