ps/base/shard_client.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <cstdint> | ||
| 4 | #include <string> | ||
| 5 | |||
| 6 | #include "base/array.h" | ||
| 7 | #include "base/tensor.h" | ||
| 8 | #include "ps/base/base_client.h" | ||
| 9 | |||
| 10 | namespace recstore { | ||
| 11 | |||
| 12 | // Single-shard parameter-server client. One instance talks to one server | ||
| 13 | // shard; routing/fan-out/merge across shards lives in ShardedClient | ||
| 14 | // (dist_sharded_client.h). All methods return 0 on success and a negative | ||
| 15 | // value on error, except InitEmbeddingTable which returns the non-negative | ||
| 16 | // table tag. | ||
| 17 | class ShardClient : public SparseGradientCommitClient { | ||
| 18 | public: | ||
| 19 | 68 | virtual ~ShardClient() = default; | |
| 20 | |||
| 21 | virtual int GetParameter(const base::ConstArray<uint64_t>& keys, | ||
| 22 | base::RecTensor& values) = 0; | ||
| 23 | virtual int PutParameter(const base::ConstArray<uint64_t>& keys, | ||
| 24 | const base::RecTensor& values) = 0; | ||
| 25 | virtual int UpdateParameter(const std::string& table_name, | ||
| 26 | const base::ConstArray<uint64_t>& keys, | ||
| 27 | const base::RecTensor& grads) = 0; | ||
| 28 | virtual int InitEmbeddingTable(const std::string& table_name, | ||
| 29 | const EmbeddingTableConfig& config) = 0; | ||
| 30 | virtual void Command(PSCommand command) = 0; | ||
| 31 | |||
| 32 | virtual bool | ||
| 33 | ✗ | SaveCheckpoint(const std::string& path, const std::string& metadata) { | |
| 34 | (void)path; | ||
| 35 | (void)metadata; | ||
| 36 | ✗ | return false; | |
| 37 | } | ||
| 38 | virtual bool | ||
| 39 | ✗ | LoadCheckpoint(const std::string& path, const std::string& metadata) { | |
| 40 | (void)path; | ||
| 41 | (void)metadata; | ||
| 42 | ✗ | return false; | |
| 43 | } | ||
| 44 | |||
| 45 | virtual uint64_t | ||
| 46 | PrefetchParameter(const base::ConstArray<uint64_t>& keys) = 0; | ||
| 47 | virtual bool IsPrefetchDone(uint64_t prefetch_id) = 0; | ||
| 48 | virtual void WaitForPrefetch(uint64_t prefetch_id) = 0; | ||
| 49 | virtual bool | ||
| 50 | GetPrefetchResult(uint64_t prefetch_id, base::RecTensor& values) = 0; | ||
| 51 | }; | ||
| 52 | |||
| 53 | } // namespace recstore | ||
| 54 |