Skip to content

[HIP] Add blender test #131

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

Merged
merged 1 commit into from
Jun 7, 2024
Merged

Conversation

yxsamliu
Copy link
Contributor

@yxsamliu yxsamliu commented Jun 6, 2024

Add test scripts to run blender with run-time compilation of HIP kernels, which can be used to test clang/llvm built by buildbot.

@yxsamliu yxsamliu requested a review from Artem-B June 6, 2024 15:06
Copy link
Member

@Artem-B Artem-B left a comment

Choose a reason for hiding this comment

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

LGTM in principle.
I'd move prerequisite checks to cmake configuration phase, instead of the tests themselves, and disable blender tests altogether if requirements are not satisfied.

import numpy as np
from skimage.metrics import structural_similarity as ssim
except ImportError:
print("One or more required packages are not installed. Please install them using the command:")
Copy link
Member

Choose a reason for hiding this comment

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

Should that be checked during cmake configuration phase instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better to check in python script since the script may be used alone.

Copy link
Member

Choose a reason for hiding this comment

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

You can have both. An enabled but failing test will just create unnecessary noise if tests are set up w/o blender. If blender is a requirement for the test suite, it's cmake's job to check for its presence, and enable/disable affected tests, IMO.

Up to you.


mse_value = mse(image1, image2)

if ssim_index < ssim_threshold or mse_value > mse_threshold:
Copy link
Member

Choose a reason for hiding this comment

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

What exactly are we checking for here?

I assume that the goal is to make sure we produced a sensible image, but it does not have to be pixel-perfect?

I suspect these checks may be rather fragile in general, though it may work well enough for the specific image you use for the test. I guess for a single image we can always find a metric that works, even if blender results change in the future. Still, describing what we do here and why/how the metrics and thresholds were chosen may be helpful.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ssim_index is 'structural similarity index' (https://en.wikipedia.org/wiki/Structural_similarity_index_measure), which is a popular measure of image similarity. Since it only measures gray-scale images, mse_value is also used, which measures 'mean square error' (https://en.wikipedia.org/wiki/Mean_squared_error). Together they should be a robust way to spot compiler issues without false alarms.

will add a comment about their meaning.

continue
return data

def calculate_average(data):
Copy link
Member

Choose a reason for hiding this comment

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

The tests already depend on numpy. You could just use numpy to do the math,

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 script may be used alone. Since the calculation is trivial, it is unnecessary to introduce extra dependency.

echo "TEST_SUITE_HIP_ROOT=$TEST_SUITE_HIP_ROOT"
ls $TEST_SUITE_HIP_ROOT
if [[ ! -e "$blender_dir/blender" || ! -e "$scene_dir/scenes.txt" ]]; then
echo "Skip HIP Blender test since no blender or test scenes found."
Copy link
Member

Choose a reason for hiding this comment

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

Another thing to check during cmake configuration?

import numpy as np
from skimage.metrics import structural_similarity as ssim
except ImportError:
print("One or more required packages are not installed. Please install them using the command:")
Copy link
Member

Choose a reason for hiding this comment

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

You can have both. An enabled but failing test will just create unnecessary noise if tests are set up w/o blender. If blender is a requirement for the test suite, it's cmake's job to check for its presence, and enable/disable affected tests, IMO.

Up to you.

@yxsamliu
Copy link
Contributor Author

yxsamliu commented Jun 6, 2024

I'd like the blender test to be enabled in cmake file always so that the scripts are always available for testing.

I will make change to the test script so that missing blender or Blender_Scenes will not cause error, but only skips the tests.

@yxsamliu yxsamliu force-pushed the hip-add-blender-test2 branch 2 times, most recently from acff4bd to e8adbc1 Compare June 7, 2024 03:46
Add test scripts to run blender with run-time compilation
of HIP kernels, which can be used to test clang/llvm
built by buildbot.
@yxsamliu yxsamliu force-pushed the hip-add-blender-test2 branch from e8adbc1 to f55ebfa Compare June 7, 2024 13:51
@yxsamliu yxsamliu merged commit ab4277b into llvm:main Jun 7, 2024
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.

2 participants