Repository navigation
Support iree-run-mlir to read input values from a file. - #2352
Conversation
GMNGeoffrey
left a comment
There was a problem hiding this comment.
Would love to see this for iree-run-module and iree-benchmark-module also!
| auto file = mlir::openInputFile(filename, &error_message); | ||
| if (!file) { | ||
| return NotFoundErrorBuilder(IREE_LOC) | ||
| << "Unable to open input file " << filename << ": " << error_message; |
There was a problem hiding this comment.
Nit: put filename in quotes
| << "Unable to open input file " << filename << ": " << error_message; | |
| << "Unable to open input file '" << filename << "': " << error_message; |
| return binary_contents; | ||
| } | ||
|
|
||
| // Returns a splitted input values from `filename` using comma as separater. |
There was a problem hiding this comment.
If we're going to be reading from a file anyway, it seems like having these be newline-separated would be better. That would also allow commas in the input tensors themselves
There was a problem hiding this comment.
Yes, it's better. Let's do it. I was thinking to follow the format in iree-run-module.
btw, I'm not sure if it ("\n") is working on Windows... (we could worry about it later?)
| ASSIGN_OR_RETURN(auto* input_list, ParseToVariantList(input_descs, allocator, | ||
| input_values_list)); | ||
| iree_vm_variant_list_t* input_list; | ||
| if (!input_values_file_flag.empty()) { |
There was a problem hiding this comment.
Validation that only one of input_values_file_flag and input_values_flag is set?
| absl::MakeConstSpan(&input_values.front(), | ||
| input_values.size()))); |
There was a problem hiding this comment.
Seems like explicit span creation here shouldn't be necessary. There should be an implicit conversion from vector to const span
There was a problem hiding this comment.
Oh I didn't find it, thanks!
- Use newline as separater - Check only one input option is set
I plan to do it in a later PR! |
| llvm::SmallVector<llvm::StringRef, 8> source_buffers; | ||
| file->getBuffer().split(source_buffers, /*Separator=*/"\n", /*MaxSplit=*/-1, | ||
| /*KeepEmpty=*/false); | ||
| std::vector<std::string> res; |
There was a problem hiding this comment.
res.reserve(source_buffers.size())?
| static llvm::cl::opt<std::string> input_values_file_flag{ | ||
| "input-value-file", | ||
| llvm::cl::desc( | ||
| "<input value file>, see run_module_main.cc for input format"), |
There was a problem hiding this comment.
"Provides a file for input shapes and optional values (see ... for details)" ?
Actually I think we might what to put the format spec in https://google.github.io/iree/DeveloperOverview so we can point to a URL here. Source code is not always there. :)
There was a problem hiding this comment.
Cool, I'll follow on this once all the tools get support of input file.
|
FYI I'm going to add an android presubmit and I think this PR is old enough that it won't have the build config and so will fail. You can ignore an android failure you see on this, or rebase to pick up the config. |
I tried to rebase but it asked me to fix more and more files as expected, like bunch of CMakelists.txt... so I just ignore the failure and merge it. :/ |
* f4f2fec Update Bazel version in docs workflow (#2511) * 19e6574 Add lint action for PR title length (#2481) * 57a9ae3 Moved CompiledModule and BackendInfo to `tf_utils.py` (#2509) * 7d50357 Update Bazel to 3.3.1 (#2496) * afa7d8e [ModelBuilder] Fix leak when using llvm::createLowerMatrixIntrinsicsPass (#2499) * 90ffb71 [ci] Enable build tests for Android cross compilation (#2507) * 62490cb Add Bazel 3.3.1 to docker images (#2497) * 028a883 [ci] Run cmake --build twice to temporary fix the flaky build (#2501) * 8096658 Start creating $async functions as part of public ABI generation. (#2411) * 27a1f3d Removed gather lowering test (#2503) * 02cc1e3 Merge google -> main (#2505) * 6706f3d Add GitHub action to create PRs merging google -> main (#2482) * 645a88b Add buildifier lint action (#2243) * fc812fe Support iree-run-mlir to read input values from a file. (#2352) * 8078fc6 Use iree_py_binary in keras test binaries (#2488) * 9f22404 Treat warnings as errors and silence them in third party code (#2489) * cb000c7 Avoid unused result warning (#2469) * b06a482 Fix some minor typos (#2486) * ce6c171 Create cooperative matrix performance test (#2443) * 0880ee9 Add android build badge to README (#2473) * 8e14d1f [vulkan] Guard against 0-byte buffer allocation (#2467) * ef019df Improve TF submodule bump action descriptions (#2471) * c53ad00 Refactors tf_test_utils, creating tf_utils and simplifying module specificatio.. * a90df48 Merge google -> main (#2468) PiperOrigin-RevId: 321174064
part of #2304