Skip to content

Commit 78d6edc

Browse files
committed
Rename shapeN_concrete back to shapeN
1 parent 22aa76c commit 78d6edc

25 files changed

+168
-168
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int main()
144144
{
145145
const auto model = fdeep::load_model("fdeep_model.json");
146146
const auto result = model.predict(
147-
{fdeep::tensor3(fdeep::shape3_concrete(4, 1, 1), {1, 2, 3, 4})});
147+
{fdeep::tensor3(fdeep::shape3(4, 1, 1), {1, 2, 3, 4})});
148148
std::cout << fdeep::show_tensor3s(result) << std::endl;
149149
}
150150
```

include/fdeep/convolution.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ namespace fdeep { namespace internal
2121
struct im2col_filter_matrix
2222
{
2323
RowMajorMatrixXf mat_;
24-
shape3_concrete filter_shape_;
24+
shape3 filter_shape_;
2525
std::size_t filter_count_;
2626
};
2727

2828
inline im2col_filter_matrix generate_im2col_filter_matrix(
2929
const std::vector<filter>& filters)
3030
{
3131
assertion(fplus::all_the_same_on(
32-
fplus_c_mem_fn_t(filter, shape, shape3_concrete), filters),
32+
fplus_c_mem_fn_t(filter, shape, shape3), filters),
3333
"all filters must have the same shape");
3434

3535
const std::size_t fz = filters.front().shape().depth_;
@@ -133,7 +133,7 @@ inline tensor3 convolve_im2col(
133133
// https://stackoverflow.com/questions/48644724/multiply-two-eigen-matrices-directly-into-memory-of-target-matrix
134134
out_mat_map.noalias() = filter_mat.mat_ * a;
135135

136-
return tensor3(shape3_concrete(out_depth, out_height, out_width), res_vec);
136+
return tensor3(shape3(out_depth, out_height, out_width), res_vec);
137137
}
138138

139139
enum class padding { valid, same };
@@ -151,11 +151,11 @@ struct convolution_config
151151
};
152152

153153
inline convolution_config preprocess_convolution(
154-
const shape2_concrete& filter_shape,
155-
const shape2_concrete& strides,
154+
const shape2& filter_shape,
155+
const shape2& strides,
156156
padding pad_type,
157157
bool use_offset,
158-
const shape3_concrete& input_shape)
158+
const shape3& input_shape)
159159
{
160160
// https://www.tensorflow.org/api_guides/python/nn#Convolution
161161
const int filter_height = static_cast<int>(filter_shape.height_);
@@ -217,7 +217,7 @@ inline convolution_config preprocess_convolution(
217217
}
218218

219219
inline tensor3 convolve(
220-
const shape2_concrete& strides,
220+
const shape2& strides,
221221
const padding& pad_type,
222222
bool use_offset,
223223
const im2col_filter_matrix& filter_mat,
@@ -247,14 +247,14 @@ inline tensor3 convolve(
247247
}
248248

249249
inline tensor3 convolve_transpose(
250-
const shape2_concrete&,
250+
const shape2&,
251251
const padding&,
252252
bool,
253253
const std::vector<filter>&,
254254
const tensor3&)
255255
{
256256
raise_error("convolve_transpose not yet implemented");
257-
return tensor3(shape3_concrete(0, 0, 0), 0);
257+
return tensor3(shape3(0, 0, 0), 0);
258258
}
259259

260260
} } // namespace fdeep, namespace internal

include/fdeep/fdeep.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include "fdeep/tensor3.hpp"
1616
#include "fdeep/tensor3_pos.hpp"
1717
#include "fdeep/node.hpp"
18-
#include "fdeep/shape2_concrete.hpp"
18+
#include "fdeep/shape2.hpp"
1919
#include "fdeep/shape2_variable.hpp"
20-
#include "fdeep/shape3_concrete.hpp"
20+
#include "fdeep/shape3.hpp"
2121
#include "fdeep/shape3_variable.hpp"
2222
#include "fdeep/layers/add_layer.hpp"
2323
#include "fdeep/layers/average_layer.hpp"

include/fdeep/filter.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "fdeep/common.hpp"
1010

1111
#include "fdeep/tensor3.hpp"
12-
#include "fdeep/shape3_concrete.hpp"
12+
#include "fdeep/shape3.hpp"
1313

1414
#include <cassert>
1515
#include <cstddef>
@@ -24,7 +24,7 @@ class filter
2424
filter(const tensor3& m, float_type bias) : m_(m), bias_(bias)
2525
{
2626
}
27-
const shape3_concrete& shape() const
27+
const shape3& shape() const
2828
{
2929
return m_.shape();
3030
}
@@ -58,15 +58,15 @@ class filter
5858

5959
typedef std::vector<filter> filter_vec;
6060

61-
inline filter dilate_filter(const shape2_concrete& dilation_rate, const filter& undilated)
61+
inline filter dilate_filter(const shape2& dilation_rate, const filter& undilated)
6262
{
6363
return filter(dilate_tensor3(dilation_rate, undilated.get_tensor3()),
6464
undilated.get_bias());
6565
}
6666

6767
inline filter_vec generate_filters(
68-
const shape2_concrete& dilation_rate,
69-
const shape3_concrete& filter_shape, std::size_t k,
68+
const shape2& dilation_rate,
69+
const shape3& filter_shape, std::size_t k,
7070
const float_vec& weights, const float_vec& bias)
7171
{
7272
filter_vec filters(k, filter(tensor3(filter_shape, 0), 0));

include/fdeep/import_model.hpp

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -68,37 +68,37 @@ inline shape3_variable create_shape3_variable(const nlohmann::json& data)
6868
fplus::nothing<std::size_t>()); // Should never be called
6969
}
7070

71-
inline shape3_concrete create_shape3_concrete(const nlohmann::json& data)
71+
inline shape3 create_shape3(const nlohmann::json& data)
7272
{
73-
assertion(data.is_array(), "shape3_concrete needs to be an array");
73+
assertion(data.is_array(), "shape3 needs to be an array");
7474
assertion(data.size() > 0, "need at least one dimension");
7575
//TODO: offset still needed?
7676
const std::size_t offset = data.front().is_null() ? 1 : 0;
7777
if (data.size() == 1 + offset)
78-
return shape3_concrete(0, 0, data[0 + offset]);
78+
return shape3(0, 0, data[0 + offset]);
7979
if (data.size() == 2 + offset)
80-
return shape3_concrete(0, data[0 + offset], data[1 + offset]);
80+
return shape3(0, data[0 + offset], data[1 + offset]);
8181
if (data.size() == 3 + offset)
82-
return shape3_concrete(data[0 + offset], data[1 + offset], data[2 + offset]);
83-
raise_error("shape3_concrete needs 1, 2 or 3 dimensions");
84-
return shape3_concrete(0, 0, 0); // Should never be called
82+
return shape3(data[0 + offset], data[1 + offset], data[2 + offset]);
83+
raise_error("shape3 needs 1, 2 or 3 dimensions");
84+
return shape3(0, 0, 0); // Should never be called
8585
}
8686

87-
inline shape2_concrete create_shape2_concrete(const nlohmann::json& data)
87+
inline shape2 create_shape2(const nlohmann::json& data)
8888
{
8989
if (data.is_array())
9090
{
9191
assertion(data.size() == 1 || data.size() == 2,
92-
"invalid number of dimensions in shape2_concrete");
92+
"invalid number of dimensions in shape2");
9393
if (data.size() == 1)
94-
return shape2_concrete(1, data[0]);
94+
return shape2(1, data[0]);
9595
else
96-
return shape2_concrete(data[0], data[1]);
96+
return shape2(data[0], data[1]);
9797
}
9898
else
9999
{
100100
const std::size_t width = data;
101-
return shape2_concrete(1, width);
101+
return shape2(1, width);
102102
}
103103
}
104104

@@ -146,7 +146,7 @@ inline float_vec decode_floats(const nlohmann::json& data)
146146

147147
inline tensor3 create_tensor3(const nlohmann::json& data)
148148
{
149-
const shape3_concrete shape = create_shape3_concrete(data["shape"]);
149+
const shape3 shape = create_shape3(data["shape"]);
150150
return tensor3(shape, decode_floats(data["values"]));
151151
}
152152

@@ -222,8 +222,8 @@ inline layer_ptr create_conv_2d_layer(const get_param_f& get_param,
222222
const std::string padding_str = data["config"]["padding"];
223223
const auto pad_type = create_padding(padding_str);
224224

225-
const shape2_concrete strides = create_shape2_concrete(data["config"]["strides"]);
226-
const shape2_concrete dilation_rate = create_shape2_concrete(data["config"]["dilation_rate"]);
225+
const shape2 strides = create_shape2(data["config"]["strides"]);
226+
const shape2 dilation_rate = create_shape2(data["config"]["dilation_rate"]);
227227

228228
const auto filter_count = create_size_t(data["config"]["filters"]);
229229
float_vec bias(filter_count, 0);
@@ -233,12 +233,12 @@ inline layer_ptr create_conv_2d_layer(const get_param_f& get_param,
233233
assertion(bias.size() == filter_count, "size of bias does not match");
234234

235235
const float_vec weights = decode_floats(get_param(name, "weights"));
236-
const shape2_concrete kernel_size = create_shape2_concrete(data["config"]["kernel_size"]);
236+
const shape2 kernel_size = create_shape2(data["config"]["kernel_size"]);
237237
assertion(weights.size() % kernel_size.area() == 0,
238238
"invalid number of weights");
239239
const std::size_t filter_depths =
240240
weights.size() / (kernel_size.area() * filter_count);
241-
const shape3_concrete filter_shape(
241+
const shape3 filter_shape(
242242
filter_depths, kernel_size.height_, kernel_size.width_);
243243

244244
const bool padding_valid_uses_offset_depth_1 =
@@ -263,7 +263,7 @@ inline layer_ptr create_conv_2d_transpose_layer(const get_param_f& get_param,
263263
const std::string padding_str = data["config"]["padding"];
264264
const auto pad_type = create_padding(padding_str);
265265

266-
const shape2_concrete strides = create_shape2_concrete(data["config"]["strides"]);
266+
const shape2 strides = create_shape2(data["config"]["strides"]);
267267

268268
const auto filter_count = create_size_t(data["config"]["filters"]);
269269
float_vec bias(filter_count, 0);
@@ -273,12 +273,12 @@ inline layer_ptr create_conv_2d_transpose_layer(const get_param_f& get_param,
273273
assertion(bias.size() == filter_count, "size of bias does not match");
274274

275275
const float_vec weights = decode_floats(get_param(name, "weights"));
276-
const shape2_concrete kernel_size = create_shape2_concrete(data["config"]["kernel_size"]);
276+
const shape2 kernel_size = create_shape2(data["config"]["kernel_size"]);
277277
assertion(weights.size() % kernel_size.area() == 0,
278278
"invalid number of weights");
279279
const std::size_t filter_depths =
280280
weights.size() / (kernel_size.area() * filter_count);
281-
const shape3_concrete filter_shape(
281+
const shape3 filter_shape(
282282
filter_depths, kernel_size.height_, kernel_size.width_);
283283

284284
const bool padding_valid_uses_offset_depth_1 =
@@ -303,8 +303,8 @@ inline layer_ptr create_separable_conv_2D_layer(const get_param_f& get_param,
303303
const std::string padding_str = data["config"]["padding"];
304304
const auto pad_type = create_padding(padding_str);
305305

306-
const shape2_concrete strides = create_shape2_concrete(data["config"]["strides"]);
307-
const shape2_concrete dilation_rate = create_shape2_concrete(data["config"]["dilation_rate"]);
306+
const shape2 strides = create_shape2(data["config"]["strides"]);
307+
const shape2 dilation_rate = create_shape2(data["config"]["dilation_rate"]);
308308

309309
const auto filter_count = create_size_t(data["config"]["filters"]);
310310
float_vec bias(filter_count, 0);
@@ -317,7 +317,7 @@ inline layer_ptr create_separable_conv_2D_layer(const get_param_f& get_param,
317317
get_param(name, "slice_weights"));
318318
const float_vec stack_weights = decode_floats(
319319
get_param(name, "stack_weights"));
320-
const shape2_concrete kernel_size = create_shape2_concrete(data["config"]["kernel_size"]);
320+
const shape2 kernel_size = create_shape2(data["config"]["kernel_size"]);
321321
assertion(slice_weights.size() % kernel_size.area() == 0,
322322
"invalid number of weights");
323323
assertion(stack_weights.size() % filter_count == 0,
@@ -326,7 +326,7 @@ inline layer_ptr create_separable_conv_2D_layer(const get_param_f& get_param,
326326
const std::size_t stack_output_depths_1 =
327327
stack_weights.size() / input_depth;
328328
assertion(stack_output_depths_1 == filter_count, "invalid weights sizes");
329-
const shape3_concrete filter_shape(1,
329+
const shape3 filter_shape(1,
330330
kernel_size.height_, kernel_size.width_);
331331
float_vec bias_0(input_depth, 0);
332332
const bool padding_valid_uses_offset_depth_1 =
@@ -351,16 +351,16 @@ inline layer_ptr create_depthwise_conv_2D_layer(const get_param_f& get_param,
351351
const std::string padding_str = data["config"]["padding"];
352352
const auto pad_type = create_padding(padding_str);
353353

354-
const shape2_concrete strides = create_shape2_concrete(data["config"]["strides"]);
355-
const shape2_concrete dilation_rate = create_shape2_concrete(data["config"]["dilation_rate"]);
354+
const shape2 strides = create_shape2(data["config"]["strides"]);
355+
const shape2 dilation_rate = create_shape2(data["config"]["dilation_rate"]);
356356

357357
const float_vec slice_weights = decode_floats(
358358
get_param(name, "slice_weights"));
359-
const shape2_concrete kernel_size = create_shape2_concrete(data["config"]["kernel_size"]);
359+
const shape2 kernel_size = create_shape2(data["config"]["kernel_size"]);
360360
assertion(slice_weights.size() % kernel_size.area() == 0,
361361
"invalid number of weights");
362362
const std::size_t input_depth = slice_weights.size() / kernel_size.area();
363-
const shape3_concrete filter_shape(1,
363+
const shape3 filter_shape(1,
364364
kernel_size.height_, kernel_size.width_);
365365
const std::size_t filter_count = input_depth;
366366
float_vec bias(filter_count, 0);
@@ -423,8 +423,8 @@ inline layer_ptr create_max_pooling_2d_layer(
423423
const get_param_f&, const get_global_param_f& get_global_param,
424424
const nlohmann::json& data, const std::string& name)
425425
{
426-
const auto pool_size = create_shape2_concrete(data["config"]["pool_size"]);
427-
const auto strides = create_shape2_concrete(data["config"]["strides"]);
426+
const auto pool_size = create_shape2(data["config"]["pool_size"]);
427+
const auto strides = create_shape2(data["config"]["strides"]);
428428
const std::string padding_str = data["config"]["padding"];
429429
const auto pad_type = create_padding(padding_str);
430430
const bool padding_valid_uses_offset =
@@ -441,8 +441,8 @@ inline layer_ptr create_average_pooling_2d_layer(
441441
const get_param_f&, const get_global_param_f& get_global_param,
442442
const nlohmann::json& data, const std::string& name)
443443
{
444-
const auto pool_size = create_shape2_concrete(data["config"]["pool_size"]);
445-
const auto strides = create_shape2_concrete(data["config"]["strides"]);
444+
const auto pool_size = create_shape2(data["config"]["pool_size"]);
445+
const auto strides = create_shape2(data["config"]["strides"]);
446446
const std::string padding_str = data["config"]["padding"];
447447
const auto pad_type = create_padding(padding_str);
448448
const bool padding_valid_uses_offset =
@@ -473,7 +473,7 @@ inline layer_ptr create_upsampling_2d_layer(
473473
const get_param_f&, const get_global_param_f&, const nlohmann::json& data,
474474
const std::string& name)
475475
{
476-
const auto scale_factor = create_shape2_concrete(data["config"]["size"]);
476+
const auto scale_factor = create_shape2(data["config"]["size"]);
477477
return std::make_shared<upsampling_2d_layer>(name, scale_factor);
478478
}
479479

include/fdeep/layers/average_pooling_2d_layer.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ FDEEP_FORCE_INLINE tensor3 average_pool_2d(
2424
const float_type invalid = std::numeric_limits<float_type>::lowest();
2525

2626
const auto conv_cfg = preprocess_convolution(
27-
shape2_concrete(pool_height, pool_width),
28-
shape2_concrete(strides_y, strides_x),
27+
shape2(pool_height, pool_width),
28+
shape2(strides_y, strides_x),
2929
pad_type, use_offset, in.shape());
3030

3131
int pad_top_int = static_cast<int>(conv_cfg.pad_top_);
@@ -35,7 +35,7 @@ FDEEP_FORCE_INLINE tensor3 average_pool_2d(
3535
const std::size_t out_height = conv_cfg.out_height_;
3636
const std::size_t out_width = conv_cfg.out_width_;
3737

38-
tensor3 out(shape3_concrete(in.shape().depth_, out_height, out_width), 0);
38+
tensor3 out(shape3(in.shape().depth_, out_height, out_width), 0);
3939
for (std::size_t z = 0; z < out.shape().depth_; ++z)
4040
{
4141
for (std::size_t y = 0; y < out.shape().height_; ++y)
@@ -70,7 +70,7 @@ class average_pooling_2d_layer : public pooling_2d_layer
7070
{
7171
public:
7272
explicit average_pooling_2d_layer(const std::string& name,
73-
const shape2_concrete& pool_size, const shape2_concrete& strides, padding p,
73+
const shape2& pool_size, const shape2& strides, padding p,
7474
bool padding_valid_uses_offset, bool padding_same_uses_offset) :
7575
pooling_2d_layer(name, pool_size, strides, p,
7676
padding_valid_uses_offset, padding_same_uses_offset)
@@ -79,9 +79,9 @@ class average_pooling_2d_layer : public pooling_2d_layer
7979
protected:
8080
tensor3 pool(const tensor3& in) const override
8181
{
82-
if (pool_size_ == shape2_concrete(2, 2) && strides_ == shape2_concrete(2, 2))
82+
if (pool_size_ == shape2(2, 2) && strides_ == shape2(2, 2))
8383
return average_pool_2d(2, 2, 2, 2, padding_, use_offset(), in);
84-
else if (pool_size_ == shape2_concrete(4, 4) && strides_ == shape2_concrete(4, 4))
84+
else if (pool_size_ == shape2(4, 4) && strides_ == shape2(4, 4))
8585
return average_pool_2d(4, 4, 4, 4, padding_, use_offset(), in);
8686
else
8787
return average_pool_2d(

include/fdeep/layers/conv_2d_layer.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
#include "fdeep/convolution.hpp"
1010
#include "fdeep/filter.hpp"
11-
#include "fdeep/shape2_concrete.hpp"
12-
#include "fdeep/shape3_concrete.hpp"
11+
#include "fdeep/shape2.hpp"
12+
#include "fdeep/shape3.hpp"
1313
#include "fdeep/layers/layer.hpp"
1414

1515
#include <fplus/fplus.hpp>
@@ -25,13 +25,13 @@ class conv_2d_layer : public layer
2525
{
2626
public:
2727
explicit conv_2d_layer(
28-
const std::string& name, const shape3_concrete& filter_shape,
29-
std::size_t k, const shape2_concrete& strides, padding p,
28+
const std::string& name, const shape3& filter_shape,
29+
std::size_t k, const shape2& strides, padding p,
3030
bool padding_valid_offset_depth_1,
3131
bool padding_same_offset_depth_1,
3232
bool padding_valid_offset_depth_2,
3333
bool padding_same_offset_depth_2,
34-
const shape2_concrete& dilation_rate,
34+
const shape2& dilation_rate,
3535
const float_vec& weights, const float_vec& bias)
3636
: layer(name),
3737
filters_(generate_im2col_filter_matrix(
@@ -60,7 +60,7 @@ class conv_2d_layer : public layer
6060
filters_, inputs.front())};
6161
}
6262
im2col_filter_matrix filters_;
63-
shape2_concrete strides_;
63+
shape2 strides_;
6464
padding padding_;
6565
bool padding_valid_offset_depth_1_;
6666
bool padding_same_offset_depth_1_;

0 commit comments

Comments
 (0)