Skip to content

Use separate Bazel invocation for TF integration binaries - #4836

Merged
GMNGeoffrey merged 20 commits into
iree-org:mainfrom
GMNGeoffrey:import-tf-binaries
Feb 26, 2021
Merged

GMNGeoffrey merged 20 commits into
iree-org:mainfrom
GMNGeoffrey:import-tf-binaries

Conversation

@GMNGeoffrey

@GMNGeoffrey GMNGeoffrey commented Feb 12, 2021 •

Copy link
Copy Markdown
Member

Rather than having CMake invoke Bazel itself, require that the
necessary binaries be built prior to running CMake and then import
them.

This is similar to what #4584 did
in the Android build and has similar advantages: the user can get these
binaries in a variety of ways: building with their chosen config (e.g.
with local or remote caching), installing prebuilt binaries, etc.

It also is significantly more clear what's going on IMO. Having CMake
invoke Bazel has caused a fair amount of confusion.

Incidentally, I'm pretty sure this increases test coverage by enabling
TF tests that were apparently not getting run.

Tested:
In addition to the CI, ran all the release distribution commands
locally and confirmed they still exited successfully.

@google-cla google-cla Bot added the cla: yes label Feb 12, 2021
Comment on lines +208 to +221
process = subprocess.run(["bazel", "info", "bazel-bin"],
cwd=TF_INTEGRATIONS_DIR,
check=True,
capture_output=True,
universal_newlines=True)
if len(process.stdout.splitlines()) != 1:
raise RuntimeError(
f"Unexpected output from `bazel info bazel-bin`:\n{process.stdout}")
bazel_bin_dir = process.stdout.strip()
if not os.path.isdir(bazel_bin_dir):
raise RuntimeError(
f"`bazel info bazel-bin` '{bazel_bin_dir}' is not a directory")

return bazel_bin_dir

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.

Can you document this (either through variable naming or comments) a bit more?

  • I'm not sure why bazel_build_tf_binary(target) is returning a directory path
  • process could be renamed to info_process or something similarly descriptive, considering there is another subprocess.run() call in this function that does something different

You could also split this into two functions - one for bazel build and one for bazel info bazel-bin

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah you're right this is not great. I needed to call it always in the same place and from the same working directory so I merged them into one function. I'll rework it

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok I made the function just return the path to the binary it just built, which seems like a much more reasonable thing for it to do. Of course, this totally reasonable thing is not well supported in Bazel, but 🙄

"${BAZEL_CMD[@]?}" build --config=generic_clang //iree_tf_compiler:all
popd

CMAKE_BUILD_DIR="$HOME/iree/build/tf"

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.

Any particular reason to use this path instead of ../iree-build or ../iree-build-tf (just thinking about being consistent with some of our docs and other scripts)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes. This is running in a docker container, so only mounted paths are writeable. As set up, we mount the directory in which IREE is checked out and the home directory, but not the parent of the directory in which IREE is checked out. See #4195

(as a side note, I hate sticking build directories as siblings to source directories)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(technically we don't mount the real home directory, we create a fake one so it's also mounted on the local_ssd for fast IO, see https://github.com/google/iree/blob/main/build_tools/kokoro/gcp_ubuntu/docker_common.sh)

@GMNGeoffrey
GMNGeoffrey marked this pull request as ready for review February 26, 2021 03:02
@@ -0,0 +1,81 @@
# Getting Started with IREE TensorFlow Integrations

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.

Eh, really not a fan of there being even more "getting started" docs... we should really differentiate more between developer docs and user docs, and anything involving building from source is pretty developer-oriented :P

What concerns me in particular about this document (where it is located and how it is titled) is that users coming from TensorFlow Python should absolutely not be following this guide - they should be using the pip packages.

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.

The contents of the doc are great though :) ... just concerned with the direction the "getting started" docs are taking.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I welcome anyone writing docs on how to do this 😛 This is the only way I know how to do it. Note that I do have a section for getting the binaries from the pip packages. All our getting started docs are about building from source. Until quite recently that was the only thing to get started on. But in particular @ewconnell was trying to actually use this stuff and the current documentation is super out of date, so I thought I would try to at least not make that worse with this change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

(and because tone is hard to convey, I don't disagree with you here). I think the addition of this doc makes things at least better documented, so we should keep it. The current docs are just...wrong AFAICT

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we need to re-organize a lot of these docs into a longer "developer guide" instead of discrete getting started docs. We should reserve the "getting started" moniker for actual users, not us poor saps who build this stuff.

Fine to reorganize as a followup.

cmd = [
"bazel",
"run",
"--run_under=echo",

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

WTF. I swear, the people who wrote these things never tried to use them in a real project.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Left a comment on the issue.

@@ -0,0 +1,81 @@
# Getting Started with IREE TensorFlow Integrations

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we need to re-organize a lot of these docs into a longer "developer guide" instead of discrete getting started docs. We should reserve the "getting started" moniker for actual users, not us poor saps who build this stuff.

Fine to reorganize as a followup.

@GMNGeoffrey
GMNGeoffrey merged commit f03c3c1 into iree-org:main Feb 26, 2021
@GMNGeoffrey
GMNGeoffrey deleted the import-tf-binaries branch February 26, 2021 18:44
GMNGeoffrey added a commit that referenced this pull request Mar 1, 2021
Fix release builds to build without asserts and turn off annoying
deprecation warnings.

The former is fallout from #4836 and
the latter is something we've noticed being really annoying recently.

The setting of deprecation to no-error (explicitly inviting warning
spam) is something we seem to have inherited from Google's internal
build. My best guess is that people mostly only see these in the code
they're changing because everything is cached or something. If we want
to surface these warnings, we should set up clang-tidy. Spamming the
logs for anyone building anything in the project is not the way.
@NatashaKnk NatashaKnk mentioned this pull request Mar 2, 2021
@GMNGeoffrey GMNGeoffrey added the infrastructure Relating to build systems, CI, or testing label Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Relating to build systems, CI, or testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants