MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / FillTensorWithTfLiteHexString

Function FillTensorWithTfLiteHexString

tensorflow/lite/testing/tf_driver.cc:56–71  ·  view source on GitHub ↗

Assumes 'values_as_string' is a hex string that gets converted into a TF Lite DynamicBuffer. Strings are then extracted and copied into the TensorFlow tensor.

Source from the content-addressed store, hash-verified

54// TF Lite DynamicBuffer. Strings are then extracted and copied into the
55// TensorFlow tensor.
56int FillTensorWithTfLiteHexString(tensorflow::Tensor* tensor,
57 const string& values_as_string) {
58 string s = absl::HexStringToBytes(values_as_string);
59
60 int num_strings = values_as_string.empty() ? 0 : GetStringCount(s.data());
61
62 if (num_strings == tensor->NumElements()) {
63 auto data = tensor->flat<tensorflow::tstring>();
64 for (size_t i = 0; i < num_strings; ++i) {
65 auto ref = GetString(s.data(), i);
66 data(i).assign(ref.str, ref.len);
67 }
68 }
69
70 return num_strings;
71}
72
73template <typename T>
74void FillTensorWithZeros(tensorflow::Tensor* tensor) {

Callers 1

SetInputMethod · 0.85

Calls 7

GetStringCountFunction · 0.85
GetStringFunction · 0.85
dataFunction · 0.50
emptyMethod · 0.45
dataMethod · 0.45
NumElementsMethod · 0.45
assignMethod · 0.45

Tested by

no test coverage detected