Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NOT FOR MERGING] iOS Image Embedder Objective C++ #830

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

priankakariat
Copy link
Contributor

  1. Added a test .mm file and corresponding test for Image Embedder
  2. Added a new .sh file for building framework archive
  3. Added new podspec for objective c++ frameworks

@@ -0,0 +1,20 @@
Pod::Spec.new do |s|
s.name = 'TensorFlowLiteTaskVisionObjCPP'
Copy link
Member

Choose a reason for hiding this comment

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

Instead of having a dedicated podspec for the ObjC++ implementation, can you add the TensorFlowLiteTaskVisionObjCPP.framework as a vendored framework for the current TensorFlowLiteTaskVision pod? We don't want to expose the internal structure of the framework to the end-users if possible.

Copy link
Contributor Author

@priankakariat priankakariat Jun 8, 2022

Choose a reason for hiding this comment

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

This was just meant for illustrating how it will work. I have added the entire vision framework as a vendored framework now for more clarity. You can refer to the new vision podspec. The vendor framework mentioned here is defined in this build file.
We can also build the text framework in a similar manner going forward. I haven't made that change. Once it is done, the two shell scripts in /tensorflow_lite_support/tools/ci_build/builds can be unified into one.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks Prianka! LGTM.

@schmidt-sebastian @lu-wang-g Do you have any feedback?

Copy link
Member

Choose a reason for hiding this comment

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

@priankakariatyml Can you check if the new setup can make the Vision pod and Text pod co-exist in the same project? I guess that you may tweak the code to hide the duplicating symbols.

@khanhlvg khanhlvg changed the title iOS Image Embedder Objective C++ [NOT FOR MERGING] iOS Image Embedder Objective C++ Jun 8, 2022
Comment on lines +42 to +43
}
else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}
else {
} else {

@lu-wang-g lu-wang-g requested a review from yyoon June 8, 2022 23:19
Copy link
Contributor

@yyoon yyoon left a comment

Choose a reason for hiding this comment

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

Looks good to me at a high level.

As far as I can tell, this approach would work because the ObjC API headers (e.g., TFLImageEmbedder.h) are only using the other ObjC API headers in the same directory and not including any other C++ headers directly.

As noted, the header prefix stripping macro is probably not needed, but I'm not 100% sure about that. Please double check.

# to the "Headers" directory with no header path prefixes. This auxiliary rule
# is used for stripping the path prefix from the iOS API header files imported by
# other iOS API header files.
def strip_ios_api_include_path_prefix(name, hdr_labels, prefix = ""):
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Do we actually need this new macro?

As far as I can tell, the new iOS header files (e.g., TFLImageEmbedder.h) are all using plain header filenames in their import statements. That is, it's likely that the processed header file will be the same as the original header file.

  1. If you actually need it (which is probably not the case in my understanding..), does this actually need to be separated from the strip_c_api_include_path_prefix helper above?

Copy link
Contributor Author

@priankakariat priankakariat Jun 16, 2022

Choose a reason for hiding this comment

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

  1. Yes stripping will be needed. Right now only one file has been added for reviewing the structure. In a full implementation the header would have a lot of imports in a hierarchical structure like TFLImageClassifier.h. We will have to strip the prefixes and build the final iOS framework like the C framework is built.
    I added a separate method since objective c files are imported using #import as opposed to c files which are included using #include.
  2. I can incorporate this check in strip_c_api_include_path_prefix and call it strip_api_include_path_prefix which will strip path prefixes irrespective of #import or #include

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. If it's needed, I'd recommend consolidating these two functions into a single one as mentioned before.

s.library = 'c++'
s.vendored_frameworks = 'Frameworks/TensorFlowLiteTaskVisionC.framework'
s.frameworks = 'CoreMedia', 'Accelerate'
s.vendored_frameworks = 'Frameworks/TensorFlowLiteTaskVisionObjCPP.framework'
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be identical to the "bundle" name of the ios_static_framework rule?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, my bad. While testing the pod I had named the bundle TensorFlowLiteTaskVisionObjCPP. Afterwards I changed it to TensorFlowLiteTaskVision but didn't change it here. I have updated it now.

deps = [
"//tensorflow_lite_support/cc/task/vision:image_embedder",
],
copts = ["-ObjC++","-std=c++14"],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the -ObjC++ option needed?

Copy link
Contributor Author

@priankakariat priankakariat Jun 16, 2022

Choose a reason for hiding this comment

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

My understanding was that "-ObjC++" is needed when you are building with .mm files. Our source file is .mm.

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.

4 participants