SMIS | Semantically Multi-modal Image Synthesis | Computer Vision library
kandi X-RAY | SMIS Summary
kandi X-RAY | SMIS Summary
Semantically Multi-modal Image Synthesis(CVPR 2020)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Display the current visual results
- Add images
- Save numpy array to png
- Convert visuals to numpy tensors
- Creates the path of the dataset
- Make a dataset from a directory
- Recursively iterate over all images in a directory
- Generate a colormap
- Convert ID to a label
- Creates the paths to the images
- Save visuals to images
- Perform the data parallelization
- Update learning rate
- Get paths to images
- Create dataset paths
- Run the forward computation
- Create a data loader
- Generate paths for training images
- Modify commandline options
- Print current errors
- Record end of epoch
- Forward transformation
- Parse options
- Forward computation
- Compute the loss function
- Monkey - patch the replication callback
SMIS Key Features
SMIS Examples and Code Snippets
Community Discussions
Trending Discussions on SMIS
QUESTION
Long story short, I've made an app for web scraping and in order for it to be able to simultaneously run more then 1 process at a time (more than 1 Chromium opened), i used puppeteer-cluster. I've got it to run several processes at once, but the cluster won't stop afterwards, it permanently runs. Along the way, I've encountered the following error (1)
...ANSWER
Answered 2021-Mar-02 at 01:27Cluster.launch
return a Promise. If you just call const cluster = Cluster.launch
, now cluster
is Promise, when you call (await cluster).close();
, (await cluster)
will return a Cluster
instance -> It work!
Let’s use cluster
as a Cluster
instance instead of a Promise object:
QUESTION
I'm learning V8 internals now. I learned that V8 uses pointer tagging for value storing, but wondered why it is not use NaN boxing.
AFAIK, NaN boxing is better because it can also store doubles and not just SMIs. I've read this, and understand (if that true) why not use NaN boxing on 32-bit platforms. But on 64-bit platforms I don't see why.
I suspect the reason has something to do with SMIs. Maybe they can't be stored using NaN boxing? I think they can. We have 52 superfluous bits for them (we can even use more than 32 bits). Maybe this will require additional masking operations that will render integer math slower? But we already need to do bitwise shift!
I don't know why. Thanks for anyone willing to answer.
...ANSWER
Answered 2020-Aug-23 at 21:11(V8 developer here.) NaN boxing and pointer tagging are design choices with different tradeoffs, neither is strictly better than the other. V8's decision to use pointer tagging has been made long before I joined the project, so I can only speculate what the specific reason(s) might have been at the time.
Advantages of pointer tagging are:
- significantly less memory consumption (certainly on 32-bit platforms; with "pointer compression" on 64-bit platforms too)
- slightly more efficient (small) integer operations, because most CPUs' integer operations are faster than their double operations. This may not matter at all once an optimizing compiler enters the picture.
- slightly more efficient pointer operations, because you can simply add an adjusted offset when accessing object fields (which has the same performance as not playing any pointer tricks at all), as opposed to having to mask off irrelevant parts of a NaN. This may not matter at all once an optimizing compiler enters the picture.
As you point out, the main benefit of NaN tagging is that it supports the full double range, which is very nice in some situations. You can build a well-performing engine based on either technique.
QUESTION
When writing performance-sensitive code in Javascript which operates on large numeric arrays (think a linear algebra package, operating on integers or floating-point numbers), one always wants the the JIT to help out as much as possible. Roughly this means:
- We always want our arrays to be packed SMIs (small integers) or packed Doubles, depending on whether we're doing integer or floating-point calculations.
- We always want to be passing the same type of thing to functions, so that they don't get labelled "megamorphic" and deoptimised. For instance, we always want to be calling
vec.add(x, y)
with bothx
andy
being packed SMI arrays, or both packed Double arrays. - We want functions to be inlined as much as possible.
When one strays outside of these cases, a sudden and drastic performance dropoff occurs. This can happen for various innocuous reasons:
- You might turn a packed SMI array into a packed Double array via a seemingly innocuous operation, like the equivalent of
myArray.map(x => -x)
. This is actually the "best" bad case, since packed Double arrays are still very fast. - You might turn a packed array into a generic boxed array, for example by mapping the array over a function which (unexpectedly) returned
null
orundefined
. This bad case is fairly easy to avoid. - You might deoptimise a whole function such as
vec.add()
by passing in too many types of things and turning it megamorphic. This could happen if you want to do "generic programming", wherevec.add()
is used both in cases where you're not being careful about types (so it sees a lot of types come in) and in cases where you want to eke out maximum performance (it should only ever receive boxed doubles, for instance).
My question is more of a soft question, about how one writes high-performance Javascript code in light of the considerations above, while still keeping the code nice and readable. Some specific sub-questions so that you know what kind of answer I'm aiming for:
- Is there a set of guidelines somewhere on how to program while staying in the world of packed SMI arrays (for instance)?
- Is possible to do generic high-performance programming in Javascript without using something like a macro system to inline things like
vec.add()
into callsites? - How does one modularise high-performance code into libaries in light of things like megamorphic call sites and deoptimisations? For instance, if I am happily using Linear Algebra package
A
at high speed, and then I import a packageB
that depends onA
, butB
calls it with other types and deoptimises it, suddenly (without my code changing) my code runs slower. - Are there any good easy to use measurement tools for checking what the Javascript engine is doing internally with types?
ANSWER
Answered 2020-Mar-11 at 12:19V8 developer here. Given the amount of interest in this question, and the lack of other answers, I can give this a shot; I'm afraid it won't be the answer you were hoping for though.
Is there a set of guidelines somewhere on how to program while staying in the world of packed SMI arrays (for instance)?
Short answer: it's right here: const guidelines = ["keep your integers small enough"]
.
Longer answer: giving a comprehensive set of guidelines is difficult for various reasons. In general, our opinion is that JavaScript developers should write code that makes sense to them and their use case, and JavaScript engine developers should figure out how to run that code fast on their engines. On the flip side, there are obviously some limitations to that ideal, in the sense that some coding patterns will always have higher performance costs than others, regardless of engine implementation choices and optimization efforts.
When we talk about performance advice, we try to keep that in mind, and carefully estimate what recommendations have a high likelihood of remaining valid across many engines and many years, and also are reasonably idiomatic/non-intrusive.
Getting back to the example at hand: using Smis internally is supposed to be an implementation detail that user code doesn't need to know about. It'll make some cases more efficient, and shouldn't hurt in other cases. Not all engines use Smis (for example, AFAIK Firefox/Spidermonkey historically hasn't; I've heard that for some cases they do use Smis these days; but I don't know any details and can't speak with any authority on the matter). In V8, the size of Smis is an internal detail, and has actually been changing over time and over versions. On 32-bit platforms, which used to be the majority use case, Smis have always been 31-bit signed integers; on 64-bit platforms they used to be 32-bit signed integers, which recently seemed like the most common case, until in Chrome 80 we shipped "pointer compression" for 64-bit architectures, which required lowering Smi size to the 31 bits known from 32-bit platforms. If you happened to have based an implementation on the assumption that Smis are typically 32 bits, you'd get unfortunate situations like this.
Thankfully, as you noted, double arrays are still very fast. For numerics-heavy code, it probably makes sense to assume/target double arrays. Given the prevalence of doubles in JavaScript, it is reasonable to assume that all engines have good support for doubles and double arrays.
Is possible to do generic high-performance programming in Javascript without using something like a macro system to inline things like vec.add() into callsites?
"generic" is generally at odds with "high-performance". This is unrelated to JavaScript, or to specific engine implementations.
"Generic" code means that decisions have to be made at runtime. Every time you execute a function, code has to run to determine, say, "is x
an integer? If so, take that code path. Is x
a string? Then jump over here. Is it an object? Does it have .valueOf
? No? Then maybe .toString()
? Maybe on its prototype chain? Call that, and restart from the beginning with its result". "High-performance" optimized code is essentially built on the idea to drop all these dynamic checks; that's only possible when the engine/compiler has some way to infer types ahead of time: if it can prove (or assume with high enough probability) that x
is always going to be an integer, then it only needs to generate code for that case (guarded by a type check if unproven assumptions were involved).
Inlining is orthogonal to all this. A "generic" function can still get inlined. In some cases, the compiler might be able to propagate type information into the inlined function to reduce polymorphism there.
(For comparison: C++, being a statically compiled language, has templates to solve a related problem. In short, they let the programmer explicitly instruct the compiler to create specialized copies of functions (or entire classes), parameterized on given types. That's a nice solution for some cases, but not without its own set of drawbacks, for example long compile times and large binaries. JavaScript, of course, has no such thing as templates. You could use eval
to build a system that's somewhat similar, but then you'd run into similar drawbacks: you'd have to do the equivalent of the C++ compiler's work at runtime, and you'd have to worry about the sheer amount of code you're generating.)
How does one modularise high-performance code into libaries in light of things like megamorphic call sites and deoptimisations? For instance, if I am happily using Linear Algebra package A at high speed, and then I import a package B that depends on A, but B calls it with other types and deoptimises it, suddenly (without my code changing) my code runs slower.
Yes, that's a general problem with JavaScript. V8 used to implement certain builtins (things like Array.sort
) in JavaScript internally, and this problem (which we call "type feedback pollution") was one of the primary reasons why we have entirely moved away from that technique.
That said, for numerical code, there aren't all that many types (only Smis and doubles), and as you noted they should have similar performance in practice, so while type feedback pollution is indeed a theoretical concern, and in some cases can have significant impact, it's also fairly likely that in linear algebra scenarios you won't see a measurable difference.
Also, inside the engine there are many more situations than "one type == fast" and "more than one type == slow". If a given operation has seen both Smis and doubles, that's totally fine. Loading elements from two kinds of arrays is fine too. We use the term "megamorphic" for the situation when a load has seen so many different types that it's given up on tracking them individually and instead uses a more generic mechanism that scales better to large numbers of types -- a function containing such loads can still get optimized. A "deoptimization" is the very specific act of having to throw away optimized code for a function because a new type is seen that hasn't been seen previously, and that the optimized code therefore isn't equipped to handle. But even that is fine: just go back to unoptimized code to collect more type feedback, and optimize again later. If this happens a couple of times, then it's nothing to worry about; it only becomes a problem in pathologically bad cases.
So the summary of all that is: don't worry about it. Just write reasonable code, let the engine deal with it. And by "reasonable", I mean: what makes sense for your use case, is readable, maintainable, uses efficient algorithms, doesn't contain bugs like reading beyond the length of arrays. Ideally, that's all there is to it, and you don't need to do anything else. If it makes you feel better to do something, and/or if you're actually observing performance issues, I can offer two ideas:
Using TypeScript can help. Big fat warning: TypeScript's types are aimed at developer productivity, not execution performance (and as it turns out, those two perspectives have very different requirements from a type system). That said, there is some overlap: e.g. if you consistently annotate things as number
, then the TS compiler will warn you if you accidentally put null
into an array or function that's supposed to only contain/operate on numbers. Of course, discipline is still required: a single number_func(random_object as number)
escape hatch can silently undermine everything, because the correctness of the type annotations is not enforced anywhere.
Using TypedArrays can also help. They have a little more overhead (memory consumption and allocation speed) per array compared to regular JavaScript arrays (so if you need many small arrays, then regular arrays are probably more efficient), and they're less flexible because they can't grow or shrink after allocation, but they do provide the guarantee that all elements have exactly one type.
Are there any good easy to use measurement tools for checking what the Javascript engine is doing internally with types?
No, and that's intentional. As explained above, we don't want you to specifically tailor your code to whatever patterns V8 can optimize particularly well today, and we don't believe that you really want to do that either. That set of things can change in either direction: if there's a pattern you'd love to use, we might optimize for that in a future version (we have previously toyed with the idea of storing unboxed 32-bit integers as array elements... but work on that hasn't started yet, so no promises); and sometimes if there's a pattern we used to optimize for in the past, we might decide to drop that if it gets in the way of other, more important/impactful optimizations. Also, things like inlining heuristics are notoriously difficult to get right, so making the right inlining decision at the right time is an area of ongoing research and corresponding changes to engine/compiler behavior; which makes this another case where it would be unfortunate for everyone (you and us) if you spent a lot of time tweaking your code until some set of current browser versions does approximately the inlining decisions you think (or know?) are best, only to come back half a year later to realize that then-current browsers have changed their heuristics.
You can, of course, always measure performance of your application as a whole -- that's what ultimately matters, not what choices specifically the engine made internally. Beware of microbenchmarks, for they are misleading: if you only extract two lines of code and benchmark those, then chances are that the scenario will be sufficiently different (e.g., different type feedback) that the engine will make very different decisions.
QUESTION
Starting from Windows 10 1809, OS generates lots of software SMIs.
We are running our real time application on separate processor core and each SMI generates unpredictable delay. Before 1809 it was always possible to disable SMIs in BIOS.
Call stack in Windows looks like:
ANSWER
Answered 2020-Jan-03 at 07:24The short answer is NO, it is not possible to configure Windows to not generate SW SMIs on UEFI Variable accesses, because those SMIs are not generated by Windows. The SMIs are generated inside the firmware.
All UEFI-aware OSes read/write UEFI variables via GetVariable() and SetVariable() services, which are part of Runtime Services exposed by a UEFI firmware to the OS via System Table - see UEFI Spec, section 8. The current implementation of Variable Services in most firmware is to process the actual Get/Set variable requests inside SMM, for security reasons.
So it is the device's firmware that's responsible for generating SW SMIs, not the OS. However, the OS and some system services/applications absolutely need to work with UEFI variables as it is how a UEFI-aware OS is supposed to run on a UEFI firmware.
QUESTION
I'm trying to add subject to a teacher's workload. I have a validation before inserting the user input to my workload table, mostly for detecting schedule conflict.
Now, what I want is to retain the selected value of the user and display it again after the validation fails. So that the user doesn't have to select the subject name, class name, and class adviser again.
I've attached my code for the class adviser selection.
...ANSWER
Answered 2018-Mar-14 at 20:45You could compare the posted value against the id of the current row. And add selected
attribute if the values are the same.
QUESTION
I'm trying to record the attendance of each student, I was able to retrieve the value of the checkbox (Late, Excuse, Absent). Is there a way that I can get both the student ID and the attendance mark from the checkbox? I need to pair the student ID with his/her attendance mark.
...ANSWER
Answered 2018-Mar-06 at 15:49sure. Use a hidden field.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SMIS
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page