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 literal rounding in codegen functions #1910

Merged
merged 9 commits into from
Jul 5, 2023
Merged

Conversation

kahmed10
Copy link
Collaborator

Fixes the failing test case in #1815. Added a test that would otherwise fail without the change.

@kahmed10 kahmed10 added bugfix Fixes a bug found in the code. simple small or simple changes labels Jun 30, 2023
@kahmed10 kahmed10 linked an issue Jun 30, 2023 that may be closed by this pull request
@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Merging #1910 (e3f8fd1) into develop (e747114) will not change coverage.
The diff coverage is n/a.

❗ Current head e3f8fd1 differs from pull request most recent head 2bd3c26. Consider uploading reports for the commit 2bd3c26 to get more accurate results

@@           Coverage Diff            @@
##           develop    #1910   +/-   ##
========================================
  Coverage    91.37%   91.37%           
========================================
  Files          419      419           
  Lines        15544    15544           
========================================
  Hits         14204    14204           
  Misses        1340     1340           
Impacted Files Coverage Δ
src/include/migraphx/raw_data.hpp 98.50% <ø> (ø)

#include "migraphx/op/mul.hpp"
#include <iostream>
#include <vector>
#include <migraphx/operators.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dont include this header.

#include <migraphx/program.hpp>
#include <migraphx/register_target.hpp>
#include <migraphx/verify.hpp>
#include <migraphx/pass_manager.hpp>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this needed? I dont see it using passes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably not, going to clean up and remove unneeded headers

// and after rounding must equal 63, not 64.
TEST_CASE(mul_literal_round_test)
{
auto run_prog = [](migraphx::program p,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make this a free function.

result.visit([&](auto v) { res.assign(v.begin(), v.end()); });
};

auto create_program = [&] {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Inline this.

* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "migraphx/op/mul.hpp"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dont include this header.

@pfultz2
Copy link
Collaborator

pfultz2 commented Jun 30, 2023

Is it possible to add a to_string unit test as well?

TEST_CASE(literal_to_string_float_precision)
{
    migraphx::literal x{1 / 0.00787402f};
    EXPECT(x.to_string() == "126.99993142003703");
}

This can probably go in test/literal_test.cpp.

@kahmed10
Copy link
Collaborator Author

kahmed10 commented Jun 30, 2023

migraphx::literal x{1 / 0.00787402f};
    EXPECT(x.to_string() == "126.99993142003703");

Seems like this test fails because the string value doesn't match directly. I think I will rewrite it so it checks that the number doesn't round up.

@migraphx-bot
Copy link
Collaborator

migraphx-bot commented Jul 1, 2023

Test Batch Rate new
2bd3c2
Rate old
5924fd
Diff Compare
torchvision-resnet50 64 895.88 895.42 0.05%
torchvision-resnet50_fp16 64 5,312.97 5,306.36 0.12%
torchvision-densenet121 32 1,125.47 1,126.29 -0.07%
torchvision-densenet121_fp16 32 3,277.74 3,281.90 -0.13%
torchvision-inceptionv3 32 594.19 594.18 0.00%
torchvision-inceptionv3_fp16 32 2,506.38 2,499.08 0.29%
cadene-inceptionv4 16 329.91 329.61 0.09%
cadene-resnext64x4 16 393.57 394.41 -0.21%
slim-mobilenet 64 7,133.69 7,133.66 0.00%
slim-nasnetalarge 64 159.91 160.05 -0.09%
slim-resnet50v2 64 1,089.92 1,089.71 0.02%
bert-mrpc-onnx 8 718.72 719.50 -0.11%
bert-mrpc-tf 1 369.66 370.77 -0.30%
pytorch-examples-wlang-gru 1 307.46 307.76 -0.10%
pytorch-examples-wlang-lstm 1 312.11 313.57 -0.47%
torchvision-resnet50_1 1 92.03 91.90 0.14%
torchvision-inceptionv3_1 1 128.95 127.95 0.78%
cadene-dpn92_1 1 336.40 335.65 0.22%
cadene-resnext101_1 1 237.11 237.13 -0.01%
slim-vgg16_1 1 53.37 53.35 0.04%
slim-mobilenet_1 1 1,494.12 1,516.80 -1.50%
slim-inceptionv4_1 1 102.43 100.81 1.61%
onnx-taau-downsample 1 316.68 316.87 -0.06%
dlrm-criteoterabyte 1 21.42 21.43 -0.04%
dlrm-criteoterabyte_fp16 1 39.89 39.95 -0.16%
agentmodel 1 5,871.20 5,581.60 5.19% 🔆
unet_fp16 2 52.71 52.83 -0.22%

Check results before merge 🔆

@migraphx-bot
Copy link
Collaborator


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

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

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

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

    :white_check_mark:torchvision-resnet50_1: PASSED: MIGraphX meets tolerance

    :white_check_mark:torchvision-inceptionv3_1: PASSED: MIGraphX meets tolerance

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


    :white_check_mark:cadene-resnext101_1: PASSED: MIGraphX meets tolerance

    :white_check_mark:slim-vgg16_1: PASSED: MIGraphX meets tolerance

    :white_check_mark:slim-mobilenet_1: PASSED: MIGraphX meets tolerance

    :white_check_mark:slim-inceptionv4_1: PASSED: MIGraphX meets tolerance

    :white_check_mark:dlrm-criteoterabyte: PASSED: MIGraphX meets tolerance

    :white_check_mark:agentmodel: PASSED: MIGraphX meets tolerance

    :white_check_mark:unet: PASSED: MIGraphX meets tolerance

// and after rounding must equal 63, not 64.
TEST_CASE(mul_literal_round_test)
{

Copy link
Member

Choose a reason for hiding this comment

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

extra line

{
if(m_in.count(x.first) > 0)
{
m[x.first] = t.copy_to(m_in[x.first]);
Copy link
Member

Choose a reason for hiding this comment

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

I think you can call to set_offload_copy to do this.

@causten causten merged commit 697709a into develop Jul 5, 2023
11 checks passed
@causten causten deleted the codegen_literal_fix branch July 5, 2023 23:39
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. simple small or simple changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ref::quant_dot for int8 computes wrong result in test validation
6 participants