ct2rs 0.8.2

Rust bindings for OpenNMT/CTranslate2
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "ctranslate2/allocator.h"

#include "device_dispatch.h"

namespace ctranslate2 {

  Allocator& get_allocator(Device device) {
    Allocator* allocator = nullptr;
    DEVICE_DISPATCH(device, allocator = &get_allocator<D>());
    if (!allocator)
      throw std::runtime_error("No allocator defined for device " + device_to_str(device));
    return *allocator;
  }

}