| 143 | } |
| 144 | |
| 145 | Status 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 | |
| 159 | TEST(ImmutableConstantOpTest, FromFile) { |
| 160 | const TensorShape kFileTensorShape({1000, 1}); |