This is a C wrapper API for TTC.
cmake 2.8+
- TTC
- python
To build the document, doxygen
is also needed.
Under the project directory, execute:
mkdir build; cd build
Currently, three customized options are used in CMake scripts. They are:
-
Building the test/demo program:
BUILD_TEST=[ON|OFF]
, default:OFF
. -
Building the documents:
BUILD_DOC=[ON|OFF]
, default:OFF
. -
Choosing building type:
BUILD_TYPE=[RELEASE|DEBUG]
, defaultRELEASE
.
E.g.
cmake -D BUILD_TEST=ON -D BUILD_DOC=ON ..
Then, execute make
to build the library, and make doc
to build the document.
Here is a short (incomplete) example which illustrates the usage of this API on the example of perm=2,1,0 for tensors of size 100x200x300:
#include <string.h>
// include header
#include <ttc_c.h>
// Create handle
ttc_handler_s *ttc_handle = ttc_init();
// Create transpose parameter
ttc_param_s param = { .alpha.s = 1.0, .beta.s = 1.0, .lda = NULL, .ldb = NULL, .perm = NULL, .size = NULL, .loop_perm = NULL, .dim = 4};
uint32_t perm[] = { 2, 1, 0};
uint32_t size[] = { 100, 200, 300};
param.perm = perm;
param.size = size;
// Set TTC options (THIS IS OPTIONAL)
int maxImplemenations = 100;
ttc_set_opt( ttc_handle, TTC_OPT_MAX_IMPL, (void*)&maxImplemenations, 1 );
int numThreads = 24;
ttc_set_opt( ttc_handle, TTC_OPT_NUM_THREADS, (void*)&numThreads, 1 );
char affinity[] = "compact,1";
ttc_set_opt( ttc_handle, TTC_OPT_AFFINITY, (void*)affinity, strlen(affinity) );
// Allocating memory for tensors
void *A = (void *)malloc(sizeof(float) * 100*200*300);
void *B = (void *)malloc(sizeof(float) * 100*200*300);
// Execute transpose
ttc_transpose(ttc_handle, ¶m, A, B);
For further examples please have a look at the provided tests.