1 #include "fbgemm_pack_matrix_cache.h" 11 template <
typename ACC_T>
12 shared_ptr<fbgemm::PackBMatrix<int8_t, ACC_T>> GetOrCreateFbgemmPackBMatrix(
13 fbgemm::matrix_op_t trans,
16 const void* orig_data,
17 const int8_t* quantized_data,
20 std::tuple<int, int, const void*>,
21 weak_ptr<fbgemm::PackBMatrix<int8_t, ACC_T>>>
23 static mutex cache_mutex;
30 auto new_packed = make_shared<fbgemm::PackBMatrix<int8_t, ACC_T>>(
39 std::tuple<int, int, const void*> key(m, n, orig_data);
40 std::shared_ptr<fbgemm::PackBMatrix<int8_t, ACC_T>> cache_entry;
42 lock_guard<mutex> lock(cache_mutex);
43 auto itr = cache.find(key);
44 if (itr != cache.end()) {
45 cache_entry = itr->second.lock();
49 if (!cache_entry || !cache_entry->metaEquals(*new_packed) ||
50 !cache_entry->equals(*new_packed)) {
52 lock_guard<mutex> lock(cache_mutex);
53 cache[key] = new_packed;
60 template shared_ptr<fbgemm::PackBMatrix<int8_t, int16_t>>
61 GetOrCreateFbgemmPackBMatrix<int16_t>(
62 fbgemm::matrix_op_t trans,
65 const void* orig_data,
66 const int8_t* quantized_data,
69 template shared_ptr<fbgemm::PackBMatrix<int8_t, int32_t>>
70 GetOrCreateFbgemmPackBMatrix<int32_t>(
71 fbgemm::matrix_op_t trans,
74 const void* orig_data,
75 const int8_t* quantized_data,
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...