Skip to content

Commit

Permalink
Merge pull request #46804 from Oceania2018:master
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 364462308
Change-Id: I943a37112d69eb3d3fba798e230efd1791467f3f
  • Loading branch information
tensorflower-gardener committed Mar 23, 2021
2 parents cbdf80e + 8c69220 commit 82c4ebc
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tensorflow/c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,19 @@ tf_cuda_library(
"tf_file_statistics.h",
"tf_status.h",
"tf_tensor.h",
"tf_tstring.h",
],
copts = tf_copts(),
visibility = ["//visibility:public"],
deps = [
"//tensorflow/core/platform:tstring",
":c_api_no_xla",
":c_api_internal",
":tf_attrtype",
":tf_status_internal",
":tf_file_statistics",
":tf_tensor_internal",
":tf_tstring",
] + select({
"//tensorflow:with_xla_support": [
"//tensorflow/compiler/tf2xla:xla_compiler",
Expand Down Expand Up @@ -314,6 +317,24 @@ cc_library(
visibility = ["//visibility:public"],
)

cc_library(
name = "tf_tstring",
srcs = [
"tf_tstring.cc",
],
hdrs = [
"c_api_macros.h",
"tf_datatype.h",
"tf_status.h",
"tf_tensor.h",
"tf_tstring.h",
],
visibility = ["//visibility:public"],
deps = [
"//tensorflow/core/platform:tstring",
],
)

cc_library(
name = "tf_file_statistics",
hdrs = ["tf_file_statistics.h"],
Expand Down
47 changes: 47 additions & 0 deletions tensorflow/c/tf_tstring.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright 2021 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

#include "tensorflow/c/tf_tstring.h"

#include "tensorflow/c/tf_tensor.h"
#include "tensorflow/core/platform/ctstring_internal.h"

void TF_StringInit(TF_TString *tstr) { TF_TString_Init(tstr); }

void TF_StringCopy(TF_TString *dst, const char *src, size_t size) {
TF_TString_Copy(dst, src, size);
}

void TF_StringAssignView(TF_TString *dst, const char *src, size_t size) {
TF_TString_AssignView(dst, src, size);
}

const char *TF_StringGetDataPointer(const TF_TString *tstr) {
return TF_TString_GetDataPointer(tstr);
}

TF_TString_Type TF_StringGetType(const TF_TString *str) {
return TF_TString_GetType(str);
}

size_t TF_StringGetSize(const TF_TString *tstr) {
return TF_TString_GetSize(tstr);
}

size_t TF_StringGetCapacity(const TF_TString *str) {
return TF_TString_GetCapacity(str);
}

void TF_StringDealloc(TF_TString *tstr) { TF_TString_Dealloc(tstr); }
42 changes: 42 additions & 0 deletions tensorflow/c/tf_tstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,48 @@ limitations under the License.
#ifndef TENSORFLOW_C_TF_TSTRING_H_
#define TENSORFLOW_C_TF_TSTRING_H_

#include "tensorflow/c/tf_tensor.h"
#include "tensorflow/core/platform/ctstring.h"

#ifdef SWIG
#define TF_CAPI_EXPORT
#else
#if defined(_WIN32)
#ifdef TF_COMPILE_LIBRARY
#define TF_CAPI_EXPORT __declspec(dllexport)
#else
#define TF_CAPI_EXPORT __declspec(dllimport)
#endif // TF_COMPILE_LIBRARY
#else
#define TF_CAPI_EXPORT __attribute__((visibility("default")))
#endif // _WIN32
#endif // SWIG

#ifdef __cplusplus
extern "C" {
#endif

TF_CAPI_EXPORT extern void TF_StringInit(TF_TString *t);

TF_CAPI_EXPORT extern void TF_StringCopy(TF_TString *dst, const char *src,
size_t size);

TF_CAPI_EXPORT extern void TF_StringAssignView(TF_TString *dst, const char *src,
size_t size);

TF_CAPI_EXPORT extern const char *TF_StringGetDataPointer(
const TF_TString *tstr);

TF_CAPI_EXPORT extern TF_TString_Type TF_StringGetType(const TF_TString *str);

TF_CAPI_EXPORT extern size_t TF_StringGetSize(const TF_TString *tstr);

TF_CAPI_EXPORT extern size_t TF_StringGetCapacity(const TF_TString *str);

TF_CAPI_EXPORT extern void TF_StringDealloc(TF_TString *tstr);

#ifdef __cplusplus
} /* end extern "C" */
#endif

#endif // THIRD_PARTY_TENSORFLOW_C_TF_TSTRING_H_

0 comments on commit 82c4ebc

Please sign in to comment.