Ok, I know that global constants defined in the base of a python file don’t work with torch.jit.script()
, but I’ve tried 4 or 5 seemingly reasonable ways to define a collection of constants for torchscript consumption and none of them work.
Does anyone have a good solution for project-wide constants used in a range of functions/modules across different files short of passing around and indexing a dict? That seems 1) inefficient as the constants can’t be compiled down as constants, 2) like bad code since it’s not obvious the dict shouldn’t be mutated. I’ve considered just hard coding constants across the codebase, but some are used in 20+ places and could actually change in the future despite not being a parameter, creating a real maintenance headache (think physical device measurements).
Surely there’s a best practice way to have constants available without a lot of object passing?? Any advice would be very much appreciated.