158 lines
3.3 KiB
C++
158 lines
3.3 KiB
C++
/* Copyright 2015-2017 Philippe Tillet
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
* a copy of this software and associated documentation files
|
|
* (the "Software"), to deal in the Software without restriction,
|
|
* including without limitation the rights to use, copy, modify, merge,
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
* and to permit persons to whom the Software is furnished to do so,
|
|
* subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be
|
|
* included in all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
*/
|
|
|
|
#ifndef _ISAAC_SYMBOLIC_OPERATIONS_H
|
|
#define _ISAAC_SYMBOLIC_OPERATIONS_H
|
|
|
|
#include <string>
|
|
|
|
namespace isaac
|
|
{
|
|
|
|
|
|
/** @brief Optimization enum for grouping operations into unary or binary operations. Just for optimization of lookups. */
|
|
enum operation_type_family
|
|
{
|
|
INVALID_ = 0,
|
|
|
|
// BLAS1-type
|
|
UNARY_ARITHMETIC,
|
|
BINARY_ARITHMETIC,
|
|
REDUCE,
|
|
|
|
// BLAS2-type
|
|
REDUCE_ROWS,
|
|
REDUCE_COLUMNS,
|
|
|
|
// BLAS3-type
|
|
GEMM
|
|
};
|
|
|
|
/** @brief Enumeration for identifying the possible operations */
|
|
enum operation_type
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FMIN_TYPE,
|
|
ELEMENT_MAX_TYPE,
|
|
ELEMENT_MIN_TYPE,
|
|
|
|
//Products
|
|
OUTER_PROD_TYPE,
|
|
GEMM_NN_TYPE,
|
|
GEMM_TN_TYPE,
|
|
GEMM_NT_TYPE,
|
|
GEMM_TT_TYPE,
|
|
|
|
//Access modifiers
|
|
RESHAPE_TYPE,
|
|
SHIFT_TYPE,
|
|
DIAG_MATRIX_TYPE,
|
|
DIAG_VECTOR_TYPE,
|
|
ACCESS_INDEX_TYPE,
|
|
|
|
|
|
PAIR_TYPE,
|
|
|
|
OPERATOR_FUSE,
|
|
SFOR_TYPE,
|
|
};
|
|
|
|
struct op_element
|
|
{
|
|
op_element();
|
|
op_element(operation_type_family const & _type_family, operation_type const & _type);
|
|
operation_type_family type_family;
|
|
operation_type type;
|
|
};
|
|
|
|
std::string to_string(operation_type type);
|
|
|
|
bool is_assignment(operation_type op);
|
|
bool is_operator(operation_type op);
|
|
bool is_function(operation_type op);
|
|
bool is_cast(operation_type op);
|
|
bool is_indexing(operation_type op);
|
|
|
|
}
|
|
|
|
#endif
|