Skip to content

Conversation

@snnn
Copy link
Contributor

@snnn snnn commented Mar 24, 2021

Description:

  1. Fix the warnings found by VC++ static code analyzer and add it to the CPU CI build
  2. Update pybind11 to a newer version because it contains a warning fix from me.
  3. Remove the cancel function of the Eigen thread pool. It is not used anywhere, and we don't know if it ever works.

Motivation and Context

  • Why is this change required? What problem does it solve?

Before this change, we even didn't test any EPs(other than CPU) in the java code.

  • If it fixes an open issue, please link to the issue here.

@snnn snnn requested a review from a team as a code owner March 24, 2021 03:50
condition: and(succeeded(), eq(variables['BuildConfig'], 'Debug'))
inputs:
scriptPath: '$(Build.SourcesDirectory)\tools\ci_build\build.py'
arguments: '--config Debug --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --build_shared_lib --update --cmake_generator "Visual Studio 16 2019" --build_wheel --build_shared_lib --enable_onnx_tests --cmake_extra_defines onnxruntime_ENABLE_STATIC_ANALYSIS=ON'
Copy link
Contributor

Choose a reason for hiding this comment

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

--enable_onnx_tests [](start = 197, length = 19)

do we need stuff like enabling the onnx tests if we're doing static analysis, or can we just keep it to the core code (could maybe turn off building of all the unit tests to make it faster as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "enable_onnx_tests" build flags doesn't control if the unit tests would be built. onnxruntime_BUILD_UNIT_TESTS does that. I think it's OK to keep it ON, it won't cost much time. Either works.

}

void Cancel() override {
cancelled_ = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we need this if we did anything more for parallel and/or async execution?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is mainly needed for fast failing. Suppose you have summited a "parallel for" code block with 4 threadpool tasks to a thread pool, and one of the tasks failed. If you want to quickly cancel the other 3 without continue to wait them being finished, then a cancel method would help. If everything was fine, then we don't need to cancel the pending or running tasks.

@snnn
Copy link
Contributor Author

snnn commented Mar 25, 2021

I'm still working on this.

@snnn snnn closed this Mar 29, 2021
@snnn snnn reopened this Mar 29, 2021
@snnn snnn force-pushed the snnn/vs2019 branch 2 times, most recently from c35ff35 to f1839b4 Compare April 8, 2021 20:41
@snnn
Copy link
Contributor Author

snnn commented Apr 9, 2021

Now it's ready for review.

endif()

if (onnxruntime_USE_OPENVINO)
if(NOT onnxruntime_ENABLE_STATIC_ANALYSIS)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a "if() ... endif()". The code between them is unchanged.

switch (code) {
case ORT_OK:
return 0;
return 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed tabs to spaces.

@snnn snnn requested a review from skottmckay April 9, 2021 14:42
Changming Sun added 2 commits April 14, 2021 00:47
Changming Sun added 2 commits April 14, 2021 01:19
onnxruntime_add_shared_library_module(onnxruntime4j_jni ${onnxruntime4j_native_src})
set_property(TARGET onnxruntime4j_jni PROPERTY CXX_STANDARD 11)

# Tell the JNI code about the requested providers
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 this code removed? It's used to cause the JNI code to emit a well formed exception if the provider isn't available.

Copy link
Contributor Author

@snnn snnn Apr 14, 2021

Choose a reason for hiding this comment

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

I moved it to CMakeLists.txt. And I think the things like "USE_OPENVINO" should not be used in the JNI project. I suggest the macro should be always on.

Copy link
Contributor

Choose a reason for hiding this comment

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

Now that the provider list exists in the C API I guess I can check that and throw the exception, but if you look in SessionOptions.c it's used to either compile the JNI method so it always throws a Java exception, or to compile it so it adds the requested provider. I'm not sure how stable that provider list is though, as it's not in the C API itself, I've got to manually copy the string constants into Java and check them.

* @param deviceId The id of the OpenVINO execution device.
* @throws OrtException If there was an error in native code.
*/
public void addOpenVINO(String deviceId) throws OrtException {
Copy link
Contributor

Choose a reason for hiding this comment

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

I realise these need shared library support which isn't currently possible in Java, but is there some other reason they are being removed? Are these two providers deprecated?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean isn't currently possible ?

Copy link
Contributor

Choose a reason for hiding this comment

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

The changes which broke out OpenVINO, DNNL and TensorRT into separate shared libraries broke the Java API wrappers around those providers. I opened #6553 as we'll package those shared libraries into the jar, and so need to be able to load them from a non-standard place, but as there's been no progress there they are broken in the current release and it's been broken since those providers are converted into shared libraries. When this (https://communities.sas.com/t5/SAS-Communities-Library/SAS-and-Microsoft-collaborate-to-democratize-the-use-of-Deep/ta-p/730072) lands it'll break CUDA too.

Copy link
Contributor

Choose a reason for hiding this comment

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

BTW I've got the code ready to go to move these providers over to the new API point (with the struct), but I can't test it because Java can't load the library.

* \param device_type openvino device type and precision. Could be any of
* CPU_FP32, GPU_FP32, GPU_FP16, MYRIAD_FP16, VAD-M_FP16 or VAD-F_FP32.
*/
ORT_API_STATUS(OrtSessionOptionsAppendExecutionProvider_OpenVINO,
Copy link
Member

Choose a reason for hiding this comment

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

why are these api's being removed for OpenVINO and TensorRT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the deprecated one, and it misses features.

Copy link
Member

@jywu-msft jywu-msft Apr 14, 2021

Choose a reason for hiding this comment

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

okay. originally i was going to let Intel handle it, but looks like they didn't remove this yet.

// End of Version 6 - DO NOT MODIFY ABOVE (see above text for more information)

public IntPtr ModelMetadataGetGraphDescription;
public IntPtr SessionOptionsAppendExecutionProvider_TensorRT;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the new API we should use

@snnn
Copy link
Contributor Author

snnn commented Apr 14, 2021

I'll wait #7315 merge first.

@snnn snnn closed this Apr 15, 2021
@snnn
Copy link
Contributor Author

snnn commented Apr 15, 2021

I will split it to smaller pieces.

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.

6 participants