Skip to content

Commit bfbcf8c

Browse files
committed
Remove dead or duplicate code
1 parent fb5d4cd commit bfbcf8c

File tree

14 files changed

+20
-268
lines changed

14 files changed

+20
-268
lines changed

blackcat/algorithms/algorithms.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static auto function ( \
4545
End end, \
4646
Args... args) \
4747
{ \
48-
return stream.enqueue([&](){std::function(begin, end, args...); }); \
48+
return stream.enqueue([&](){ std::function(begin, end, args...); }); \
4949
}
5050

5151
#define BC_REDUCE_ALGORITHM_DEF(function) \

blackcat/neural_networks/layers/convolution_reference.h

-112
This file was deleted.

blackcat/neural_networks/neural_networks.h

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "layers/output_layer.h"
3131
#include "layers/logging_output_layer.h"
3232
#include "layers/convolution.h"
33-
#include "layers/convolution_reference.h"
3433
#include "layers/max_pooling.h"
3534
#include "layers/flatten.h"
3635
#include "layers/recurrent.h"

blackcat/operations/binary.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ struct Device_Atomic_Mul: Mul_Assign {
197197
BC_ADVANCED_FORWARD_DEF(
198198
static_assert(
199199
std::is_same<void, Lv>::value,
200-
"BLACKCAT_TENSORS: Atomic-reduction mul-assign is currently not available on the GPU");
200+
"BLACKCAT_TENSORS: Atomic-reduction "
201+
"mul-assign is currently not available on the GPU");
201202
)
202203
} device_atomic_mul;
203204

@@ -212,7 +213,8 @@ struct Device_Atomic_Div: Div_Assign {
212213
BC_ADVANCED_FORWARD_DEF(
213214
static_assert(
214215
std::is_same<void, Lv>::value,
215-
"BLACKCAT_TENSORS: Atomic-reduction div-assign is currently not available on the GPU");
216+
"BLACKCAT_TENSORS: Atomic-reduction "
217+
"div-assign is currently not available on the GPU");
216218
)
217219
} device_atomic_div;
218220

blackcat/tensors/iterators/common.h

+4-9
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,9 @@ namespace bc {
1515
namespace tensors {
1616
namespace iterators {
1717

18-
namespace detail {
19-
template<class T>
20-
using query_system_tag = typename T::system_tag;
21-
}
22-
2318
enum direction {
24-
forward = 1,
25-
reverse = -1
19+
forward = 1,
20+
reverse = -1
2621
};
2722

2823
enum initpos {
@@ -31,11 +26,11 @@ enum initpos {
3126
};
3227

3328
template<class T>
34-
struct iterator_traits : std::iterator_traits<T> {
29+
struct iterator_traits: std::iterator_traits<T> {
3530

3631
using system_tag =
3732
bc::traits::conditional_detected_t<
38-
detail::query_system_tag, T, host_tag>;
33+
bc::traits::query_system_tag, T, host_tag>;
3934
};
4035

4136

blackcat/tensors/tensor_common.h

-6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,6 @@
1717
namespace bc {
1818
namespace tensors {
1919

20-
//aliases
21-
template<class... Ts>
22-
auto index(Ts... ts) {
23-
return bc::dim(ts...);
24-
}
25-
2620
template<class> class Tensor_Base;
2721

2822
template<class ExpressionTemplate>

blackcat/tensors/tensor_utility.h

-7
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,6 @@
138138
std::cout << std::endl;
139139
}
140140

141-
void print_block_dimensions() const {
142-
for (int i = 0; i < tensor_dimension; ++i) {
143-
std::cout << "[" << this->block_dimension(i) << "]";
144-
}
145-
std::cout << std::endl;
146-
}
147-
148141
friend std::ostream& operator << (
149142
std::ostream& os,
150143
const Tensor_Base& self) {

blackcat/type_traits/type_traits.h

+1-50
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414
#include "bind.h"
1515

1616
namespace bc {
17-
18-
namespace streams {
19-
20-
//forward declare stream for common_traits
21-
template<class SystemTag>
22-
class Stream;
23-
}
24-
2517
namespace traits {
2618

2719
using namespace bc::traits::common;
@@ -55,7 +47,6 @@ template<class...> using void_t = void;
5547
template<class...> using true_t = true_type;
5648
template<class...> using false_t = false_type;
5749

58-
5950
template<bool cond>
6051
using truth_type = conditional_t<cond, true_type, false_type>;
6152

@@ -117,28 +108,6 @@ using conditional_detected_t =
117108

118109
//----------------------------------
119110

120-
template<class Function, class voider=void>
121-
struct is_compileable : false_type {};
122-
123-
template<class Function>
124-
struct is_compileable<Function,
125-
enable_if_t<
126-
true_v<
127-
decltype(declval<Function>()())>
128-
>
129-
> : true_type {};
130-
131-
template<class Function>
132-
static constexpr bool compileable(Function&&) {
133-
return is_compileable<Function>::value;
134-
}
135-
template<class Function>
136-
static constexpr bool compileable() {
137-
return is_compileable<Function>::value;
138-
}
139-
140-
//----------------------------------
141-
142111

143112
template<class T>
144113
BCINLINE static constexpr bc::size_t max(const T& x) { return x; }
@@ -179,8 +148,7 @@ template<template<class> class Function, class... Ts>
179148
static constexpr bool any_v = any<Function, Ts...>::value;
180149

181150
template<template<class> class Function, class... Ts>
182-
struct none:
183-
conditional_t<any<Function, Ts...>::value, false_type, true_type> {};
151+
struct none: truth_type<any<Function, Ts...>::value> {};
184152

185153
template<template<class> class Function, class... Ts>
186154
static constexpr bool none_v = none<Function, Ts...>::value;
@@ -313,23 +281,6 @@ struct common_traits {
313281
using system_tag =
314282
traits::conditional_detected_t<query_system_tag, T, host_tag>;
315283

316-
static auto select_on_get_stream(const T& type)
317-
{
318-
static_assert(
319-
std::is_same<system_tag, host_tag>::value ||
320-
std::is_same<system_tag, device_tag>::value,
321-
"SystemTag Mismatch");
322-
323-
return traits::constexpr_ternary<defines_get_stream::value>(
324-
bc::traits::bind([](const auto& type) {
325-
return type.get_stream();
326-
}, type),
327-
[]() {
328-
return bc::streams::Stream<system_tag>();
329-
}
330-
);
331-
}
332-
333284
static auto select_on_get_allocator(const T& type)
334285
{
335286
static_assert(

blackcat/utility/any_collections.h renamed to blackcat/utility/any_map.h

-70
Original file line numberDiff line numberDiff line change
@@ -18,76 +18,6 @@ namespace utility {
1818
template<class T>
1919
using Type = bc::traits::Type<T>;
2020

21-
class Any_Set {
22-
23-
using any_ptr = std::shared_ptr<void>;
24-
std::unordered_map<std::string, any_ptr> m_any_map;
25-
26-
template<class T>
27-
static std::string hash(Type<T> type_key) {
28-
return typeid(T).name();
29-
}
30-
31-
public:
32-
33-
template<class T>
34-
bool contains(Type<T> key) const {
35-
return m_any_map.find(hash(key)) != m_any_map.end();
36-
}
37-
38-
template<class T>
39-
auto& operator [] (Type<T> key) {
40-
static auto deleter = [](void* data) {
41-
delete reinterpret_cast<T*>(data);
42-
};
43-
44-
if (!contains(key)) {
45-
void* data = reinterpret_cast<void*>(new T());
46-
m_any_map[hash(key)] = any_ptr(data, deleter);
47-
}
48-
49-
return *reinterpret_cast<T*>(m_any_map[hash(key)].get());
50-
}
51-
52-
template<class T>
53-
auto& at (Type<T> key) {
54-
return this->operator[](key);
55-
}
56-
57-
58-
template<class T, class... DefaultArgs>
59-
auto& get(Type<T> key, DefaultArgs&&... args) {
60-
if (!contains(key)) {
61-
return m_any_map[hash(key)] = T(std::forward(args)...);
62-
} else {
63-
return m_any_map[hash(key)];
64-
}
65-
}
66-
67-
template<class T>
68-
auto& get(Type<T> key, T&& value) {
69-
if (!contains(key)) {
70-
return m_any_map[hash(key)] = value;
71-
} else {
72-
return m_any_map[hash(key)];
73-
}
74-
}
75-
76-
int empty() const { return m_any_map.empty(); }
77-
int size() const { return m_any_map.size(); }
78-
int max_size() const { return m_any_map.size(); }
79-
80-
auto begin() const { return m_any_map.begin(); }
81-
auto end() const { return m_any_map.end(); }
82-
83-
auto begin() { return m_any_map.begin(); }
84-
auto end() { return m_any_map.end(); }
85-
auto cbegin() { return m_any_map.cbegin(); }
86-
auto cend() { return m_any_map.cend(); }
87-
};
88-
89-
90-
9121
template<char... Chars>
9222
struct Name {
9323
std::string name() {

blackcat/utility/utility.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ BC_DEFAULT_MODULE_BODY(utility, Utility)
1414

1515
#include "host.h"
1616
#include "device.h"
17-
#include "any_collections.h"
18-
17+
#include "any_map.h"
1918

2019
#endif /* UTILITY_H_ */
2120

examples/mnist_test_convolutional/mnist_test.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int percept_MNIST(System system_tag, std::string mnist_dataset,
1818
system_tag,
1919
bc::dim(28,28,1), //input dimension
2020
bc::dim(3,3), //pool dimensions
21-
bc::dim(1,1)), //pad_dimensions, out dims == (input_dims + pad_dims*2) / krnl_dims
21+
bc::dim(1,1)), //pad_dimensions
2222
bc::nn::convolution(
2323
system_tag,
2424
bc::dim(10, 10,1), //input_image shape

0 commit comments

Comments
 (0)