buf | A new way of working with Protocol Buffers | Serialization library
kandi X-RAY | buf Summary
kandi X-RAY | buf Summary
The buf CLI is a tool for working with Protocol Buffers APIs, offering a range of features not found in the standard protoc compiler, including these core features:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of buf
buf Key Features
buf Examples and Code Snippets
def tf_buffer(data=None):
"""Context manager that creates and deletes TF_Buffer.
Example usage:
with tf_buffer() as buf:
# get serialized graph def into buf
...
proto_data = c_api.TF_GetBuffer(buf)
graph_def.ParseFrom
Community Discussions
Trending Discussions on buf
QUESTION
This may be a silly question, but... I tried to implement printf
, but for some reason the output I get is not exactly what I expected. any idea what it could be? I would appreciate some help.
ANSWER
Answered 2022-Mar-23 at 23:19Seems that gcvt()
don't do exactly what printf()
do, at least with your compiler. Check it with a "real" printf
with the same value.
Since you didn't gave the numbers you used for the test (avoid getfloat()
and initialize directly i1
, i2
, noi1
and noi2
with required constants in your question), I can't run it and tell you why exactly - or if it even happens with my own compiler.
Usually, the source code for printf
is at least two times bigger than yours, so you may have missed some vicious subcases. If I remember well, printf
has code to decode an IEEE-754 directly and don't rely on gcvt
.
QUESTION
I am trying to capture video via Gallery or via Camera. I am able to successfully fetch the video from Gallery. However when I try to record the video from camera it loses the track and I am unable to fetch the path. It does save the video on path. The log give following error/warning. Why is is losing track of the video recorder? Where am I going wrong?
...ANSWER
Answered 2022-Mar-22 at 18:12I don't know if it will help but maybe you should do startActivityForResult or ActivtyResultLauncher. I would comment that if I had enough reputation.
QUESTION
In the following F# code, f1 takes a Span as input, and f2 calls f1. The compiler gives the indicated error when the argument is piped instead of passed.
...ANSWER
Answered 2022-Mar-07 at 18:17Just to add a little more color as to the why:
Byrefs and byref-like types fly in the face of functional-first programming.
These types are required to have their entire lifetime on the stack, and come with some compiler analysis that allow the runtime to elide some checks. That's great for performance.
When a function is made first-class, it involves a heap allocation. It's an object with an Invoke
method on it, basically. In the F# compiler there are several optimizations that attempt to convert an F# function into just a static method (and most F# function declarations are like this), but there are many circumstances where they're emitted as objects on the heap (some you can predict, some you can't). That means several things:
- You can't pass a function around that takes a byref or byref-like type as a parameter
- You can't use a byref or byref-like type in a lambda
- You can't use a byref or byref-like type in an inner function
There are some cases where this would technically be possible, but there's nothing in source code that would indicate why it's possible in some cases but not others. The reason would simply be "because the compiler needs to emit this function as an object" and that is entirely unpredictable and non-uniform. One proposed suggestion would help with this, but it's closed in favor of tweaks in the compiler and like this suggestion, which is estimated to probably not be too bad from a predictability standpoint.
Now the |>
case is more interesting, as are several other functions that are declared inline
. The |>
operator is quite literally defined to take in a higher-order function as a parameter, so naturally it shouldn't be supported. But because it's defined as inline
, it could actually work since it's just an optimization. However, this may also require that you can only use it in the context of other inline
functions. You may not be able to pipe into any arbitrary function.
That's why this is not a bug, but a by-design behavior that will take some serious consideration into enhancing, should it be implemented: https://github.com/fsharp/fslang-suggestions/issues/688
QUESTION
#include
using namespace std;
int main() {
int buf[2];
int *p=new (buf) int(2);
int *q=new (buf+1) int(6);
for(int i=0;i<2;i++)
cout<<<" ";
return 0;
}
...ANSWER
Answered 2022-Feb-13 at 14:24This is a GCC bug affecting versions 8 to 10 and fixed in 11, see bug report.
The code is fine, the warning a false-positive.
QUESTION
I'm trying to safely zero a std::array
in a class destructor. From safely, I mean I want to be sure that compiler never optimize this zeroing. Here is what I came with:
ANSWER
Answered 2022-Jan-30 at 23:06The C++ standard itself doesn't make explicit guarantees. It says:
[dcl.type.cv]
The semantics of an access through a volatile glvalue are implementation-defined. ...
[Note 5: volatile is a hint to the implementation to avoid aggressive optimization involving the object because the value of the object might be changed by means undetectable by an implementation. Furthermore, for some implementations, volatile might indicate that special hardware instructions are required to access the object. See [intro.execution] for detailed semantics. In general, the semantics of volatile are intended to be the same in C++ as they are in C. — end note]
Despite the lack of guarantees by the C++ standard, over-writing the memory through a pointer to volatile is one way that some crypto libraries clear memory - at least as a fallback when system specific function isn't available.
P.S. I recommend using const_cast
instead, in order to avoid accidentally casting to a different type rather than differently qualified same type:
QUESTION
I want to encrypt data in a web browser that is send to my C# backend and decrypted there.
That fails because I am unable to decrypt the data generated on the frontend in the backend.
Here's what I did so far.
First I created a private/public key pair (in XmlString Format). I took the ExportPublicKey
function to generate the public key file from here: https://stackoverflow.com/a/28407693/98491
ANSWER
Answered 2022-Jan-24 at 15:42You need to encrypt with the private key and then decrypt with the public key
QUESTION
Trying to install openssl on homebrew using:
...ANSWER
Answered 2021-Sep-03 at 15:29Seems a bug of openssl itself. https://github.com/openssl/openssl/issues/16487
~~What about export SDKROOT="/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk "
?~~
Homebrew pre-build packages for some versions of macOS. But it keep dropping this pre-building support for old macOS. On macOS 10.12, you're building openssl
from the source code and Xcode command line tool is needed.
QUESTION
I made a bubble sort implementation in C, and was testing its performance when I noticed that the -O3
flag made it run even slower than no flags at all! Meanwhile -O2
was making it run a lot faster as expected.
Without optimisations:
...ANSWER
Answered 2021-Oct-27 at 19:53It looks like GCC's naïveté about store-forwarding stalls is hurting its auto-vectorization strategy here. See also Store forwarding by example for some practical benchmarks on Intel with hardware performance counters, and What are the costs of failed store-to-load forwarding on x86? Also Agner Fog's x86 optimization guides.
(gcc -O3
enables -ftree-vectorize
and a few other options not included by -O2
, e.g. if
-conversion to branchless cmov
, which is another way -O3
can hurt with data patterns GCC didn't expect. By comparison, Clang enables auto-vectorization even at -O2
, although some of its optimizations are still only on at -O3
.)
It's doing 64-bit loads (and branching to store or not) on pairs of ints. This means, if we swapped the last iteration, this load comes half from that store, half from fresh memory, so we get a store-forwarding stall after every swap. But bubble sort often has long chains of swapping every iteration as an element bubbles far, so this is really bad.
(Bubble sort is bad in general, especially if implemented naively without keeping the previous iteration's second element around in a register. It can be interesting to analyze the asm details of exactly why it sucks, so it is fair enough for wanting to try.)
Anyway, this is pretty clearly an anti-optimization you should report on GCC Bugzilla with the "missed-optimization" keyword. Scalar loads are cheap, and store-forwarding stalls are costly. (Can modern x86 implementations store-forward from more than one prior store? no, nor can microarchitectures other than in-order Atom efficiently load when it partially overlaps with one previous store, and partially from data that has to come from the L1d cache.)
Even better would be to keep buf[x+1]
in a register and use it as buf[x]
in the next iteration, avoiding a store and load. (Like good hand-written asm bubble sort examples, a few of which exist on Stack Overflow.)
If it wasn't for the store-forwarding stalls (which AFAIK GCC doesn't know about in its cost model), this strategy might be about break-even. SSE 4.1 for a branchless pmind
/ pmaxd
comparator might be interesting, but that would mean always storing and the C source doesn't do that.
If this strategy of double-width load had any merit, it would be better implemented with pure integer on a 64-bit machine like x86-64, where you can operate on just the low 32 bits with garbage (or valuable data) in the upper half. E.g.,
QUESTION
I am getting the following error mentioned. The basic configs are as follow: I have uploaded the files on the server I want to download them but getting these errors I called a POST request to /api/files/delete/${fileId} Which should call the route and give back the file to the browser instead getting the error with the Grid related module.
...ANSWER
Answered 2021-Sep-07 at 04:57I also faced similar issues. The resolution for me was with mongoose version. The issue arises in the version 6.0.5 but is working in the version 5.13.7
QUESTION
In a piece of code I'm writing, I receive packets as uint8_t *
and std::size_t
combination. I can register functions to call with these two parameters, based on which file descriptor the packet was received from. I use an std::map > handlers
to keep track of which function to call.
I would like to be able to (indirectly) register functions with arbitrary arguments. I already have a function like this to transform from the uint8_t *
and std::size_t
to separate variables:
ANSWER
Answered 2022-Jan-08 at 17:53It's possible, just annoying to write.
First you need a trait to get parameters from a function type:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install buf
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