Creating empty templated VNTs

Aperta
#1,283 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
julia
Ambito
backend

Direzione di ricerca

Inizia individuando templated_setindex!!, DynamicPPL.settemplate!! e BangBang.setindex!!, quindi traccia il modo in cui vengono rappresentati i template di VarNamedTuple e i tipi degli elementi. Definisci separatamente il comportamento dei template vuoti e quello dell’impostazione dei valori, mantieni templated_setindex!! come loro composizione e verifica il comportamento documentato di stabilità dei tipi per valori non corrispondenti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

data-structures enhancement

Transferring this from a discussion on the weekly meeting Google Docs: we should split up templated_setindex!! to do two different actions, one to create an empty template in a VNT, and one to set the value of one or more elements. That is, we could have something like this:

vnt = VarNamedTuple()
vnt = DynamicPPL.settemplate!!(vnt, zeros(3, 3), @varname(x))
vnt = BangBang.setindex!!(vnt, 10.0, @varname(x[1,1]))

templated_setindex!! I think would still exist, but it would be a composition of the last two lines. The main benefit of doing so is so that we would be able to create preallocated, empty, VNTs prior to the model evaluation, instead of the current workflow where templates are detected at model runtime.

I think this should not be very difficult to do; the main concerns would be type stability, for example in

vnt = DynamicPPL.settemplate!!(vnt, zeros(3, 3), @varname(x))
# string instead of float
vnt = BangBang.setindex!!(vnt, "a", @varname(x[1,1]))

the latter call would be type unstable since it would need to broaden the eltype of the array. This is in fact the user's fault for supplying the wrong template, but I guess we would need to make it clear. The reason why templated_setindex!! avoids this type stability issue is because when calling

templated_setindex!!(vnt, "a", @varname(x[1, 1]), zeros(3, 3))

it in fact infers the eltype of the array from the value "a" rather than the eltype of the template Float64.

Lingua principale
Julia
Stelle
291
Fork
43
Merge medio
1g 23h
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TuringLang/DynamicPPL.jl

Tutte le issue di TuringLang/DynamicPPL.jl

Issue simili

Altre issue su Julia

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.