Skip to content

refactor(test): add macros for quantizer tests to reduce code duplication#1738

Open
LHT129 wants to merge 1 commit intomainfrom
yellow/quantization-test-template-refactor
Open

refactor(test): add macros for quantizer tests to reduce code duplication#1738
LHT129 wants to merge 1 commit intomainfrom
yellow/quantization-test-template-refactor

Conversation

@LHT129
Copy link
Copy Markdown
Collaborator

@LHT129 LHT129 commented Mar 20, 2026

Summary

Add macro definitions in quantizer_test.h to simplify quantizer test definitions and reduce code duplication across multiple test files.

Changes

  • Add DEFINE_QUANTIZER_ENCODE_DECODE_TESTS macro for encode/decode tests
  • Add DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE macro for simple encode/decode tests
  • Add DEFINE_QUANTIZER_COMPUTE_TESTS macro for compute tests
  • Add DEFINE_QUANTIZER_COMPUTE_TESTS_WITH_SAME macro for compute tests with TestComputeCodesSame
  • Add DEFINE_QUANTIZER_SERIALIZE_TESTS macro for serialize/deserialize tests
  • Refactor fp32_quantizer_test.cpp to use new macros (95 lines → 28 lines, 70% reduction)

Technical Details

The macros use runtime metric selection (if/else) instead of TEMPLATE_TEST_CASE since MetricType is an enum value, not a type. This approach:

  • Avoids complex template metaprogramming
  • Maintains the same test coverage
  • Makes the code easier to understand and maintain

Testing

All tests pass:

./build/tests/unittests -d yes "[FP32Quantizer]"
All tests passed (30930 assertions in 3 test cases)

Files Changed

  • src/quantization/quantizer_test.h - Added 5 macros for test definition
  • src/quantization/fp32_quantizer_test.cpp - Refactored to use macros

Checklist

  • Code follows VSAG coding style
  • All tests pass
  • Commit messages follow Conventional Commits

Copilot AI review requested due to automatic review settings March 20, 2026 08:44
@LHT129 LHT129 self-assigned this Mar 20, 2026
@LHT129 LHT129 added kind/improvement Code improvements (variable/function renaming, refactoring, etc. ) version/1.0 labels Mar 20, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces macros to simplify quantizer test definitions and reduce code duplication. The primary goal is to make the test code more maintainable and easier to understand, while preserving the existing test coverage. The changes involve adding macro definitions in quantizer_test.h and refactoring fp32_quantizer_test.cpp to use these macros.

Highlights

  • Macros Added: Introduced several macros in quantizer_test.h to streamline the definition of quantizer tests, reducing code duplication.
  • Refactoring: Refactored fp32_quantizer_test.cpp to utilize the newly defined macros, significantly reducing the lines of code.
  • Test Coverage: Maintained the same test coverage while simplifying the test definitions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors quantizer unit tests by introducing reusable Catch2 macro helpers to reduce duplication, then migrates FP32 quantizer tests to the new macros.

Changes:

  • Added a set of DEFINE_QUANTIZER_* macros in quantizer_test.h to generate common encode/decode, compute, and serialization test cases.
  • Refactored fp32_quantizer_test.cpp to use the new macros and centralize test parameters (dims/counts/error).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/quantization/quantizer_test.h Adds macro-based helpers that generate Catch2 test cases for multiple metrics/dims/counts.
src/quantization/fp32_quantizer_test.cpp Replaces duplicated FP32 quantizer test logic with the new macro helpers.

#include "data_type.h"
#include "fixtures.h"
#include "impl/allocator/safe_allocator.h"
#include "iostream"
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

iostream is a standard library header and should be included with angle brackets (#include <iostream>). Using quotes can accidentally pick up a project-local header named iostream, leading to confusing build behavior.

Suggested change
#include "iostream"
#include <iostream>

Copilot uses AI. Check for mistakes.
@@ -15,81 +14,16 @@

Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

This file now uses std::vector but does not include <vector> directly. Please add #include <vector> to avoid relying on transitive includes (which can break with unrelated header changes).

Suggested change
#include <vector>

Copilot uses AI. Check for mistakes.
Comment on lines +22 to +23
const auto dims = std::vector<int>{64, 128};
const auto counts = std::vector<int>{10, 101};
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

This file now uses std::vector but does not include <vector> directly. Please add #include <vector> to avoid relying on transitive includes (which can break with unrelated header changes).

Copilot uses AI. Check for mistakes.
Comment on lines +473 to +489
constexpr MetricType metrics[] = {MetricType::METRIC_TYPE_L2SQR, MetricType::METRIC_TYPE_COSINE, MetricType::METRIC_TYPE_IP}; \
for (auto dim : dims_val) { \
for (auto count : counts_val) { \
for (auto metric : metrics) { \
auto allocator = SafeAllocator::FactoryDefaultAllocator(); \
if (metric == MetricType::METRIC_TYPE_L2SQR) { \
QuantizerT<MetricType::METRIC_TYPE_L2SQR> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, error_val); \
} else if (metric == MetricType::METRIC_TYPE_COSINE) { \
QuantizerT<MetricType::METRIC_TYPE_COSINE> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_COSINE>, MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_COSINE>, MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, error_val); \
} else { \
QuantizerT<MetricType::METRIC_TYPE_IP> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_IP>, MetricType::METRIC_TYPE_IP>(quantizer, dim, count, error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_IP>, MetricType::METRIC_TYPE_IP>(quantizer, dim, count, error_val); \
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

Several macro lines are very long and hard to read/review (and likely violate the project’s 100-char line length). Consider wrapping the repeated test invocations into small helper functions/templates (e.g., per-metric helpers) so the macro only declares the TEST_CASE and calls a readable helper, or split the template arguments across multiple lines using additional line continuations.

Suggested change
constexpr MetricType metrics[] = {MetricType::METRIC_TYPE_L2SQR, MetricType::METRIC_TYPE_COSINE, MetricType::METRIC_TYPE_IP}; \
for (auto dim : dims_val) { \
for (auto count : counts_val) { \
for (auto metric : metrics) { \
auto allocator = SafeAllocator::FactoryDefaultAllocator(); \
if (metric == MetricType::METRIC_TYPE_L2SQR) { \
QuantizerT<MetricType::METRIC_TYPE_L2SQR> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, error_val); \
} else if (metric == MetricType::METRIC_TYPE_COSINE) { \
QuantizerT<MetricType::METRIC_TYPE_COSINE> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_COSINE>, MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_COSINE>, MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, error_val); \
} else { \
QuantizerT<MetricType::METRIC_TYPE_IP> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_IP>, MetricType::METRIC_TYPE_IP>(quantizer, dim, count, error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_IP>, MetricType::METRIC_TYPE_IP>(quantizer, dim, count, error_val); \
constexpr MetricType metrics[] = { \
MetricType::METRIC_TYPE_L2SQR, \
MetricType::METRIC_TYPE_COSINE, \
MetricType::METRIC_TYPE_IP, \
}; \
for (auto dim : dims_val) { \
for (auto count : counts_val) { \
for (auto metric : metrics) { \
auto allocator = SafeAllocator::FactoryDefaultAllocator(); \
if (metric == MetricType::METRIC_TYPE_L2SQR) { \
QuantizerT<MetricType::METRIC_TYPE_L2SQR> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, \
MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, \
error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, \
MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, \
error_val); \
} else if (metric == MetricType::METRIC_TYPE_COSINE) { \
QuantizerT<MetricType::METRIC_TYPE_COSINE> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_COSINE>, \
MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, \
error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_COSINE>, \
MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, \
error_val); \
} else { \
QuantizerT<MetricType::METRIC_TYPE_IP> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_IP>, \
MetricType::METRIC_TYPE_IP>(quantizer, dim, count, \
error_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_IP>, \
MetricType::METRIC_TYPE_IP>(quantizer, dim, count, \
error_val); \

Copilot uses AI. Check for mistakes.
}

#define DEFINE_QUANTIZER_ENCODE_DECODE_TESTS(TestName, QuantizerT, dims_val, counts_val, error_val, code_max_val) \
TEST_CASE(TestName " Encode and Decode", "[ut][" TestName "]") { \
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

DEFINE_QUANTIZER_ENCODE_DECODE_TESTS and DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE generate the exact same Catch2 test case name (TestName " Encode and Decode"). If a quantizer test file ever uses both macros with the same TestName, this can create duplicate/ambiguous test names. Consider differentiating the names (e.g., " Encode and Decode (Same)" vs " Encode and Decode") or adding a macro parameter for the suffix.

Suggested change
TEST_CASE(TestName " Encode and Decode", "[ut][" TestName "]") { \
TEST_CASE(TestName " Encode and Decode (Same)", "[ut][" TestName "]") { \

Copilot uses AI. Check for mistakes.
}

#define DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE(TestName, QuantizerT, dims_val, counts_val, error_val) \
TEST_CASE(TestName " Encode and Decode", "[ut][" TestName "]") { \
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

DEFINE_QUANTIZER_ENCODE_DECODE_TESTS and DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE generate the exact same Catch2 test case name (TestName " Encode and Decode"). If a quantizer test file ever uses both macros with the same TestName, this can create duplicate/ambiguous test names. Consider differentiating the names (e.g., " Encode and Decode (Same)" vs " Encode and Decode") or adding a macro parameter for the suffix.

Suggested change
TEST_CASE(TestName " Encode and Decode", "[ut][" TestName "]") { \
TEST_CASE(TestName " Encode and Decode (Simple)", "[ut][" TestName "]") { \

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request effectively reduces code duplication in quantizer tests by introducing macros. The approach is sound. I have two suggestions for improvement: one to further reduce duplication within the newly created macros for better maintainability, and another to address a potential reduction in test coverage for fp32_quantizer_test.cpp.

}
}
}
DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE("FP32Quantizer", FP32Quantizer, dims, counts, error)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The original test code for FP32Quantizer's "Encode and Decode" test included a call to TestQuantizerEncodeDecodeSame. By using DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE, this test is now omitted, which reduces test coverage. To maintain the original test coverage, you should use DEFINE_QUANTIZER_ENCODE_DECODE_TESTS and provide the code_max_val (65536) that was used previously.

Suggested change
DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE("FP32Quantizer", FP32Quantizer, dims, counts, error)
DEFINE_QUANTIZER_ENCODE_DECODE_TESTS("FP32Quantizer", FP32Quantizer, dims, counts, error, 65536)

Comment on lines +496 to +522
#define DEFINE_QUANTIZER_COMPUTE_TESTS_WITH_SAME(TestName, QuantizerT, dims_val, counts_val, error_val, code_max_val) \
TEST_CASE(TestName " Compute", "[ut][" TestName "]") { \
constexpr MetricType metrics[] = {MetricType::METRIC_TYPE_L2SQR, MetricType::METRIC_TYPE_COSINE, MetricType::METRIC_TYPE_IP}; \
for (auto dim : dims_val) { \
for (auto count : counts_val) { \
for (auto metric : metrics) { \
auto allocator = SafeAllocator::FactoryDefaultAllocator(); \
if (metric == MetricType::METRIC_TYPE_L2SQR) { \
QuantizerT<MetricType::METRIC_TYPE_L2SQR> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, error_val); \
TestComputeCodesSame<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, code_max_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_L2SQR>, MetricType::METRIC_TYPE_L2SQR>(quantizer, dim, count, error_val); \
} else if (metric == MetricType::METRIC_TYPE_COSINE) { \
QuantizerT<MetricType::METRIC_TYPE_COSINE> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_COSINE>, MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, error_val); \
TestComputeCodesSame<QuantizerT<MetricType::METRIC_TYPE_COSINE>, MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, code_max_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_COSINE>, MetricType::METRIC_TYPE_COSINE>(quantizer, dim, count, error_val); \
} else { \
QuantizerT<MetricType::METRIC_TYPE_IP> quantizer(dim, allocator.get()); \
TestComputeCodes<QuantizerT<MetricType::METRIC_TYPE_IP>, MetricType::METRIC_TYPE_IP>(quantizer, dim, count, error_val); \
TestComputeCodesSame<QuantizerT<MetricType::METRIC_TYPE_IP>, MetricType::METRIC_TYPE_IP>(quantizer, dim, count, code_max_val); \
TestComputer<QuantizerT<MetricType::METRIC_TYPE_IP>, MetricType::METRIC_TYPE_IP>(quantizer, dim, count, error_val); \
} \
} \
} \
} \
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The macro definitions contain a lot of duplicated code in the if/else if/else blocks for handling different metric types. This can be simplified by extracting the common logic into a helper structure with a templated static method, defined within the TEST_CASE to avoid name clashes. This improves maintainability and readability.

This suggestion applies to all the new macros defined in this file.

#define DEFINE_QUANTIZER_COMPUTE_TESTS_WITH_SAME(TestName, QuantizerT, dims_val, counts_val, error_val, code_max_val) \
    TEST_CASE(TestName " Compute", "[ut][" TestName "]") { \
        struct TestRunner { \
            template <MetricType metric> \
            static void run(int dim, int count, float error, int code_max) { \
                auto allocator = SafeAllocator::FactoryDefaultAllocator(); \
                QuantizerT<metric> quantizer(dim, allocator.get()); \
                TestComputeCodes<QuantizerT<metric>, metric>(quantizer, dim, count, error); \
                TestComputeCodesSame<QuantizerT<metric>, metric>(quantizer, dim, count, code_max); \
                TestComputer<QuantizerT<metric>, metric>(quantizer, dim, count, error); \
            } \
        }; \
        constexpr MetricType metrics[] = {MetricType::METRIC_TYPE_L2SQR, MetricType::METRIC_TYPE_COSINE, MetricType::METRIC_TYPE_IP}; \
        for (auto dim : dims_val) { \
            for (auto count : counts_val) { \
                for (auto metric : metrics) { \
                    if (metric == MetricType::METRIC_TYPE_L2SQR) { \
                        TestRunner::run<MetricType::METRIC_TYPE_L2SQR>(dim, count, error_val, code_max_val); \
                    } else if (metric == MetricType::METRIC_TYPE_COSINE) { \
                        TestRunner::run<MetricType::METRIC_TYPE_COSINE>(dim, count, error_val, code_max_val); \
                    } else { \
                        TestRunner::run<MetricType::METRIC_TYPE_IP>(dim, count, error_val, code_max_val); \
                    } \
                } \
            } \
        } \
    }

Copilot AI review requested due to automatic review settings March 24, 2026 09:33
@LHT129 LHT129 force-pushed the yellow/quantization-test-template-refactor branch from de2395e to f823f4c Compare March 24, 2026 09:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment on lines +431 to +442
#define DEFINE_QUANTIZER_ENCODE_DECODE_TESTS( \
TestName, QuantizerT, dims_val, counts_val, error_val, code_max_val) \
TEST_CASE(TestName " Encode and Decode", "[ut][" TestName "]") { \
constexpr MetricType metrics[] = {MetricType::METRIC_TYPE_L2SQR, \
MetricType::METRIC_TYPE_IP}; \
for (auto dim : dims_val) { \
for (auto count : counts_val) { \
for (auto metric : metrics) { \
auto allocator = SafeAllocator::FactoryDefaultAllocator(); \
if (metric == MetricType::METRIC_TYPE_L2SQR) { \
QuantizerT<MetricType::METRIC_TYPE_L2SQR> quantizer(dim, allocator.get()); \
TestQuantizerEncodeDecode(quantizer, dim, count, error_val); \
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The newly added test-definition macros contain multiple lines that significantly exceed the repo’s configured 100-column limit, which makes them hard to read and can fight clang-format. Consider wrapping long template/type lines and/or factoring repeated branch bodies into a helper macro/lambda to keep macro lines within the column limit.

Copilot uses AI. Check for mistakes.
}
}
}
DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE("FP32Quantizer", FP32Quantizer, dims, counts, error)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This refactor drops the TestQuantizerEncodeDecodeSame(...) coverage that previously ran for FP32 encode/decode (the new _SIMPLE macro only calls TestQuantizerEncodeDecode). If that check is still desired, switch to DEFINE_QUANTIZER_ENCODE_DECODE_TESTS and pass code_max=65536 so the same-behavior assertions remain equivalent to the old test.

Copilot generated this review using guidance from repository custom instructions.
}
}
DEFINE_QUANTIZER_ENCODE_DECODE_TESTS_SIMPLE("FP32Quantizer", FP32Quantizer, dims, counts, error)
DEFINE_QUANTIZER_COMPUTE_TESTS_WITH_SAME("FP32Quantizer", FP32Quantizer, dims, counts, error, 65536)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

This macro invocation line is over the 100-column limit; please wrap it across multiple lines for readability and to match the repository formatting configuration.

Suggested change
DEFINE_QUANTIZER_COMPUTE_TESTS_WITH_SAME("FP32Quantizer", FP32Quantizer, dims, counts, error, 65536)
DEFINE_QUANTIZER_COMPUTE_TESTS_WITH_SAME("FP32Quantizer",
FP32Quantizer,
dims,
counts,
error,
65536)

Copilot uses AI. Check for mistakes.
Comment on lines 20 to +22
#include "data_type.h"
#include "fixtures.h"
#include "impl/allocator/safe_allocator.h"
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

quantizer_test.h is used as a header across many test translation units, but it has no include guard (#pragma once or #ifndef/#define). This can cause ODR/redefinition errors if it ever gets included transitively more than once in a TU (especially now that it also defines macros). Add an include guard at the top of this file to make inclusion safe and consistent with the rest of the codebase’s headers (e.g., src/quantization/quantizer.h uses #pragma once).

Copilot uses AI. Check for mistakes.
…tion

Introduce test macros to simplify quantizer test cases and reduce
boilerplate code.

Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
@LHT129 LHT129 force-pushed the yellow/quantization-test-template-refactor branch from f823f4c to 59f3263 Compare March 27, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/improvement Code improvements (variable/function renaming, refactoring, etc. ) size/L version/1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants