Skip to content

Conversation

@TedThemistokleous
Copy link
Collaborator

@TedThemistokleous TedThemistokleous commented Aug 5, 2025

Precursor cleanup for resize parser which has a flattened set of calls for parsing between resize and linear modes.

More cleanup in another PR to handle upscale/resize with this parser in a more sane way before we do any changes to the modes of this operator.

Should get rid of the tidy complexity call right now.

Started off simple but found a few things with this one before I begin modifying the linear algorithm for resizing to integer values.

  • Removed tidy complexity suppression on parse() call
  • Encapsulated checks and variables into resize_args struct
  • Added in separate paths for upsample/resize when scales is an attribute
  • Cleans up complexity with parse_args (consolidate this into get_scales() call) for scale/size input (resize opset 13+)
  • Found bugfix with errors with input type for scales - Spec mentions float across both resize/upsample but we're allowing inputs of non float to be used (could lead to innacuracy)
  • Updated test for half type handling of scales
  • Added coverage for the case scale input is invalid.

@TedThemistokleous TedThemistokleous self-assigned this Aug 5, 2025
@TedThemistokleous TedThemistokleous added simple small or simple changes Cleanup Cleans up code from stale bits/warnings/previous changes for a previous feature PR labels Aug 5, 2025
added as of resize opset 18
Represent all the posible combinations/defaults and states using a struct  Will slowly build up functionality in a parser that takes these then mutates its state based on the parsed input capability
Use this to get / perform the proper parse based on the attributes detectd. leverage the use of std::optinal here for things like the scale() which can be made to be an attr in upsample operator but an input in both resize and upsample too
@TedThemistokleous TedThemistokleous removed the simple small or simple changes label Aug 8, 2025
Use the same get_scales() call for upsample scale values if its not detected as an attribute
Cleans up the transforms used to get output or scales by using other args to compute. Encapsulated these in the resize_arg
@codecov
Copy link

codecov bot commented Aug 14, 2025

Codecov Report

❌ Patch coverage is 94.29825% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/onnx/parse_resize.cpp 94.30% 13 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4204      +/-   ##
===========================================
+ Coverage    92.23%   92.23%   +0.01%     
===========================================
  Files          553      555       +2     
  Lines        25627    25767     +140     
===========================================
+ Hits         23635    23766     +131     
- Misses        1992     2001       +9     
Files with missing lines Coverage Δ
src/onnx/parse_resize.cpp 95.26% <94.30%> (-0.51%) ⬇️

... and 17 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@shivadbhavsar shivadbhavsar left a comment

Choose a reason for hiding this comment

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

I think there are some parts where combining the upsample and resize functionalities is created really messy functions. It would be nice to decouple some of these things for the two use cases (especially for figuring out the scales and output size) by putting them in entirely separate functions

Scales inputs should always be of type float. Its an error if we attempt to use scales or downcast the input to a lower type which could lead to errors. The onnx spec specifies across all Resize/Upsamples that scale is always of type float.

Fixed this since we originally had an else case when checking type for size or scale input  that would fall through allowing half, bf16, etc types through. Added an explicit check here and a test case for this
@TedThemistokleous TedThemistokleous added the bugfix Fixes a bug found in the code. label Aug 15, 2025
- rename compute_ouptuts to comptue_output_sizes
- Handle mispell of neighbor
- Use setter/gett of scales_sizes_arg better
- Remove double assignments of vec_scales
- Cleanup get_scales to be assign_scale_or_size() function

Should clean up some of the logic and clarify what some of these blocks are doing better
Not needed and just go by the op_name instead

simplifies and removes the need for another flag and two members in the struct
@migraphx-bot
Copy link
Collaborator

Test Batch Rate new
0fceaa
Rate old
397919
Diff Compare
torchvision-resnet50 64 3,228.00 3,227.60 0.01%
torchvision-resnet50_fp16 64 6,931.41 6,921.26 0.15%
torchvision-densenet121 32 2,440.75 2,438.37 0.10%
torchvision-densenet121_fp16 32 4,163.16 4,138.73 0.59%
torchvision-inceptionv3 32 1,627.55 1,627.50 0.00%
torchvision-inceptionv3_fp16 32 2,743.15 2,744.50 -0.05%
cadene-inceptionv4 16 766.55 767.15 -0.08%
cadene-resnext64x4 16 808.42 813.10 -0.57%
slim-mobilenet 64 7,416.65 7,419.38 -0.04%
slim-nasnetalarge 64 209.94 209.98 -0.02%
slim-resnet50v2 64 3,326.96 3,327.70 -0.02%
bert-mrpc-onnx 8 1,135.13 1,136.65 -0.13%
bert-mrpc-tf 1 441.88 445.25 -0.76%
pytorch-examples-wlang-gru 1 294.34 297.79 -1.16%
pytorch-examples-wlang-lstm 1 421.51 411.20 2.51%
torchvision-resnet50_1 1 762.88 767.87 -0.65%
cadene-dpn92_1 1 388.12 387.31 0.21%
cadene-resnext101_1 1 391.30 387.00 1.11%
onnx-taau-downsample 1 394.41 393.43 0.25%
dlrm-criteoterabyte 1 33.66 33.67 -0.04%
dlrm-criteoterabyte_fp16 1 51.07 51.11 -0.08%
agentmodel 1 9,219.65 9,137.01 0.90%
unet_fp16 2 58.98 58.97 0.01%
resnet50v1_fp16 1 990.58 988.80 0.18%
resnet50v1_int8 1 1,031.12 1,047.22 -1.54%
bert_base_cased_fp16 64 1,099.47 1,100.24 -0.07%
bert_large_uncased_fp16 32 343.36 343.33 0.01%
bert_large_fp16 1 197.03 196.19 0.43%
distilgpt2_fp16 16 2,103.40 2,104.94 -0.07%
yolov5s 1 580.63 578.82 0.31%
tinyllama 1 43.76 43.77 -0.01%
vicuna-fastchat 1 45.13 44.96 0.39%
whisper-tiny-encoder 1 416.29 415.75 0.13%
whisper-tiny-decoder 1 406.75 407.70 -0.23%
llama2_7b 1 19.11 19.10 0.04%
qwen1.5-7b 1 23.41 23.44 -0.09%
phi3-3.8b 1 26.61 26.61 -0.02%
mask-rcnn 1 12.47 12.01 3.90% 🔆
llama3-8b 1 21.64 21.62 0.10%
whisper-large-encoder 1 10.16 10.17 -0.06%
whisper-large-decoder 1 95.13 95.53 -0.42%
mistral-7b 1 23.62 23.63 -0.04%
FLUX.1-schnell 1 746.89 746.00 0.12%
nan nan nan nan nan%

This build is not recommended to merge 🔴

@migraphx-bot
Copy link
Collaborator


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

❌bert-mrpc-tf: ERROR - check error outputerror: unknown warning option '-Wnrvo' [-Werror,-Wunknown-warning-option]

error: unknown warning option '-Wnrvo' [-Werror,-Wunknown-warning-option]

2025-08-24 14:14:00.724885: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1756062845.917136 172407 gpu_device.cc:2022] Created device /job:localhost/replica:0/task:0/device:GPU:0 with 62951 MB memory: -> device: 0, name: AMD Instinct MI250X/MI250, pci bus id: 0000:32:00.0
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
I0000 00:00:1756062846.785120 172407 mlir_graph_optimization_pass.cc:401] MLIR V1 optimization pass is not enabled
2025-08-24 14:14:15.206017: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-08-24 14:14:15.206162: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-08-24 14:14:15.206203: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-08-24 14:14:15.206232: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-08-24 14:14:15.206277: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-08-24 14:14:15.206322: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-08-24 14:14:15.206353: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
2025-08-24 14:14:15.206400: E external/local_xla/xla/service/gpu/llvm_gpu_backend/gpu_backend_lib.cc:250] bitcode module is required by this HLO module but was not found at ./opencl.bc
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
error: Failure when generating HSACO
2025-08-24 14:14:15.207513: E tensorflow/compiler/mlir/tools/kernel_gen/tf_framework_c_interface.cc:228] INTERNAL: Generating device code failed.
2025-08-24 14:14:15.208694: W tensorflow/core/framework/op_kernel.cc:1829] UNKNOWN: JIT compilation failed.
2025-08-24 14:14:15.208715: I tensorflow/core/framework/local_rendezvous.cc:405] Local rendezvous is aborting with status: UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
2025-08-24 14:14:15.208727: I tensorflow/core/framework/local_rendezvous.cc:405] Local rendezvous is aborting with status: UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
[[import/loss/output/_21]]
2025-08-24 14:14:15.208742: I tensorflow/core/framework/local_rendezvous.cc:424] Local rendezvous recv item cancelled. Key hash: 11217777527359497193
Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1407, in _do_call
return fn(*args)
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1390, in _run_fn
return self._call_tf_sessionrun(options, feed_dict, fetch_list,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1483, in _call_tf_sessionrun
return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
tensorflow.python.framework.errors_impl.UnknownError: 2 root error(s) found.
(0) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
[[import/loss/output/_21]]
(1) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
0 successful operations.
0 derived errors ignored.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 359, in
main()
File "/src/AMDMIGraphX/tools/accuracy/accuracy_checker.py", line 335, in main
y_out = sess.run(y, feed_dict=tf_dict)
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 977, in run
result = self._run(None, fetches, feed_dict, options_ptr,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1220, in _run
results = self._do_run(handle, final_targets, final_fetches,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1400, in _do_run
return self._do_call(_run_fn, feeds, fetches, targets, options,
File "/usr/local/lib/python3.10/dist-packages/tensorflow/python/client/session.py", line 1426, in _do_call
raise type(e)(node_def, op, message) # pylint: disable=no-value-for-parameter
tensorflow.python.framework.errors_impl.UnknownError: Graph execution error:

Detected at node 'import/bert/embeddings/LayerNorm/moments/SquaredDifference' defined at (most recent call last):
Node: 'import/bert/embeddings/LayerNorm/moments/SquaredDifference'
Detected at node 'import/bert/embeddings/LayerNorm/moments/SquaredDifference' defined at (most recent call last):
Node: 'import/bert/embeddings/LayerNorm/moments/SquaredDifference'
2 root error(s) found.
(0) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
[[import/loss/output/_21]]
(1) UNKNOWN: JIT compilation failed.
[[{{node import/bert/embeddings/LayerNorm/moments/SquaredDifference}}]]
0 successful operations.
0 derived errors ignored.

Original stack trace for 'import/bert/embeddings/LayerNorm/moments/SquaredDifference':


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

     ✅ pytorch-examples-wlang-lstm: 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

     ✅ llama2_7b: PASSED: MIGraphX meets tolerance

     ✅ qwen1.5-7b: PASSED: MIGraphX meets tolerance

     ✅ phi3-3.8b: PASSED: MIGraphX meets tolerance

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


     ✅ llama3-8b: PASSED: MIGraphX meets tolerance

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

     ✅ mistral-7b: PASSED: MIGraphX meets tolerance

     ✅ FLUX.1-schnell: PASSED: MIGraphX meets tolerance

@causten causten merged commit fc0ddf8 into develop Aug 26, 2025
50 of 52 checks passed
@causten causten deleted the rewrite_resize_linear branch August 26, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug found in the code. Cleanup Cleans up code from stale bits/warnings/previous changes for a previous feature PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants