Commit 74a7ef7f authored by Jaikrishnan Menon's avatar Jaikrishnan Menon Committed by Scott Cyphers

Add helper macros to select from a partial set of ranks and element types (#1339)

parent 49d15902
......@@ -108,7 +108,9 @@
else if (R == 15) \
KV = K<ET, 15>; \
else if (R == 16) \
KV = K<ET, 16>;
KV = K<ET, 16>; \
else \
throw ngraph_error("Unsupported rank " #R " for kernel " #K);
// Per-type and rank kernel macro
#define SELECT_KERNEL_BY_RANK(KV, ET, R, K) \
......@@ -155,6 +157,49 @@
else if (ET == element::u64) \
{ \
SELECT_RANK(KV, uint64_t, R, K); \
} \
else \
{ \
throw ngraph_error("Unsupported element type " + ET.c_type_string() + " for kernel " #K); \
}
// Helper macros for a partial set of element types and ranks
// Useful for keeping compilation time and memory usage reasonable
// when the computed expression is complex
#define PARTIAL_SELECT_RANK(KV, ET, R, K) \
if (R == 1) \
KV = K<ET, 1>; \
else if (R == 2) \
KV = K<ET, 2>; \
else if (R == 3) \
KV = K<ET, 3>; \
else if (R == 4) \
KV = K<ET, 4>; \
else if (R == 5) \
KV = K<ET, 5>; \
else if (R == 6) \
KV = K<ET, 6>; \
else \
throw ngraph_error("Unsupported rank " #R " for kernel " #K);
// Partial per-type and rank kernel macro
#define PARTIAL_SELECT_KERNEL_BY_RANK(KV, ET, R, K) \
if (ET == element::f32) \
{ \
PARTIAL_SELECT_RANK(KV, float, R, K); \
} \
else if (ET == element::i8) \
{ \
PARTIAL_SELECT_RANK(KV, int8_t, R, K); \
} \
else if (ET == element::u8) \
{ \
PARTIAL_SELECT_RANK(KV, uint8_t, R, K); \
} \
else \
{ \
throw ngraph_error("Unsupported element type " + ET.c_type_string() + " for kernel " #K); \
}
#define BUILD_UNARY_ELEMWISE_FUNCTOR(OP) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment