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

Function CreateTempFile

tensorflow/core/kernels/immutable_constant_op_test.cc:145–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145Status CreateTempFile(Env* env, float value, uint64 size, string* filename) {
146 const string dir = testing::TmpDir();
147 *filename = io::JoinPath(dir, strings::StrCat("file_", value));
148 std::unique_ptr<WritableFile> file;
149 TF_RETURN_IF_ERROR(env->NewWritableFile(*filename, &file));
150 for (uint64 i = 0; i < size; ++i) {
151 StringPiece sp(static_cast<char*>(static_cast<void*>(&value)),
152 sizeof(value));
153 TF_RETURN_IF_ERROR(file->Append(sp));
154 }
155 TF_RETURN_IF_ERROR(file->Close());
156 return Status::OK();
157}
158
159TEST(ImmutableConstantOpTest, FromFile) {
160 const TensorShape kFileTensorShape({1000, 1});

Callers 1

TESTFunction · 0.85

Calls 6

TmpDirFunction · 0.85
JoinPathFunction · 0.50
StrCatFunction · 0.50
NewWritableFileMethod · 0.45
AppendMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected