mirror of https://github.com/google/gemma.cpp.git
Refactor: Rename BlobReader to BlobFinder
Renamed BlobReader and BlobWriter to BlobFinder as suggested by @janwas in TODO. Also Updated associated files, tests, and CMakeLists.txt.
This commit is contained in:
parent
3ed403e287
commit
733bbddb7a
|
|
@ -98,8 +98,8 @@ set(SOURCES
|
|||
gemma/vit.h
|
||||
gemma/weights.cc
|
||||
gemma/weights.h
|
||||
io/blob_store.cc
|
||||
io/blob_store.h
|
||||
io/blob_finder.cc
|
||||
io/blob_finder.h
|
||||
io/fields.cc
|
||||
io/fields.h
|
||||
io/io_win.cc
|
||||
|
|
@ -223,7 +223,7 @@ set(GEMMA_TEST_FILES
|
|||
evals/gemma_test.cc
|
||||
gemma/flash_attention_test.cc
|
||||
gemma/tensor_info_test.cc
|
||||
io/blob_store_test.cc
|
||||
io/blob_finder_test.cc
|
||||
io/fields_test.cc
|
||||
ops/bench_matmul.cc
|
||||
ops/dot_test.cc
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "io/blob_store.h"
|
||||
#include "io/blob_finder.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
|
@ -13,8 +13,8 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef THIRD_PARTY_GEMMA_CPP_IO_BLOB_STORE_H_
|
||||
#define THIRD_PARTY_GEMMA_CPP_IO_BLOB_STORE_H_
|
||||
#ifndef THIRD_PARTY_GEMMA_CPP_IO_BLOB_FINDER_H_
|
||||
#define THIRD_PARTY_GEMMA_CPP_IO_BLOB_FINDER_H_
|
||||
|
||||
// Reads/writes arrays of bytes from/to file.
|
||||
|
||||
|
|
@ -48,11 +48,11 @@ struct BlobRange {
|
|||
// faster lookups.
|
||||
// TODO(janwas): rename to BlobFinder or similar.
|
||||
// Thread-safe: it is safe to concurrently call all methods except `CloseFile`.
|
||||
class BlobReader {
|
||||
class BlobFinder {
|
||||
public:
|
||||
// Acquires ownership of `file` (which must be non-null) and reads its header.
|
||||
// Aborts on error.
|
||||
explicit BlobReader(const Path& blob_path);
|
||||
explicit BlobFinder(const Path& blob_path);
|
||||
|
||||
const Path& blob_path() const { return blob_path_; }
|
||||
|
||||
|
|
@ -136,4 +136,4 @@ class BlobWriter {
|
|||
|
||||
} // namespace gcpp
|
||||
|
||||
#endif // THIRD_PARTY_GEMMA_CPP_IO_BLOB_STORE_H_
|
||||
#endif // THIRD_PARTY_GEMMA_CPP_IO_BLOB_FINDER_H_
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include "io/blob_store.h"
|
||||
#include "io/blob_finder.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -32,10 +32,10 @@ namespace gcpp {
|
|||
namespace {
|
||||
|
||||
#if !HWY_TEST_STANDALONE
|
||||
class BlobStoreTest : public testing::Test {};
|
||||
class BlobFinderTest : public testing::Test {};
|
||||
#endif
|
||||
|
||||
TEST(BlobStoreTest, TestReadWrite) {
|
||||
TEST(BlobFinderTest, TestReadWrite) {
|
||||
ThreadingArgs threading_args;
|
||||
ThreadingContext ctx(threading_args);
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ TEST(BlobStoreTest, TestReadWrite) {
|
|||
|
||||
std::fill(buffer.begin(), buffer.end(), 0);
|
||||
|
||||
const BlobReader reader(path);
|
||||
const BlobFinder reader(path);
|
||||
|
||||
HWY_ASSERT_EQ(reader.Keys().size(), 2);
|
||||
HWY_ASSERT_STRING_EQ(reader.Keys()[0].c_str(), keyA.c_str());
|
||||
|
|
@ -92,7 +92,7 @@ TEST(BlobStoreTest, TestReadWrite) {
|
|||
}
|
||||
|
||||
// Ensures padding works for any number of random-sized blobs.
|
||||
TEST(BlobStoreTest, TestNumBlobs) {
|
||||
TEST(BlobFinderTest, TestNumBlobs) {
|
||||
ThreadingArgs threading_args;
|
||||
ThreadingContext ctx(threading_args);
|
||||
hwy::RandomState rng;
|
||||
|
|
@ -126,7 +126,7 @@ TEST(BlobStoreTest, TestNumBlobs) {
|
|||
HWY_ASSERT(blobs.size() == num_blobs);
|
||||
writer.Finalize();
|
||||
|
||||
BlobReader reader(path);
|
||||
BlobFinder reader(path);
|
||||
HWY_ASSERT_EQ(reader.Keys().size(), num_blobs);
|
||||
|
||||
ParallelFor(
|
||||
Loading…
Reference in New Issue