Skip to content

Instantly share code, notes, and snippets.

//
// Copyright (c) 2021 Cem Bassoy, cem.bassoy@gmail.com
// Copyright (c) 2021, Amit Singh, amitsingh19975@gmail.com
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// Google and Fraunhofer IOSB, Ettlingen, Germany
@amitsingh19975
amitsingh19975 / main.hpp
Last active October 6, 2020 19:54
Span implementation
namespace ub = boost::numeric::ublas;
int main(){
using namespace ub::literals;
/// dynamic span
{
// span[first: 0, last: 600, step: 4]
auto s1 = ub::span<>(0,600,4);
// span[first: 0, last: 600, step: 4]
@amitsingh19975
amitsingh19975 / meta.hpp
Last active October 6, 2020 13:52
metaprogramming
//
// Copyright (c) 2018-2020, Cem Bassoy, cem.bassoy@gmail.com
// Copyright (c) 2019-2020, Amit Singh, amitsingh19975@gmail.com
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// Google and Fraunhofer IOSB, Ettlingen, Germany
template <std::size_t q, typename TensorEngine1, typename TensorEngine2, std::size_t... Ss1, std::size_t... Ss2>
inline decltype(auto) prod(tensor_core< TensorEngine1 > const &a, tensor_core< TensorEngine2 > const &b,
std::integer_sequence<std::size_t, Ss1...>, std::integer_sequence<std::size_t, Ss2...>)
{
using tensor_type = tensor_core< TensorEngine1 >;
using extents_type_1 = typename tensor_type::extents_type;
using extents_type_2 = typename tensor_core< TensorEngine2 >::extents_type;
using value_type = typename tensor_type::value_type;
using layout_type = typename tensor_type::layout_type;
using size_type = typename extents_type_1::size_type;
@amitsingh19975
amitsingh19975 / eval.hpp
Last active June 5, 2020 14:11
dynamic_optimize
#if !defined(AMT_EVAL_HPP)
#define AMT_EVAL_HPP
#include "exp.hpp"
#include <tuple>
#include <boost/numeric/ublas/tensor.hpp>
#include <boost/fusion/include/for_each.hpp>
#include <boost/fusion/tuple/tuple.hpp>
namespace amt{
@amitsingh19975
amitsingh19975 / exp.hpp
Last active June 5, 2020 08:30
symbol_optimization
#if !defined(AMT_EXP_HPP)
#define AMT_EXP_HPP
#include <tuple>
#include <type_traits>
namespace amt{
template<typename... Ts>
struct expr_list{
@amitsingh19975
amitsingh19975 / main.cpp
Last active April 2, 2020 11:05
decoupling tensor
int main(){
auto s1 = ub::test::tensor_static_container<float,ub::static_extents<1,2,3>, ub::first_order>{};
auto s2 = ub::test::tensor_static_container<float,ub::static_extents<1,2,3>, ub::first_order>{1};
std::cout<<s1.rank()<<'\n';
return 0;
}
//
// Copyright (c) 2018-2019, Cem Bassoy, cem.bassoy@gmail.com
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// Fraunhofer IOSB, Ettlingen, Germany
//
#include <boost/numeric/ublas/functional.hpp>
#include <boost/numeric/ublas/tensor/extents.hpp>
#include <boost/numeric/ublas/tensor/static_extents.hpp>
#include <boost/numeric/ublas/tensor/strides.hpp>
#include <boost/numeric/ublas/tensor/static_strides.hpp>
#include <boost/core/demangle.hpp>
#include <complex>
#include <iostream>
#include <type_traits>
//
// Copyright (c) 2018-2019, Cem Bassoy, cem.bassoy@gmail.com
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
// The authors gratefully acknowledge the support of
// Fraunhofer IOSB, Ettlingen, Germany
//