Conversation
LHT129
commented
Sep 12, 2024
- only header for quantizer and io
- fp32 quantizer as example
d41db02 to
36309db
Compare
|
|
||
| private: | ||
| [[nodiscard]] inline bool | ||
| CheckValidOffset(uint64_t size) const { |
There was a problem hiding this comment.
unify the naming convention; our private methods generally use the underscore naming style. (check_valid_offset)
| #include "fixtures.h" | ||
| using namespace vsag; | ||
|
|
||
| #define TEST_RECALL(Func) \ |
There was a problem hiding this comment.
Renaming it to TEST_ACCURACY would be more accurate.
| auto val = query[i] - codes[i]; | ||
| result += val * val; | ||
| } | ||
| return result; |
There was a problem hiding this comment.
There is no sqrt in the result. So, it is better to rename it to "FP32ComputeL2".
There was a problem hiding this comment.
L2Sqr is the Square of L2 norm
| private: | ||
| uint64_t dim_{0}; | ||
|
|
||
| uint64_t codeSize_{0}; |
There was a problem hiding this comment.
codeSize -> code_size_
f1ae5ea to
ca3eda5
Compare
eb24b83 to
414ce55
Compare
| auto* outVec = new float[dim]; | ||
| quant.DecodeOne(codes, outVec); | ||
| for (int i = 0; i < dim; ++i) { | ||
| REQUIRE(std::abs(vecs[idx * dim + i] - outVec[i]) < error); |
There was a problem hiding this comment.
should replace abs with fabs?
There was a problem hiding this comment.
For integral arguments, the integral overloads of std::abs are likely better matches.
reference: https://en.cppreference.com/w/cpp/numeric/math/fabs
| sum = _mm256_add_ps(sum, _mm256_mul_ps(a, b)); // accumulate the product | ||
| } | ||
| alignas(32) float result[8]; | ||
| _mm256_store_ps(result, sum); // store the accumulated result into an array |
There was a problem hiding this comment.
When n == 0, the store instruction (e.g. _mm256_store_ps) still occur in the avx512, avx2, and sse operators that may be harmful to the performance. Is it possible to add a judgment to skip these store instructions?
There was a problem hiding this comment.
yeah, I have fixed it
| } else if (metric == vsag::MetricType::METRIC_TYPE_L2SQR) { | ||
| gt = L2Sqr(data + idx1 * dim, query + i * dim, &dim); | ||
| } | ||
| REQUIRE(std::abs(gt - value) < 1e-4); |
60ae2ae to
f421f5f
Compare
d5e42ef to
0e8c538
Compare
|
|
||
| namespace vsag { | ||
|
|
||
| template <typename IOTmpl> |
There was a problem hiding this comment.
IOTmpl need any interface limit ?
| return ret; | ||
| } | ||
| void | ||
| MemoryIO::PrefetchImpl(uint64_t offset, uint64_t cacheLine) { |
There was a problem hiding this comment.
explicit mark cacheLine to unused ?
cacheLine -> cache_line
There was a problem hiding this comment.
code style will be modified in following pull request
|
|
||
| namespace vsag { | ||
|
|
||
| template <MetricType Metric = MetricType::METRIC_TYPE_L2SQR> |
| } | ||
|
|
||
| inline void | ||
| Prefetch(uint64_t offset, uint64_t cacheLine = 64) { |
There was a problem hiding this comment.
cacheLine -> cache_line
| MultiReadImpl(uint8_t* datas, uint64_t* sizes, uint64_t* offsets, uint64_t count) const; | ||
|
|
||
| inline void | ||
| PrefetchImpl(uint64_t offset, uint64_t cacheLine = 64); |
There was a problem hiding this comment.
cacheLine -> cache_line
|
|
||
| uint64_t codeSize_{0}; | ||
|
|
||
| bool isTrained_{false}; |
There was a problem hiding this comment.
isTrained_ -> is_trained_
| private: | ||
| uint64_t dim_{0}; | ||
|
|
||
| uint64_t codeSize_{0}; |
There was a problem hiding this comment.
codeSize -> code_size_
| } else if (Metric == MetricType::METRIC_TYPE_COSINE) { | ||
| return InnerProduct(codes1, codes2, &this->dim_); // TODO | ||
| } else { | ||
| return 0.; |
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
…up#25) Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
Signed-off-by: LHT129 <tianlan.lht@antgroup.com>
…up#25) Signed-off-by: LHT129 <tianlan.lht@antgroup.com> Signed-off-by: Sia Sheerland <x1075956441x@163.com> Signed-off-by: Sia Sheerland <x1075956441x@163.com>