Skip to content

Commit

Permalink
#tf-data implements string type AddScalar
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 631965339
  • Loading branch information
jimlinntu authored and tensorflower-gardener committed May 16, 2024
1 parent 62abb36 commit 39dbb1f
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tensorflow/core/framework/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,16 @@ class GraphDefBuilderWrapper {
return OkStatus();
}

absl::Status AddScalar(const std::string& val, Node** output) {
Tensor val_t = Tensor(DataTypeToEnum<tstring>::v(), TensorShape({}));
val_t.scalar<tstring>()() = val;
AddTensorInternal(val_t, output);
if (*output == nullptr) {
return absl::InternalError("AddScalar: Failed to build Const op.");
}
return absl::OkStatus();
}

// Adds a Const node with vector value to the Graph.
// `*output` contains a pointer to the output `Node`. It is guaranteed to be
// non-null if the method returns with an OK status.
Expand Down

0 comments on commit 39dbb1f

Please sign in to comment.