Skip to content

Commit

Permalink
fix for normalized distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
scarlehoff committed Nov 22, 2024
1 parent 1d19da3 commit 97f2515
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
8 changes: 5 additions & 3 deletions n3fit/src/n3fit/layers/DY.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def compute_dy_observable_many_replica(pdf, padded_fk):
"""
pdfa = pdf[1]
pdfb = pdf[0]

temp = op.einsum('nxfyg, bryg -> brnxf', padded_fk, pdfa)
return op.einsum('brnxf, brxf -> brn', temp, pdfb)

Expand All @@ -96,11 +96,13 @@ def compute_dy_observable_one_replica(pdf, mask_and_fk):
Same operations as above but a specialized implementation that is more efficient for 1 replica,
masking the PDF rather than the fk table.
"""
# mask: (channels, flavs_b, flavs_a) Ffg
# fk: (npoints, channels, x_a, x_b) nFyx
mask, fk = mask_and_fk
# Retrieve the two PDFs (which may potentially be coming from different initial states)
# Since this is the one-replica function, remove the batch and replica dimension
pdfb = pdf[0][0][0] # xf
pdfa = pdf[1][0][0] # yg
pdfb = pdf[0][0][0] # (x_b, flavs_b) xf
pdfa = pdf[1][0][0] # (x_a, flavs_a) yg

# TODO: check which PDF must go first in case of different initial states!!!
mask_x_pdf = op.tensor_product(mask, pdfa, axes=[(2,), (1,)]) # Ffg, yg -> Ffy
Expand Down
7 changes: 5 additions & 2 deletions n3fit/src/n3fit/layers/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(
operation_name="NULL",
nfl=14,
n_replicas=1,
**kwargs
**kwargs,
):
super(MetaLayer, self).__init__(**kwargs)

Expand Down Expand Up @@ -178,7 +178,10 @@ def call(self, pdf):
rank 3 tensor (batchsize, replicas, ndata)
"""
if self.splitting:
pdfs = op.split(pdf, self.splitting, axis=2)
splitter = op.tensor_splitter(
pdf.shape, self.splitting, axis=2, name=f"pdf_splitter_{self.name}"
)
pdfs = splitter(pdf)
else:
pdfs = [pdf] * len(self.padded_fk_tables)

Expand Down
1 change: 0 additions & 1 deletion n3fit/src/n3fit/model_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def _generate_experimental_layer(self, pdf):
the input PDF is evaluated in all points that the experiment needs and needs to be split
"""
if len(self.dataset_xsizes) > 1:

sp_layer = op.tensor_splitter(
pdf.shape, self.dataset_xsizes, axis=2, name=f"{self.name}_split"
)
Expand Down

0 comments on commit 97f2515

Please sign in to comment.