Skip to content

Support iree-run-mlir to read input values from a file. - #2352

Merged
hanhanW merged 4 commits into
iree-org:mainfrom
hanhanW:read-from-file
Jul 13, 2020
Merged

hanhanW merged 4 commits into
iree-org:mainfrom
hanhanW:read-from-file

Conversation

@hanhanW

@hanhanW hanhanW commented Jun 29, 2020

Copy link
Copy Markdown
Contributor

part of #2304

Comment thread iree/tools/run_mlir_main.cc Resolved

@GMNGeoffrey GMNGeoffrey left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would love to see this for iree-run-module and iree-benchmark-module also!

Comment thread iree/tools/run_mlir_main.cc Outdated
auto file = mlir::openInputFile(filename, &error_message);
if (!file) {
return NotFoundErrorBuilder(IREE_LOC)
<< "Unable to open input file " << filename << ": " << error_message;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: put filename in quotes

Suggested change
<< "Unable to open input file " << filename << ": " << error_message;
<< "Unable to open input file '" << filename << "': " << error_message;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread iree/tools/run_mlir_main.cc Outdated
return binary_contents;
}

// Returns a splitted input values from `filename` using comma as separater.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validation that only one of input_values_file_flag and input_values_flag is set?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread iree/tools/run_mlir_main.cc Outdated
Comment on lines +297 to +298
absl::MakeConstSpan(&input_values.front(),
input_values.size())));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like explicit span creation here shouldn't be necessary. There should be an implicit conversion from vector to const span

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I didn't find it, thanks!

- Use newline as separater
- Check only one input option is set
@hanhanW

hanhanW commented Jul 1, 2020

Copy link
Copy Markdown
Contributor Author

Would love to see this for iree-run-module and iree-benchmark-module also!

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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

res.reserve(source_buffers.size())?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment thread iree/tools/run_mlir_main.cc Outdated
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"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"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. :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'll follow on this once all the tools get support of input file.

@GMNGeoffrey

Copy link
Copy Markdown
Member

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.

@hanhanW
hanhanW merged commit fc812fe into iree-org:main Jul 13, 2020
@hanhanW

hanhanW commented Jul 13, 2020

Copy link
Copy Markdown
Contributor Author

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. :/

@hanhanW
hanhanW deleted the read-from-file branch July 13, 2020 17:20
This was referenced Jul 13, 2020
copybara-service Bot pushed a commit that referenced this pull request Jul 14, 2020
* 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
@copybara-service copybara-service Bot mentioned this pull request Jul 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants