1#ifndef TMVA_SOFIE_SOFIE_COMMON
2#define TMVA_SOFIE_SOFIE_COMMON
16namespace Experimental{
22 UNDEFINED = 0,
FLOAT = 1,
UNINT8 = 2,
INT8 = 3,
UINT16 = 4,
INT16 = 5,
INT32 = 6,
INT64 = 7,
STRING = 8,
BOOL = 9,
107T*
Unidirectional_broadcast(
const T* original_data,
const std::vector<size_t> original_shape,
const std::vector<size_t> target_shape);
108std::string
Clean_name(std::string input_tensor_name);
114 return static_cast<unsigned>(
a) <
static_cast<unsigned>(
b);
138void Im2col(
const T *data_im,
const int channels,
const int height,
const int width,
const int kernel_h,
139 const int kernel_w,
const int pad_h,
const int pad_w,
const int stride_h,
const int stride_w,
140 const int dilation_h,
const int dilation_w, T *data_col)
142 const int output_h = (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1;
143 const int output_w = (
width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1;
144 const int channel_size = height *
width;
145 for (
int channel = channels; channel--; data_im += channel_size) {
146 for (
int kernel_row = 0; kernel_row < kernel_h; kernel_row++) {
147 for (
int kernel_col = 0; kernel_col < kernel_w; kernel_col++) {
148 int input_row = -pad_h + kernel_row * dilation_h;
149 for (
int output_rows = output_h; output_rows; output_rows--) {
151 for (
int output_cols = output_w; output_cols; output_cols--) {
155 int input_col = -pad_w + kernel_col * dilation_w;
156 for (
int output_col = output_w; output_col; output_col--) {
158 *(data_col++) = data_im[input_row *
width + input_col];
162 input_col += stride_w;
165 input_row += stride_h;
175 const int depth,
const int height,
const int width,
176 const int kernel_d,
const int kernel_h,
const int kernel_w,
177 const int pad_d,
const int pad_h,
const int pad_w,
178 const int stride_d,
const int stride_h,
const int stride_w,
179 const int dilation_d,
const int dilation_h,
const int dilation_w, T *data_col)
181 const int output_h = (height + 2 * pad_h - (dilation_h * (kernel_h - 1) + 1)) / stride_h + 1;
182 const int output_w = (
width + 2 * pad_w - (dilation_w * (kernel_w - 1) + 1)) / stride_w + 1;
183 const int output_d = (depth + 2 * pad_d - (dilation_d * (kernel_d - 1) + 1)) / stride_d + 1;
184 const int channel_size = height *
width * depth;
186 for (
int channel = channels; channel--; data_im += channel_size) {
187 for (
int kernel_depth = 0; kernel_depth < kernel_d; kernel_depth++) {
188 for (
int kernel_row = 0; kernel_row < kernel_h; kernel_row++) {
189 for (
int kernel_col = 0; kernel_col < kernel_w; kernel_col++) {
190 int input_dep = -pad_d + kernel_depth * dilation_d;
191 for (
int output_dep = output_d; output_dep; output_dep--) {
193 for (
int output_rows = output_h; output_rows; output_rows--) {
194 for (
int output_cols = output_w; output_cols; output_cols--) {
199 int input_row = -pad_h + kernel_row * dilation_h;
200 for (
int output_rows = output_h; output_rows; output_rows--) {
202 for (
int output_cols = output_w; output_cols; output_cols--) {
206 int input_col = -pad_w + kernel_col * dilation_w;
207 for (
int output_col = output_w; output_col; output_col--) {
209 *(data_col++) = data_im[input_dep *
width * height + input_row *
width + input_col];
213 input_col += stride_w;
216 input_row += stride_h;
219 input_dep += stride_d;
232extern "C" void sgemm_(
const char * transa,
const char * transb,
const int *
m,
const int *
n,
const int * k,
233 const float * alpha,
const float * A,
const int * lda,
const float * B,
const int * ldb,
234 const float * beta,
float * C,
const int * ldc);
include TDocParser_001 C image html pict1_TDocParser_001 png width
void sgemm_(const char *transa, const char *transb, const int *m, const int *n, const int *k, const float *alpha, const float *A, const int *lda, const float *B, const int *ldb, const float *beta, float *C, const int *ldc)
void Im2col_3d(const T *data_im, const int channels, const int depth, const int height, const int width, const int kernel_d, const int kernel_h, const int kernel_w, const int pad_d, const int pad_h, const int pad_w, const int stride_d, const int stride_h, const int stride_w, const int dilation_d, const int dilation_h, const int dilation_w, T *data_col)
3d implementation
std::string Clean_name(std::string input_tensor_name)
bool is_a_ge_zero_and_a_lt_b(int a, int b)
function to check if a >> 0 and a < MAX using a single comparison / use trick casting to unsigned val...
void Im2col(const T *data_im, const int channels, const int height, const int width, const int kernel_h, const int kernel_w, const int pad_h, const int pad_w, const int stride_h, const int stride_w, const int dilation_h, const int dilation_w, T *data_col)
im2col : efficient function to re-arrange input data of convolution to a matrix that can be used by B...
T * Unidirectional_broadcast(const T *original_data, const std::vector< size_t > original_shape, const std::vector< size_t > target_shape)
std::vector< Dim > ConvertShapeToDim(std::vector< size_t > shape)
ETensorType GetTemplatedType(T)
std::string ConvertShapeToString(std::vector< size_t > shape)
std::string ConvertTypeToString(ETensorType type)
ETensorType ConvertStringToType(std::string type)
std::size_t ConvertShapeToLength(std::vector< size_t > shape)
create variable transformations
std::shared_ptr< void > fData
std::vector< std::size_t > fShape
void CastSharedToPersistent()
void CastPersistentToShared()
std::vector< size_t > shape