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

fix compilation on HIP SDK 6.3 for Windows - undefined behavior #3824

Merged
merged 1 commit into from
Feb 22, 2025

Conversation

apwojcik
Copy link
Collaborator

The HIP SDK 6.3 compiler for Windows reports the following warning message, which is treated as an error when compiling MIGraphX on Windows.

C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:489:12: error: dereference of type 'T *' that was reinterpret_cast from type 'X *' has undefined behavior [-Werror,-Wundefined-reinterpret-cast]
  489 |         f(*reinterpret_cast<T*>(obj), result, no_out_arg{}, xs...);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
C:\...\MIGraphX\src\api/include\migraphx\migraphx.hpp:130:16: note: in instantiation of function template specialization 'migraphx::interface_base<migraphx::handle_base<migraphx::experimental_custom_op, migraphx_experimental_custom_op, migraphx_status (*)(migraphx_experimental_custom_op *), &migraphx_experimental_custom_op_destroy, migraphx_status (*)(migraphx_experimental_custom_op *, const migraphx_experimental_custom_op *), &migraphx_experimental_custom_op_assign_to>>::set_fp(migraphx_status (*)(migraphx_experimental_custom_op *, migraphx_status (*)(migraphx_shape *, void *, char *, unsigned long long, migraphx_shapes *)), (lambda at C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:465:13), out_params<1>)::(anonymous class)::operator()<migraphx_shape *, migraphx_shapes *>' requested here
  130 |     auto e = f(std::forward<Ts>(xs)...);
      |                ^
C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:438:9: note: in instantiation of function template specialization 'migraphx::call<migraphx_status (*)(migraphx_experimental_custom_op *, migraphx_status (*)(migraphx_shape *, void *, char *, unsigned long long, migraphx_shapes *)), migraphx_experimental_custom_op *, (lambda at C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:440:14)>' requested here
  438 |         call(setter,
      |         ^
C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:463:16: note: in instantiation of function template specialization 'migraphx::interface_base<migraphx::handle_base<migraphx::experimental_custom_op, migraphx_experimental_custom_op, migraphx_status (*)(migraphx_experimental_custom_op *), &migraphx_experimental_custom_op_destroy, migraphx_status (*)(migraphx_experimental_custom_op *, const migraphx_experimental_custom_op *), &migraphx_experimental_custom_op_assign_to>>::set_fp<sigmoid_custom_op, migraphx_status (*)(migraphx_experimental_custom_op *, migraphx_status (*)(migraphx_shape *, void *, char *, unsigned long long, migraphx_shapes *)), (lambda at C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:465:13)>' requested here
  463 |         return set_fp<T>(
      |                ^
C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:1568:9: note: in instantiation of function template specialization 'migraphx::interface_base<migraphx::handle_base<migraphx::experimental_custom_op, migraphx_experimental_custom_op, migraphx_status (*)(migraphx_experimental_custom_op *), &migraphx_experimental_custom_op_destroy, migraphx_status (*)(migraphx_experimental_custom_op *, const migraphx_experimental_custom_op *), &migraphx_experimental_custom_op_assign_to>>::set_auto_fp<sigmoid_custom_op, migraphx_status (*)(migraphx_experimental_custom_op *, migraphx_status (*)(migraphx_shape *, void *, char *, unsigned long long, migraphx_shapes *)), (lambda at C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:1568:9), migraphx::out_params<1>>' requested here
 1568 |         MIGRAPHX_INTERFACE_LIFT(1, T, experimental_custom_op, compute_shape);
      |         ^
C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:565:11: note: expanded from macro 'MIGRAPHX_INTERFACE_LIFT'
  565 |     this->set_auto_fp<T>(                               \
      |           ^
C:\...\MIGraphX\src\api\include\migraphx\migraphx.hpp:1580:28: note: in instantiation of function template specialization 'migraphx::experimental_custom_op::experimental_custom_op<sigmoid_custom_op>' requested here
 1580 |     experimental_custom_op op{obj};
      |                            ^
C:\...\MIGraphX\test\api\test_custom_op.cpp:73:15: note: in instantiation of function template specialization 'migraphx::register_experimental_custom_op<sigmoid_custom_op, void>' requested here
   73 |     migraphx::register_experimental_custom_op(sigmoid_op);

Changing to static_cast resolves the problem.

@apwojcik apwojcik added the Windows Related changes for Windows Environments label Feb 18, 2025
@apwojcik apwojcik requested a review from causten as a code owner February 18, 2025 10:52
@apwojcik
Copy link
Collaborator Author

@causten We also need this PR in the branch release/rocm-rel-6.4.

@apwojcik apwojcik requested review from umangyadav, causten and pfultz2 and removed request for causten February 18, 2025 10:53
Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.35%. Comparing base (27a90b5) to head (6c8ec26).
Report is 8 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #3824   +/-   ##
========================================
  Coverage    92.35%   92.35%           
========================================
  Files          519      519           
  Lines        22311    22311           
========================================
  Hits         20606    20606           
  Misses        1705     1705           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
6c8ec2
Rate old
bfc14e
Diff Compare
torchvision-resnet50 64 3,237.23 3,233.96 0.10%
torchvision-resnet50_fp16 64 6,866.95 6,874.33 -0.11%
torchvision-densenet121 32 2,439.12 2,436.94 0.09%
torchvision-densenet121_fp16 32 4,192.43 4,181.18 0.27%
torchvision-inceptionv3 32 1,613.72 1,612.90 0.05%
torchvision-inceptionv3_fp16 32 2,673.35 2,677.82 -0.17%
cadene-inceptionv4 16 750.82 750.47 0.05%
cadene-resnext64x4 16 810.54 809.72 0.10%
slim-mobilenet 64 6,661.84 6,659.15 0.04%
slim-nasnetalarge 64 196.93 196.77 0.08%
slim-resnet50v2 64 3,431.01 3,430.42 0.02%
bert-mrpc-onnx 8 1,134.75 1,133.14 0.14%
bert-mrpc-tf 1 505.05 500.00 1.01%
pytorch-examples-wlang-gru 1 480.87 470.97 2.10%
pytorch-examples-wlang-lstm 1 447.20 437.32 2.26%
torchvision-resnet50_1 1 793.65 793.65 0.00%
cadene-dpn92_1 1 429.51 430.36 -0.20%
cadene-resnext101_1 1 389.11 389.11 0.00%
onnx-taau-downsample 1 371.29 371.31 -0.00%
dlrm-criteoterabyte 1 31.83 31.79 0.12%
dlrm-criteoterabyte_fp16 1 51.05 51.06 -0.02%
agentmodel 1 8,761.78 8,658.38 1.19%
unet_fp16 2 58.26 58.36 -0.17%
resnet50v1_fp16 1 1,020.41 1,075.27 -5.10% 🔴
resnet50v1_int8 1 793.65 800.00 -0.79%
bert_base_cased_fp16 64 1,159.42 1,159.42 0.00%
bert_large_uncased_fp16 32 360.04 359.96 0.02%
bert_large_fp16 1 217.39 215.98 0.65%
distilgpt2_fp16 16 2,188.78 2,188.78 0.00%
yolov5s 1 538.82 531.08 1.46%
tinyllama 1 49.09 49.12 -0.05%
vicuna-fastchat 1 43.58 43.55 0.07%
whisper-tiny-encoder 1 436.68 436.68 0.00%
whisper-tiny-decoder 1 450.45 448.43 0.45%

This build is not recommended to merge 🔴

@migraphx-bot
Copy link
Collaborator


     ✅ bert-mrpc-onnx: PASSED: MIGraphX meets tolerance

     ✅ bert-mrpc-tf: PASSED: MIGraphX meets tolerance

     ✅ pytorch-examples-wlang-gru: PASSED: MIGraphX meets tolerance

     ✅ pytorch-examples-wlang-lstm: PASSED: MIGraphX meets tolerance

     ✅ torchvision-resnet50_1: PASSED: MIGraphX meets tolerance

     ✅ cadene-dpn92_1: PASSED: MIGraphX meets tolerance

     ✅ cadene-resnext101_1: PASSED: MIGraphX meets tolerance

     ✅ dlrm-criteoterabyte: PASSED: MIGraphX meets tolerance

     ✅ agentmodel: PASSED: MIGraphX meets tolerance

     ✅ unet: PASSED: MIGraphX meets tolerance

     ✅ resnet50v1: PASSED: MIGraphX meets tolerance

     ✅ bert_base_cased_fp16: PASSED: MIGraphX meets tolerance

🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output


     ✅ bert_large: PASSED: MIGraphX meets tolerance

     ✅ yolov5s: PASSED: MIGraphX meets tolerance

     ✅ tinyllama: PASSED: MIGraphX meets tolerance

     ✅ vicuna-fastchat: PASSED: MIGraphX meets tolerance

     ✅ whisper-tiny-encoder: PASSED: MIGraphX meets tolerance

     ✅ whisper-tiny-decoder: PASSED: MIGraphX meets tolerance

     ✅ distilgpt2_fp16: PASSED: MIGraphX meets tolerance

@causten causten requested a review from kahmed10 February 20, 2025 18:16
@causten causten added the high priority A PR with high priority for review and merging. label Feb 21, 2025
@causten causten merged commit 466ceed into develop Feb 22, 2025
37 of 38 checks passed
@causten causten deleted the dereference-undefined-behaviour branch February 22, 2025 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority A PR with high priority for review and merging. Windows Related changes for Windows Environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants