Skip to content

Commit 2ae43a4

Browse files
Chenyu Zhangfacebook-github-bot
authored andcommitted
handle inference buck gpu deps (#4358)
Summary: X-link: facebookresearch/FBGEMM#1425 **Context** Add a gpu compiler flags to ignore gpu dependency for cpu buck target. This is to unblock the cpu bolt package build. Reviewed By: emlin Differential Revision: D76228086
1 parent c63f643 commit 2ae43a4

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

fbgemm_gpu/src/ssd_split_embeddings_cache/kv_db_table_batched_embeddings.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
#include <folly/coro/Collect.h>
1212
#include <algorithm>
1313
#include "common/time/Time.h"
14+
#ifdef FBGEMM_USE_GPU
1415
#include "kv_db_cuda_utils.h"
16+
#endif
1517
#include "torch/csrc/autograd/record_function_ops.h"
1618
#ifdef FBGEMM_FBCODE
1719
#include <folly/stop_watch.h>
@@ -411,6 +413,7 @@ void EmbeddingKVDB::get_cuda(
411413
const at::Tensor& indices,
412414
const at::Tensor& weights,
413415
const at::Tensor& count) {
416+
#ifdef FBGEMM_USE_GPU
414417
auto rec = torch::autograd::profiler::record_function_enter_new(
415418
"## EmbeddingKVDB::get_cuda ##");
416419
check_tensor_type_consistency(indices, weights);
@@ -424,6 +427,7 @@ void EmbeddingKVDB::get_cuda(
424427
functor,
425428
0));
426429
rec->record.end();
430+
#endif
427431
}
428432

429433
void EmbeddingKVDB::set_cuda(
@@ -432,6 +436,7 @@ void EmbeddingKVDB::set_cuda(
432436
const at::Tensor& count,
433437
const int64_t timestep,
434438
const bool is_bwd) {
439+
#ifdef FBGEMM_USE_GPU
435440
auto rec = torch::autograd::profiler::record_function_enter_new(
436441
"## EmbeddingKVDB::set_cuda ##");
437442
check_tensor_type_consistency(indices, weights);
@@ -447,14 +452,15 @@ void EmbeddingKVDB::set_cuda(
447452
functor,
448453
0));
449454
rec->record.end();
455+
#endif
450456
}
451457

452458
void EmbeddingKVDB::stream_cuda(
453459
const at::Tensor& indices,
454460
const at::Tensor& weights,
455461
const at::Tensor& count,
456462
bool blocking_tensor_copy) {
457-
#ifdef FBGEMM_FBCODE
463+
#ifdef FBGEMM_USE_GPU
458464
auto rec = torch::autograd::profiler::record_function_enter_new(
459465
"## EmbeddingKVDB::stream_cuda ##");
460466
check_tensor_type_consistency(indices, weights);
@@ -472,7 +478,7 @@ void EmbeddingKVDB::stream_cuda(
472478
}
473479

474480
void EmbeddingKVDB::stream_sync_cuda() {
475-
#ifdef FBGEMM_FBCODE
481+
#ifdef FBGEMM_USE_GPU
476482
auto rec = torch::autograd::profiler::record_function_enter_new(
477483
"## EmbeddingKVDB::stream_sync_cuda ##");
478484
// take reference to self to avoid lifetime issues.

fbgemm_gpu/src/ssd_split_embeddings_cache/kv_db_table_batched_embeddings.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
#include <rocksdb/slice_transform.h>
3535
#include <rocksdb/table.h>
3636
#include <rocksdb/table_properties.h>
37-
37+
#ifdef FBGEMM_USE_GPU
3838
#include <ATen/cuda/CUDAContext.h>
3939
#include <cuda_runtime.h>
40+
#endif
4041

4142
#include <folly/coro/Task.h>
4243
#include "../dram_kv_embedding_cache/feature_evict.h"

0 commit comments

Comments
 (0)