Skip to content

Commit 9c86229

Browse files
committed
Update
1 parent 7b2c4ef commit 9c86229

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

dlib/dnn/layers.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5614,7 +5614,7 @@ namespace dlib
56145614
class tril_
56155615
{
56165616
public:
5617-
tril_(): diag(diag_), diag_value(compute_diag_value()) {}
5617+
tril_(): diag(diag_), prefix_size(0), diag_value(compute_diag_value()) {}
56185618

56195619
template <typename SUBNET>
56205620
void setup(const SUBNET& /*sub*/)
@@ -5643,6 +5643,17 @@ namespace dlib
56435643

56445644
const tensor& get_layer_params() const { return params; }
56455645
tensor& get_layer_params() { return params; }
5646+
5647+
void set_prefix_size(long n_prefix_size)
5648+
{
5649+
if (prefix_size != n_prefix_size) {
5650+
prefix_size = n_prefix_size;
5651+
binary_mask.set_size(0, 0, 0, 0);
5652+
output_mask.set_size(0, 0, 0, 0);
5653+
}
5654+
5655+
}
5656+
long get_prefix_size() const { return prefix_size; }
56465657

56475658
friend void serialize(const tril_& item, std::ostream& out)
56485659
{
@@ -5695,7 +5706,7 @@ namespace dlib
56955706
{
56965707
for (long r = 0; r < output_mask.nr(); ++r)
56975708
{
5698-
for (long c = std::max(r + diag + 1, 0L); c < output_mask.nc(); ++c)
5709+
for (long c = std::max(r + diag + 1, prefix_size); c < output_mask.nc(); ++c)
56995710
{
57005711
if (diag_value != 0.0f) output_mask.host()[tensor_index(output_mask, s, k, r, c)] = diag_value;
57015712
binary_mask.host()[tensor_index(binary_mask, s, k, r, c)] = 0;
@@ -5712,6 +5723,7 @@ namespace dlib
57125723
resizable_tensor params; // unused
57135724
resizable_tensor binary_mask, output_mask;
57145725
long diag;
5726+
long prefix_size;
57155727
float diag_value;
57165728
};
57175729

0 commit comments

Comments
 (0)