Skip to content

Commit 349729a

Browse files
committed
tests
1 parent c06e0cd commit 349729a

3 files changed

Lines changed: 42 additions & 5 deletions

File tree

include/layers/FCLayer.hpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ FCLayerImpl<ValueType>::FCLayerImpl(const std::vector<ValueType>& input_weights,
113113
this->inputShape_[0] = input_weights_shape[0];
114114
this->outputShape_[0] = input_weights_shape[1];
115115

116-
if (this->inputShape_[0] == 0 || this->outputShape_[0] == 0) {
117-
throw std::invalid_argument("Invalid weights/bias size for FCLayer");
118-
}
119-
120116
if (input_bias.size() != this->outputShape_[0]) {
121117
throw std::invalid_argument("Bias size doesn't match output size");
122118
}

test/single_layer/test_concatlayer.cpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,44 @@ TEST(ConcatLayerTests, ConcatResNetStyle) {
230230
EXPECT_FLOAT_EQ(output[0].get<float>({0, 3, 0, 1}), 14.0f);
231231
EXPECT_FLOAT_EQ(output[0].get<float>({0, 3, 1, 0}), 15.0f);
232232
EXPECT_FLOAT_EQ(output[0].get<float>({0, 3, 1, 1}), 16.0f);
233-
}
233+
}
234+
235+
TEST(ConcatLayerTests, ConcatSetOrderMultipleCalls) {
236+
ConcatLayer layer(1);
237+
std::vector<int> order1 = {0, 1, 2};
238+
std::vector<int> order2 = {2, 1, 0};
239+
std::vector<int> order3;
240+
241+
EXPECT_NO_THROW(layer.setInputOrder(order1));
242+
EXPECT_NO_THROW(layer.setInputOrder(order2));
243+
EXPECT_NO_THROW(layer.setInputOrder(order3));
244+
}
245+
246+
TEST(ConcatLayerTests, ConcatSetOrderAfterRun) {
247+
ConcatLayer layer(0);
248+
Tensor input1 = make_tensor<int>({1, 2, 3, 4}, {2, 2});
249+
Tensor input2 = make_tensor<int>({5, 6, 7, 8}, {2, 2});
250+
Tensor output;
251+
std::vector<Tensor> inputs{input1, input2};
252+
std::vector<Tensor> outputs{output};
253+
EXPECT_NO_THROW(layer.run(inputs, outputs));
254+
std::vector<int> order = {1, 0};
255+
EXPECT_NO_THROW(layer.setInputOrder(order));
256+
EXPECT_NO_THROW(layer.run(inputs, outputs));
257+
}
258+
259+
TEST(ConcatLayerTests, ReorderInputsWithInvalidOrderSize) {
260+
ConcatLayer layer(0);
261+
Tensor input1 = make_tensor<int>({1, 2}, {2});
262+
Tensor input2 = make_tensor<int>({3, 4}, {2});
263+
std::vector<int> order = {0};
264+
EXPECT_NO_THROW(layer.setInputOrder(order));
265+
}
266+
267+
TEST(ConcatLayerTests, ReorderInputsWithInvalidIndex) {
268+
ConcatLayer layer(0);
269+
Tensor input1 = make_tensor<int>({1, 2}, {2});
270+
Tensor input2 = make_tensor<int>({3, 4}, {2});
271+
std::vector<int> order = {0, 5};
272+
EXPECT_NO_THROW(layer.setInputOrder(order););
273+
}

test/single_layer/test_fclayer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ TEST(fclayer, new_fc_bias_and_weights_not_same) {
249249
std::vector<Tensor> out{output};
250250
EXPECT_THROW(layer.run(in, out), std::invalid_argument);
251251
}
252+
252253
TEST(fclayer, VectorSizeNotDivisibleByMatrixRows) {
253254
std::vector<float> weightsvec = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f};
254255
Shape weights_shape({3, 2});

0 commit comments

Comments
 (0)