-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathtable_utils.hpp
More file actions
69 lines (60 loc) · 2.93 KB
/
Copy pathtable_utils.hpp
File metadata and controls
69 lines (60 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <memory>
#include <string>
#include <nlohmann/json.hpp>
#include "include/common.hpp"
#include "include/host_table.hpp" // host_table_ptr_t
#include "include/nve_types.hpp"
#include "include/table.hpp"
#include "include/serialization.hpp"
namespace nve {
// Loads the plugin shared object named by plugin_name, builds the table
// factory from the plugin-specific factory_config, and produces the
// underlying table with table_config.
table_ptr_t create_table_from_plugin(const std::string& plugin_name,
const nlohmann::json& factory_config,
const nlohmann::json& table_config,
table_id_t table_id = 1000);
// Streams (key, value) pairs from already-opened tensor-file readers into
// `table` in batches of `batch_size` rows. row_bytes is the size of a single
// value row.
//
// Operations are submitted asynchronously on `ctx`'s stream; the caller is
// responsible for ensuring `ctx` outlives in-flight work — typically by
// calling `ctx->wait()` before letting a one-shot context go out of scope.
//
// `table` and `ctx` are passed by value (not const&) — these functions
// mutate both the underlying nve::Table and ctx-bound buffers.
void insert_keys_from_tensor_file(table_ptr_t table,
context_ptr_t ctx,
std::shared_ptr<TensorFileFormatBase> keys_reader,
std::shared_ptr<TensorFileFormatBase> values_reader,
uint64_t row_bytes,
uint64_t batch_size);
// Convenience wrapper: open the keys/values files, dispatch on extension
// (.npy → NumpyTensorFileFormat, .dyn → BinaryTensorFileFormat), and call
// insert_keys_from_tensor_file. Same async/wait contract as
// insert_keys_from_tensor_file. Keys are assumed to be int64.
void insert_keys_from_filepath(table_ptr_t table,
context_ptr_t ctx,
const std::string& keys_path,
const std::string& values_path,
uint64_t row_bytes,
uint64_t batch_size);
} // namespace nve