A computing service is an object that provides hardware transparency so you can easily change the hardware on which the code will be executed.

CPU

compserv eddl::CS_CPU(int th = -1, const string &mem = "full_mem")

Executes the code in the CPU.

Parameters
  • th – CPU Threads. (if ‘-1’, use all threads)

  • mem – Indicates the memory consumption of the model. One of “full_mem” (default), “mid_mem” or “low_mem”.

Returns

The computer service itself.

Example:

build(net,
      sgd(0.01),            // Optimizer
      {"soft_cross_entropy"},   // Losses
      {"categorical_accuracy"}, // Metrics
      CS_CPU(4),                // CPU with 4 threads
);

GPU

compserv eddl::CS_GPU(const vector<int> &g, const string &mem = "full_mem")

Executes the code in the GPU.

Parameters
  • g – Vector of bools to set which GPUs will be used (1=on, 0=off)

  • mem – Indicates the memory consumption of the model. One of “full_mem” (default), “mid_mem” or “low_mem”.

Returns

The computer service itself.

compserv eddl::CS_GPU(const vector<int> &g, int lsb, const string &mem = "full_mem")

Executes the code in the GPU.

Parameters
  • g – Vector of bools to set which GPUs will be used (1=on, 0=off)

  • lsb – (Multi-gpu setting) Number of batches to run before synchronizing the weights of the different GPUs

  • mem – Indicates the memory consumption of the model. One of “full_mem” (default), “mid_mem” or “low_mem”.

Returns

The computer service itself.

Example:

build(imported_net,
      sgd(0.01),            // Optimizer
      {"soft_cross_entropy"},   // Losses
      {"categorical_accuracy"}, // Metrics
      CS_GPU({1}),              // one GPU
      false
);

FPGA

compserv eddl::CS_FPGA(const vector<int> &f, int lsb = 1)

Executes the code in the FPGA.

Parameters
  • f – Vector of bools to set which FPGAs will be used (1=on, 0=off)

  • lsb – (Multi-fpga setting) Number of batches to run before synchronizing the weights of the different FPGAs

Returns

The computer service itself.

build(imported_net,
      sgd(0.01),            // Optimizer
      {"soft_cross_entropy"},   // Losses
      {"categorical_accuracy"}, // Metrics
      CS_FPGA({1}),              // FPGA
);

COMPSS

compserv eddl::CS_COMPSS(const string &filename)

Executes the code through the COMP Superscalar (COMPSs) framework.

Parameters

filename – File with the setup specification

Returns

The computer service itself.

build(imported_net,
      sgd(0.01f),                   // Optimizer
      {"soft_cross_entropy"},          // Losses
      {"categorical_accuracy"},        // Metrics
      CS_COMPSS("filename.cfg"),       // COMPSS config file
);

Serialization

A computing service configuration can be stored and loaded to create a new equivalent computing service. To do it we serialize the configuration using protocol buffers and the ONNX standard definition.

Export to file

void save_compserv_to_onnx_file(CompServ *cs, string path)

Saves the configuration of a computing service using the ONNX format. It will contain the computing service type and configuration of devices.

Parameters
  • cs – CompServ to be saved

  • path – Path to the file where the computing service configuration will be saved

Returns

(void)

Example:

compserv cs = CS_GPU({1});
save_compserv_to_onnx_file(cs, "my_cs.onnx");

Import from file

CompServ *import_compserv_from_onnx_file(string path)

Creates a CompServ from the definition provided in an ONNX file. The ONNX will provide the CompServ type and its configuration.

Parameters

path – Path to the file where the CompServ configuration is saved

Returns

CompServ*

Example:

compserv cs = import_compserv_from_onnx_file("my_cs.onnx");