@@ -68,37 +68,37 @@ inline shape3_variable create_shape3_variable(const nlohmann::json& data)
68
68
fplus::nothing<std::size_t >()); // Should never be called
69
69
}
70
70
71
- inline shape3_concrete create_shape3_concrete (const nlohmann::json& data)
71
+ inline shape3 create_shape3 (const nlohmann::json& data)
72
72
{
73
- assertion (data.is_array (), " shape3_concrete needs to be an array" );
73
+ assertion (data.is_array (), " shape3 needs to be an array" );
74
74
assertion (data.size () > 0 , " need at least one dimension" );
75
75
// TODO: offset still needed?
76
76
const std::size_t offset = data.front ().is_null () ? 1 : 0 ;
77
77
if (data.size () == 1 + offset)
78
- return shape3_concrete (0 , 0 , data[0 + offset]);
78
+ return shape3 (0 , 0 , data[0 + offset]);
79
79
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]);
81
81
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
85
85
}
86
86
87
- inline shape2_concrete create_shape2_concrete (const nlohmann::json& data)
87
+ inline shape2 create_shape2 (const nlohmann::json& data)
88
88
{
89
89
if (data.is_array ())
90
90
{
91
91
assertion (data.size () == 1 || data.size () == 2 ,
92
- " invalid number of dimensions in shape2_concrete " );
92
+ " invalid number of dimensions in shape2 " );
93
93
if (data.size () == 1 )
94
- return shape2_concrete (1 , data[0 ]);
94
+ return shape2 (1 , data[0 ]);
95
95
else
96
- return shape2_concrete (data[0 ], data[1 ]);
96
+ return shape2 (data[0 ], data[1 ]);
97
97
}
98
98
else
99
99
{
100
100
const std::size_t width = data;
101
- return shape2_concrete (1 , width);
101
+ return shape2 (1 , width);
102
102
}
103
103
}
104
104
@@ -146,7 +146,7 @@ inline float_vec decode_floats(const nlohmann::json& data)
146
146
147
147
inline tensor3 create_tensor3 (const nlohmann::json& data)
148
148
{
149
- const shape3_concrete shape = create_shape3_concrete (data[" shape" ]);
149
+ const shape3 shape = create_shape3 (data[" shape" ]);
150
150
return tensor3 (shape, decode_floats (data[" values" ]));
151
151
}
152
152
@@ -222,8 +222,8 @@ inline layer_ptr create_conv_2d_layer(const get_param_f& get_param,
222
222
const std::string padding_str = data[" config" ][" padding" ];
223
223
const auto pad_type = create_padding (padding_str);
224
224
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" ]);
227
227
228
228
const auto filter_count = create_size_t (data[" config" ][" filters" ]);
229
229
float_vec bias (filter_count, 0 );
@@ -233,12 +233,12 @@ inline layer_ptr create_conv_2d_layer(const get_param_f& get_param,
233
233
assertion (bias.size () == filter_count, " size of bias does not match" );
234
234
235
235
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" ]);
237
237
assertion (weights.size () % kernel_size.area () == 0 ,
238
238
" invalid number of weights" );
239
239
const std::size_t filter_depths =
240
240
weights.size () / (kernel_size.area () * filter_count);
241
- const shape3_concrete filter_shape (
241
+ const shape3 filter_shape (
242
242
filter_depths, kernel_size.height_ , kernel_size.width_ );
243
243
244
244
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,
263
263
const std::string padding_str = data[" config" ][" padding" ];
264
264
const auto pad_type = create_padding (padding_str);
265
265
266
- const shape2_concrete strides = create_shape2_concrete (data[" config" ][" strides" ]);
266
+ const shape2 strides = create_shape2 (data[" config" ][" strides" ]);
267
267
268
268
const auto filter_count = create_size_t (data[" config" ][" filters" ]);
269
269
float_vec bias (filter_count, 0 );
@@ -273,12 +273,12 @@ inline layer_ptr create_conv_2d_transpose_layer(const get_param_f& get_param,
273
273
assertion (bias.size () == filter_count, " size of bias does not match" );
274
274
275
275
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" ]);
277
277
assertion (weights.size () % kernel_size.area () == 0 ,
278
278
" invalid number of weights" );
279
279
const std::size_t filter_depths =
280
280
weights.size () / (kernel_size.area () * filter_count);
281
- const shape3_concrete filter_shape (
281
+ const shape3 filter_shape (
282
282
filter_depths, kernel_size.height_ , kernel_size.width_ );
283
283
284
284
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,
303
303
const std::string padding_str = data[" config" ][" padding" ];
304
304
const auto pad_type = create_padding (padding_str);
305
305
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" ]);
308
308
309
309
const auto filter_count = create_size_t (data[" config" ][" filters" ]);
310
310
float_vec bias (filter_count, 0 );
@@ -317,7 +317,7 @@ inline layer_ptr create_separable_conv_2D_layer(const get_param_f& get_param,
317
317
get_param (name, " slice_weights" ));
318
318
const float_vec stack_weights = decode_floats (
319
319
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" ]);
321
321
assertion (slice_weights.size () % kernel_size.area () == 0 ,
322
322
" invalid number of weights" );
323
323
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,
326
326
const std::size_t stack_output_depths_1 =
327
327
stack_weights.size () / input_depth;
328
328
assertion (stack_output_depths_1 == filter_count, " invalid weights sizes" );
329
- const shape3_concrete filter_shape (1 ,
329
+ const shape3 filter_shape (1 ,
330
330
kernel_size.height_ , kernel_size.width_ );
331
331
float_vec bias_0 (input_depth, 0 );
332
332
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,
351
351
const std::string padding_str = data[" config" ][" padding" ];
352
352
const auto pad_type = create_padding (padding_str);
353
353
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" ]);
356
356
357
357
const float_vec slice_weights = decode_floats (
358
358
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" ]);
360
360
assertion (slice_weights.size () % kernel_size.area () == 0 ,
361
361
" invalid number of weights" );
362
362
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 ,
364
364
kernel_size.height_ , kernel_size.width_ );
365
365
const std::size_t filter_count = input_depth;
366
366
float_vec bias (filter_count, 0 );
@@ -423,8 +423,8 @@ inline layer_ptr create_max_pooling_2d_layer(
423
423
const get_param_f&, const get_global_param_f& get_global_param,
424
424
const nlohmann::json& data, const std::string& name)
425
425
{
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" ]);
428
428
const std::string padding_str = data[" config" ][" padding" ];
429
429
const auto pad_type = create_padding (padding_str);
430
430
const bool padding_valid_uses_offset =
@@ -441,8 +441,8 @@ inline layer_ptr create_average_pooling_2d_layer(
441
441
const get_param_f&, const get_global_param_f& get_global_param,
442
442
const nlohmann::json& data, const std::string& name)
443
443
{
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" ]);
446
446
const std::string padding_str = data[" config" ][" padding" ];
447
447
const auto pad_type = create_padding (padding_str);
448
448
const bool padding_valid_uses_offset =
@@ -473,7 +473,7 @@ inline layer_ptr create_upsampling_2d_layer(
473
473
const get_param_f&, const get_global_param_f&, const nlohmann::json& data,
474
474
const std::string& name)
475
475
{
476
- const auto scale_factor = create_shape2_concrete (data[" config" ][" size" ]);
476
+ const auto scale_factor = create_shape2 (data[" config" ][" size" ]);
477
477
return std::make_shared<upsampling_2d_layer>(name, scale_factor);
478
478
}
479
479
0 commit comments