Implement GPT-3 style contamination study

In https://github.com/EleutherAI/lm-evaluation-harness/tree/master/scripts/clean_training_data, @researcher2 has implemented the 13-grams algorithm from the paper "Language Models are Few Shot Learners." However, the code doesn't perform the same analysis using that 13-gram algorithm as the paper. "Language Models are Few Shot Learners" subtracts the contamination from the test set, and then looks at the %-change in performance between the entire test set and the uncontaminated test set. This type of analysis is growing in popularity, as is evidenced by it being done in Finetuned Language Models are Few Shot Learners and asked for by reviewers of Multitask Prompted Training Enables Zero-Shot Task Generalization.

Do we just need to:

Generate 13-grams on the Pile (or retrieve them if others like @researcher2 have already done this)
For each task on the harness, measure performance of a model (which model?) before/after cleaning (1)'s 13-gram contaminants from the task.

Do we just need to:

Generate 13-grams on the Pile (or retrieve them if others like @researcher2 have already done this)
For each task on the harness, measure performance of a model (which model?) before/after cleaning (1)'s 13-gram contaminants from the task.

Yes, with the caveat that I would like to offer this as a function that anyone can use. I am interested in using this on some models I am currently training on the Pile, and NVIDIA has asked about our plans to implement this functionality as well. NVIDIA’s data is based on the Pile, but is modified and they cannot release the dataset.
I’m thinking that we would provide a function for computing n-grams (default to 13, but can be set by the user) and then adding an argument pointing to the n-grams to the main eval harness call. When called with the n-grams input, it does the eval harness as usual except it also computes the deduplicated metrics in addition to the metrics on the full dataset.
@leogao2 do you have any plans to implement metrics as a class? This is a good excuse to do so and I could see it being useful to someone with non-standard evaluation criteria.

Getting into this discussion.
How the 13-gram search is generated for a dataset? I believe pre-calculating n-gram search support for a dataset is a costly task (Both memory and CPU compute-wise).
Here's some of the stuff that I have already explored,

Initially, I thought this would be a straightforward implementation of trie-tree but later found that trie-tree is a token-based data structure. I believe trie tree can be used to do a token level analysis of the corpus. It could be also worth exploring too.
Actual fast pattern matching algorithm is "suffix array", Are you guys using any it?
Another way could be the "minhash" algorithm but I don't know about the details of this one. I would love to know about the details if you are using it.

Here are some of the content I have collected from Teven.

Suffix array implementation from google: https://github.com/google-research/deduplicate-text-datasets
Additional scripts for checking data contamination. https://github.com/TevenLeScao/library_of_babel/blob/main/prompt_deduplication/mass_count_occurences_per_word.py

I’m thinking that we would provide a function for computing n-grams (default to 13, but can be set by the user) and then adding an argument pointing to the n-grams to the main eval harness call. When called with the n-grams input, it does the eval harness as usual except it also computes the deduplicated metrics in addition to the metrics on the full dataset.

This is actually a great point. Basically, we want to mimic the functionality of GPT-3 Appendix Table C1 Page 45

I’m thinking that we would provide a function for computing n-grams (default to 13, but can be set by the user) and then adding an argument pointing to the n-grams to the main eval harness call. When called with the n-grams input, it does the eval harness as usual except it also computes the deduplicated metrics in addition to the metrics on the full dataset.

This is actually a great point. Basically, we want to mimic the functionality of GPT-3 Appendix Table C1 Page 45

Yup! I was looking at that table as I wrote that :)

Summary Of Current Work
We have a script for generating 13 grams.
This accepts a --working-directory argument, which yields documents from all files found at f"{working_directory}/*.jsonl.zst*". That extension is lm_dataformat. It also accepts --n_value (defaults to 13-grams), and --buckets which specifies how many output buckets the ngrams are broken into. They are bucketed simply by hashing the ngram modulo num_buckets.
After generating and bucketing, the ngrams in each bucket are sorted.
Once we have sorted buckets it's very quick to count up to exclude n-grams that occur more than 10 times - it appears I did the opposite previously only including with >10 - this needs fixing.
Based on my understanding of Initial training set filtering in "Language Models are Few Shot Learners.", the process would go:

Generate/sort/deduplicate/remove>10occurences for test sets.
Run Janitor, registering the test contaminates, than run the training set through using Janitor.clean to return filtered training data.

Discussion
With some minor changes the 13-gram script could be adapted to any required input file type, or just import it and override the get_pile function.
We have some artifacts of this whole process saved somewhere, @StellaAthena or @leogao2 might know? I remember copying stuff over to a hdd0 or something like that.
In terms of the paper, I don't believe we continued onto the following section Overlap methodology, @leogao2?

Sorry, I don't know where the 13-grams are saved. Also, we never implemented the overlap methodology, but it shouldn't be too hard to implement given the 13-gram stuff.

I'll take a crack at this over the coming week

I've implemented the suggested improvements above, waiting on server config to get access to the pile 13 grams for testing. At this stage we still need to do the overlap study from 6(C) of Language Models are Few-Shot Learners.


Image cropped to smaller size when saving PNGs on MDCS

Hello!
 However, after doing so, the images get cropped. I can run the same script on my local client and get the correct result.
My test code is as follows:
%%% This script is to help with debugging figure generation on MDCS.
savePath = '/Save/Path/';
name = fullfile(savePath, 'testPNGgen');
figPos=[66 1 1855 1001];

f = figure('Position', figPos);
set(f, 'PaperUnits', 'points');
set(f, 'PaperSize', [1790 1001]);
set(f, 'PaperPosition', [66 1 1855 1001]);
plot(randn(1,10), randn(1,10));
export_fig(name, '-png', '-painters', f)

I have tried the following debug steps, all without success:

Use '-m0.5' to try to shrink figure pixel dimensions. This just makes the cropped image smaller.
Include set(f, 'PaperPositionMode', 'manual'); before plotting the figure. No change to the cropped image.

I can size things appropriately using print:
print(f, name, '-dpng', '-painters', '-r300')

This results in the full image, but without all the improvements export_fig provides.
Any help on this matter would be greatly appreciated. I am happy to run tests on my cluster if more debug information is required or desired.

Try to run the following command and see what you get:
print(f, name, '-loose', '-painters', '-depsc2')

If you see that this also crops the images (as I suspect that it would), then this would indicate a bug in Matlab's implementation of its internal print function on MDCS workers, and in such a case you should open a support ticket with MathWorks. You might try using the -depsc option as an alternative (in both print and export_fig), maybe this might improve things.
If you do not see any cropping, then this would indicate that the cropping was introduced by export_fig, and in such a case I might be able to fix it.

Using the following code:
%%% This script is to help with debugging figure generation on MDCS.
savePath = '/Save/Path/';
name = fullfile(savePath, 'testPNGgenFig');
figPos=[66 1 1855 1001];

f = figure('Position', figPos);
set(f, 'PaperUnits', 'points');
set(f, 'PaperSize', [1790 1001]);
set(f, 'PaperPositionMode', 'manual');
set(f, 'PaperPosition', [66 1 1855 1001]);

plot(randn(1,10), randn(1,10));

print(f, name, '-loose', '-painters', '-depsc2')

I do not see cropping on the resulting EPS figure. Additionally, saving to EPS using :
export_fig(name, '-eps', '-painters', f)

crops the image as well.

Cropping is done by default in export_fig, and so cropping is the correct behavior, not a bug. The reason it does not do so on your local machine may be due to having an old export_fig version. If you install the latest version of export_fig locally I think that you'll see that it also crops on your local machine.
To avoid cropping, simply use the -nocrop input parameter:
export_fig(name, '-eps', '-painters', '-nocrop', f)

Hello!
Thank you for looking into this (kind of obscure) issue. I believe I may have caused confusion with my use of the word "crop". I have attached the PNG output of my test code using the '-nocrop' option below. I would attach the .fig file as well, but I can't see an option to do so. I can tell you that the .fig generated alongside the attached PNG behaves normally.

I want to thank you again for the time you've already spent looking into this. I appreciate your help and understand if you don't have the time to troubleshoot this any more. I have a workaround, which is to use print and get uglier figures, so I will use that until I feel clever and dig around in export_fig some more.

After the initial EPS file is generated by Matlab's print command in line #231 of print2eps.m, save the file (name) sideways, and send it to me by email (altmany at gmail). You will need to add a line such as the following in order to be able to save the file, since it is automatically deleted by export_fig at a later point:
...
    % Print to eps file
    print(fig, options{:}, name);

    % New line: save a copy of the EPS file for later analysis by Yair
    copyfile(name, 'C:\ForYair.eps', 'f');

... (the rest remains unchanged)

I suspect that Matlab's print has trouble rendering graphics beyond the monitor's boundaries in headless mode. So simply resize the figure using a command such as
set(f, 'Position',[0,0,800,600]);  % alternative #1
set(f, 'Units','norm', 'Position',[0,0,1,1])  % alternative #2

I have fairly busy figures and bad eyesight, so I'll stick with my current
workaround for the moment. I will raise this as an issue with the MathWorks.
Thank you for all your help on this! Glad to know I wasn't just messing up
my figure settings.
Best,
On Tue, Sep 15, 2015 at 11:28 PM, Yair Altman<EMAIL_ADDRESS>wrote:

I suspect that Matlab's print has trouble rendering graphics beyond the
monitor's boundaries in headless mode. So simply resize the figure using a
command such as
set(f, 'Position',[0,0,800,600]);  % alternative #1set(f, 'Units','norm', 'Position',[0,0,1,1])  % alternative #2
—
Reply to this email directly or view it on GitHub
https://github.com/altmany/export_fig/issues/98#issuecomment-140642902.


Add choices and documentcloud_pages to SpltCd.elec_code (in common.py)

Overview
Add choices and documentcloud_pages to the elec_code field on SpltCd the database model.
Basically, we think elec_code should be defined as a "choice field" (in Django parlance), which just means it's a field with a defined list of valid values and an intelligible definition for each value.
Our goal is for every potential choice field to include references to locations in the official documentation where the field's valid values and their meanings are described AND to have those choices included in the field's definition.
And we need your help!
What to do
Step 1: Claim this ticket by adding yourself as an Assignee (to the right)
Step 2: Find where in the official documentation elec_code's list of valid values is defined.
The best place to look first is in the .CAL layout documents: .CAL Format version 2.01 and .CAL Format version 1.05.02. These are documents that describe the layout of the .CAL file format, which is the required electronic format of any filings ingested by the CAL-ACCESS system (more on that here if you are interested).
You can start by opening the document and just searching for "elec_code". For example, if you were assigned to tackle the stmt_type field on the CvrCampaignDisclosureCd model, you would be looking for something like this::

But note that the same column might appear on multiple tables, and the list of valid values may vary depending on the table. We want to be sure to find the list of valid values for the elec_code on the SpltCd model.
Another good place to look is in the MapCalFormat2Fields document, which describes how .CAL format fields are mapped to CAL-ACCESS database table columns. Note the Valid_V column on the far right.
Step 3: Copy the DocumentCloud ID and the page number(s) where elec_code's list of valid values is defined.
The DocumentCloud ID can be found the in the URL that points to the document. For example, the url to the .CAL Format version 2.01 doc is http://www.documentcloud.org/documents/2712034-Cal-Format-201.html#document/p1, and the id is 2712034-Cal-Format-201.
And the start page we want to grab is the DocumentCloud page number, not the page number printed on the .PDF. If the list of valid values spans multiple pages, then grab the page where the list ends as well.
Step 4: Find where elec_code is defined in common.py in the /calaccess_raw/models/common.py file underneath the SpltCd class.
Since the model files are rather long, take care to be sure you find the where elec_code is defined for the SpltCd model. It should look something like this:
    class SpltCd(CalAccessBaseModel):
        # ...
        # several lines of code later...
        # ...
        elec_code = fields.CharField(
            max_length=2,
            db_column='ELEC_CODE',
            blank=True,
            verbose_name='elec code',
            help_text='This field is undocumented',
        )

Step 5: Add the document references
Say you found the list of valid values listed in three places. You would list them in the documentcloud_pages attribute like this:
    class SpltCd(CalAccessBaseModel):
        # ...
        # several lines of code later...
        # ...
        elec_code = fields.CharField(
            max_length=2,
            db_column='ELEC_CODE',
            blank=True,
            verbose_name='elec code',
            help_text='This field is undocumented',
            documentcloud_pages=[
                DocumentCloud(id='2711616-MapCalFormat2Fields', start_page=10),
                DocumentCloud(id='2712033-Cal-Format-1-05-02', start_page=19),
                DocumentCloud(id='2712034-Cal-Format-201', start_page=24, end_page=25),
            ]
        )

Note: You only need to specify the end_page if the list spans multiple pages.
Step 6: Update the elec_code's help_text (if necessary)
It might be missing or it might be an empty string or it might not be consistent with what you see in the documentation. Note: The entire help_text string needs to be enclosed in single- or double-quotes like this:
    help_text='This is the help text',

If the help text is really long (80+ characters), then it needs to span multiple lines like this:
    help_text='This is the help text...blah...blah...blah...blah...blah...blah...\
...blah...blah...blah',

Step 7: Define the choices
The normal Django pattern is to define choices within the model class as a tuple which contains a bunch of two item tuples. The first item of each inner tuple is the valid database column value, and the second item is the definition. It should look something like this:
    ELEC_CODE_CHOICES = (
        ('AAA', 'Some definition of AAA'),
        ('BBB', 'Some definition of BBB'),
        ('CCC', 'Some definition of CCC'),
        # ...and more..
    )

Then we assign this tuple of tuples to 's choice argument with a single line: choices=ELEC_CODE_CHOICES.
When finished, it should all look something like this:
    class SpltCd(CalAccessBaseModel):
        # ...
        # several lines of code later...
        # ...
        ELEC_CODE_CHOICES = (
            ('AAA', 'Some definition of AAA'),
            ('BBB', 'Some definition of BBB'),
            ('CCC', 'Some definition of CCC'),
            # ...and more..
        )
        elec_code = fields.CharField(
            choices=ELEC_CODE_CHOICES,
            max_length=2,
            db_column='ELEC_CODE',
            blank=True,
            verbose_name='elec code',
            help_text='This field is undocumented',
            documentcloud_pages=[
                DocumentCloud(id='2711616-MapCalFormat2Fields', start_page=10),
                DocumentCloud(id='2712033-Cal-Format-1-05-02', start_page=19),
                DocumentCloud(id='2712034-Cal-Format-201', start_page=24, end_page=25),
            ]
        )

So some of these choice fields show up on multiple tables (the various office_cd fields are a good example), and of course it's rather redundant to repeat these values and their definitions over and over. In some these cases, we've consolidated these valid values into one place: calaccess_raw/annotations/choices.py.
So then instead of listing out all the choices in the tuple of tuples, we can do this:
    OFFICE_CD_CHOICES = get_sorted_choices(choices.OFFICE_CODES)
    office_cd = fields.CharField(
        choices=OFFICE_CD_CHOICES,
        # ...other stuff...
    )

If you think the field your looking at is a candidate for this sort of consolidation, let's have a conversation about it. Just post a comment below.
If you can, check the elec_code's defined choices against the actual values in elec_code's database column.
This will require you to install the app and run the updatecalaccessrawdata command. Then you can get the distinct column values with a GROUP BY query like this:
    SELECT ELEC_CODE, COUNT(*)
    FROM SPLT_CD
    GROUP BY 1
    ORDER BY 1;

It's likely that you'll find undocumented values in database column, some of which are variants of the valid values. You can note these by repeating the same definition for each variant like this:
    OFFICE_CD_CHOICES = (
        ('GOV', 'Governor'),
        ('gov', 'Governor'),
        ('GUV', 'Governor'),
        # ...
    ),

If you're dealing with a set of choices that's been consolidated into calaccess_raw/annotations/choices.py, you can map the different variants to the same definition using the key of the choices dict like this:
    OFFICE_CD_CHOICES = (
        ('gov', look_ups.OFFICE_CODES['GOV']),
        ('GUV', look_ups.OFFICE_CODES['GOV']),
        # ...
    ),

If you're not able to check the database column values for whatever reason, don't sweat it. We'll deal with it in a later issue.
Wrap up: Review your changes and create a pull request

That's it!
PS: If any of this feels confusing, or if it doesn't seem to match up with what you are seeing, or if you have any suggestions about another approach, don't hesitate to speak up. You can post a comment below, or hit up the #california-civic-data channel on the News Nerdery Slack.

Done.


Suggestion

Can there be a method to get image from dms. As of right now message.attachment does give a URL https://ton.twitter.com/1.1/ton/data/dm/etc  but it cant be used as cdn so need to extract one with cdn URL and for that need some auth I think

Hello.
I found that I can get the image by setting the header and doing a get.
Please try it.
attachment_url = 'https://ton.twitter.com/1.1/ton/data/dm/00000/00000/xxxxx.jpg'
response = client.http.get(
    attachment_url,
    headers=client._base_headers
)
image_binary = response.content


fix: remove<EMAIL_ADDRESS>from archive import scripts

We need to go further though - these errors need to get to a place that can be automatically monitored.

Agreed. Syslog? Will the new infrastructure monitor logs?


[AutoPR compute/resource-manager] [DO NOT MERGE] Auto PR experiment

Created to sync https://github.com/Azure/azure-rest-api-specs/pull/2605

(message created by the CI based on PR content)


Add a LICENSE

It would be good to add a license to the project, so that it is clear to everyone about how they can use the content associated with it and any expectations that are brought along too (WITHOUT WARRANTY and all that usual jazz).

Good call, on it! #80


Nice colors

I don't like elementary colors. I like nice colors.
50 Beautiful Color Palettes for Your Next Web Project

I thought about customizable color map. I hope sometimes to implement them :)

I'm looking forward to that!


Fix: Carthage support is broken

In the current master, using the repository with carthage fails as it cannot find the shared framework scheme for the framework as no target exists. The proper way is to have a project with two targets: one for the framework and one for the example.
This pull request does that and also maintain compatibility with Cocoapod.

Thank you for your pull request.
Going to have a look at it tonight.

A bit later. But I hade a look at your PR.
I noticed you put everything in one .xcodeproj file. It would be nice to have this separate, the framework and example, and putting this together in a workspace. More like Alamofire does this.
I've created a Carthage-fix branch where I combined your fixes (1155994e604e41a669d46dd92ed948768056e4f7). It would be nice if you could have a look at it, maybe I forgot something.
Again thanks for your Pull request.

Merged the Carthage-fix branch into the Master branch 1155994e604e41a669d46dd92ed948768056e4f7.


query plan not rendering

Azure Data Studio Version:
latest release with vscode merge

Steps to Reproduce:

open a query editor and type in a query, e.g. select * from sys.tables
click explain button
the query plan is rendered properly
click explain again

expected: query plan renders correctly
actual: empty query plan area

Do you have a better repro for this?

I'm going to close this as no repro


Set filter for file open and save dialogs / Add new setting for default commit comment

Set the file filter dropdown and default to *.ZIP in file open and save dialogs

(still an aG beginner... didn't means to combine those changes, sorry)

Some screenshots of the new setting with $FILE:

or using $OBJECT

personally I think the predefined commit comment is an anti pattern, but its behind a user flag, so ok

Thx for approving! It's a great simplifier esp. when you're the only one commiting to your own repos 👍


How do I run forward computing with C++?

Thanks to open source code and outstanding contributions. I would like to ask how to deploy yolact in actual production with C++. I want to convert a .pth model file into a .pt model file. Could you give me some reasonable suggestions? and what is the role of ‘use_jit’ in the configuration file? Thank you so much!

Do you mean through Pytorch 1.0 script? Doing so would essentially require a total rewrite though, as I use too complex python to be able to easily swap it out for torchscript. You could probably interface with python using the Pytorch C++ bindings, but the model would still be run in python (i.e., slower than in native C++).
And what do you mean by converting a .pth file into a .pt file? If I understand this correctly, .pt is just another name for .pth.
I believe I removed use_jit, but basically I already wrapped the simple parts of the model in torchscript (backbone and FPN). Use_jit just specified whether or not to use those torchscript versions. I added it because torchscript does not play nicely with multiple GPUs, but now I've made it automatically disable JIT when it detects multiple GPUs.

I want to convert a python generated model file (.pth) into a model file (.pt) that C++ can call.(https://pytorch.org/tutorials/advanced/cpp_export.html#) I don't know which method to use. Could you give me some reasonable suggestions?Thanks for your prompt reply!

Ah I see. Like I said, porting all of Yolact to torchscript would require rewriting almost everything. You might find more luck with tracing, but I think it requires you to return and input only tensors from functions, and I definitely don't do that (so it would also require some rewriting, but much less than if you took the torchscript route). You can try this section, but there will be errors you'll need to fix (at least I think so).

@FightStone Maybe you can try this work flow: Pytorch->ONNX->NCNN. I have successfully done it, and test the c++ inference code on my ARM device:)

@Wilbur529 Can you please show detail steps?
I use torch.onnx.export to export the yolact model, but it plains that
>>> torch.onnx.export(model, batch, "yolact.onnx", verbose=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\__init__.py", line 27, in export
    return utils.export(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 104, in export
    operator_export_type=operator_export_type)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 281, in _export
    example_outputs, propagate)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 224, in _model_to_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 192, in _trace_and_get_graph_from_model
    trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 197, in get_trace_graph
    return LegacyTracedModule(f, _force_outplace)(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 252, in forward
    out = self.inner(*trace_inputs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 487, in __call__
    result = self._slow_forward(*input, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 477, in _slow_forward
    result = self.forward(*input, **kwargs)
  File "./yolact-master\yolact2.py", line 632, in forward
    outs = self.fpn(outs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 491, in __call__
    hook_result = hook(self, input, result)
  File "D:\Programs\Python\Python37\lib\site-packages\torchsummary\torchsummary.py", line 19, in hook
    summary[m_key]["input_shape"] = list(input[0].size())
AttributeError: 'list' object has no attribute 'size'

Maybe I should export the submodels(backbone, fpn, proto_net, segment_net) one by one?

@Wilbur529
When I try to convert yolact from pytorch to onnx, it complains:
./yolact-master\yolact.py:100: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if x.size() != self.last_size or self.training != self.last_training:
./yolact-master\yolact.py:260: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if self.last_conv_size != (conv_w, conv_h):
./yolact-master\layers\functions\detection.py:74: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  for batch_idx in range(batch_size):
./yolact-master\layers\box_utils.py:251: TracerWarning: There are 3 live references to the data region being modified when tracing in-place operator sub_. This might cause the trace to be incorrect, because all other views that also reference this data will not not reflect this change in the trace! On the other hand, if all other views use the same memory chunk, but are disjoint (e.g. are outputs of torch.split), this might still be safe.
  boxes[:, :2] -= boxes[:, 2:] / 2
./yolact-master\layers\box_utils.py:251: TracerWarning: There are 5 live references to the data region being modified when tracing in-place operator copy_ (possibly due to an assignment). This might cause the trace to be incorrect, because all other views that also reference this data will not not reflect this change in the trace! On the other hand, if all other views use the same memory chunk, but are disjoint (e.g. are outputs of torch.split), this might still be safe.
  boxes[:, :2] -= boxes[:, 2:] / 2
./yolact-master\layers\box_utils.py:252: TracerWarning: There are 4 live references to the data region being modified when tracing in-place operator add_. This might cause the trace to be incorrect, because all other views that also reference this data will not not reflect this change in the trace! On the other hand, if all other views use the same memory chunk, but are disjoint (e.g. are outputs of torch.split), this might still be safe.
  boxes[:, 2:] += boxes[:, :2]
./yolact-master\layers\box_utils.py:252: TracerWarning: There are 5 live references to the data region being modified when tracing in-place operator copy_ (possibly due to an assignment). This might cause the trace to be incorrect, because all other views that also reference this data will not not reflect this change in the trace! On the other hand, if all other views use the same memory chunk, but are disjoint (e.g. are outputs of torch.split), this might still be safe.
  boxes[:, 2:] += boxes[:, :2]
./yolact-master\layers\functions\detection.py:99: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if scores.size(1) == 0:
./yolact-master\layers\functions\detection.py:191: TracerWarning: Converting a tensor to a Python index might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  for _cls in range(num_classes):
./yolact-master\layers\functions\detection.py:199: TracerWarning: Converting a tensor to a Python boolean might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  if cls_scores.size(0) == 0:
./yolact-master\layers\functions\detection.py:202: TracerWarning: Converting a tensor to a NumPy array might cause the trace to be incorrect. We can't record the data flow of Python values, so this value will be treated as a constant in the future. This means that the trace might not generalize to other inputs!
  preds = torch.cat([boxes[conf_mask], cls_scores[:, None]], dim=1).cpu().detach().numpy()
./yolact-master\layers\functions\detection.py:204: TracerWarning: torch.Tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.
  keep = torch.Tensor(keep, device=boxes.device).long()
Traceback (most recent call last):
  File "D:\Projects\Python\201904\yolcat_seg\th2ks.py", line 238, in <module>
    torch.onnx.export(model, batch, "yolact.onnx", verbose=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\__init__.py", line 27, in export
    return utils.export(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 104, in export
    operator_export_type=operator_export_type)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 281, in _export
    example_outputs, propagate)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 224, in _model_to_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 192, in _trace_and_get_graph_from_model
    trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 197, in get_trace_graph
    return LegacyTracedModule(f, _force_outplace)(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 253, in forward
    out_vars, _ = _flatten(out)
RuntimeError: Only tuples, lists and Variables supported as JIT inputs, but got dict

Can you please show your detail steps to make it work?

@ausk Hi, There are some key points to note:

Turn off JIT;
Just return the practical output value from the network (instead of the post-processing result of the prediction head);
Rewrite some codes to fix the parameters of some operators, just like protonet, FPN;
Decoding output by yourself( post processing, NMS,  and so on).

@Wilbur529  Hi, thank you for your advide and patient.
I follow your advice to export it into onnx format.

Turn off JIT:  set PYTORCH_JIT environment, and remove @torch.jit.script decorator, and delect JITModule、jit_backbone in yolact.py.
return list of Tensors from PredictionModule::forward and Yolact::forward.
delete decoding operations in Yolact::forward

The input shape is:
torch.Size([1, 3, 550, 550])

The outputs shapes look like ok:
torch.Size([1, 19248, 4])
torch.Size([1, 19248, 81])
torch.Size([1, 19248, 32])
torch.Size([1, 138, 138, 32])

Then when calling  torch.onnx.export(model, batch, "yolact.onnx", verbose=True), it complains:
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 211, in _model_to_graph
    assert example_outputs is not None, "example_outputs must be provided when exporting a ScriptModule"
AssertionError: example_outputs must be provided when exporting a ScriptModule

It seems like that the module is running in JIT or Script mode. But I'm sure the environment is set PYTORCH_JIT=0. I just have no idea how to fix it. Have you encounter such an issue?

@ausk I turned off JIT by modify the configure file.
https://github.com/dbolya/yolact/blob/13b49d749b734b098a292c8c5226017b344ccc67/data/config.py#L566
Just add this line to the configure dictionary that you used, and change it to True.

@ausk I turned off JIT by modifying the configure file.
https://github.com/dbolya/yolact/blob/13b49d749b734b098a292c8c5226017b344ccc67/data/config.py#L566
Just add this line to your configure dictionary, and change it to True.

@Wilbur529 I forgot to say that I modified the line. I'm still trying to debug it. Thank you for you time. :)

@FightStone Maybe you can try this work flow: Pytorch->ONNX->NCNN. I have successfully done it, and test the c++ inference code on my ARM device:)
hi，I use the torch.onnx.export(net,dummy_input,'yolact.onnx',verbose=True,training=False) to convert pth to ONNX ,but it complains:
out_put = torch_onnx.export(net,dummy_input,'yolact.onnx',verbose=True,training=False)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\onnx_init_.py", line 27, in export
return utils.export(*args, **kwargs)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\onnx\utils.py", line 104, in export
operator_export_type=operator_export_type)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\onnx\utils.py", line 281, in _export
example_outputs, propagate)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\onnx\utils.py", line 224, in _model_to_graph
graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\onnx\utils.py", line 192, in _trace_and_get_graph_from_model
trace, torch_out = torch.jit.get_trace_graph(model, args, force_outplace=True)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\jit_init.py", line 197, in get_trace_graph
return LegacyTracedModule(f, force_outplace)(*args, **kwargs)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 489, in call
result = self.forward(*input, **kwargs)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\jit_init.py", line 252, in forward
out = self.inner(*trace_inputs)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 487, in call
result = self._slow_forward(*input, **kwargs)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 477, in _slow_forward
result = self.forward(*input, **kwargs)
File "D:\work\my_install\yolact\yolact.py", line 614, in forward
return self.detect(pred_outs)
File "D:\work\my_install\yolact\layers\functions\detection.py", line 75, in call
decoded_boxes = decode(loc_data[batch_idx], prior_data)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 487, in call
result = self._slow_forward(*input, **kwargs)
File "D:\programs\Anaconda3-4.2.0\envs\pytorch\lib\site-packages\torch\nn\modules\module.py", line 477, in _slow_forward
result = self.forward(*input, **kwargs)
RuntimeError: isTensor() ASSERT FAILED at ..\aten\src\ATen/core/ivalue.h:186, please report a bug to PyTorch. (toTensor at ..\aten\src\ATen/core/ivalue.h:186)
(no backtrace available)
could you tell me ,how to convert pth to onnx?

@Wilbur529 I forgot to say that I modified the line. I'm still trying to debug it. Thank you for you time. :)
Excuse me,have you solved your problem,I'm also converting it to onnx,I met the same problem,could you please give me some suggestion.

@Wilbur529 I forgot to say that I modified the line. I'm still trying to debug it. Thank you for you time. :)

Excuse me,have you solved your problem,I'm also converting it to onnx,I met the same problem,could you please give me some suggestion.

Hi @ausk ,
Did you succeed in converting the weights אם ONNX?

@Wilbur529 @ausk  Hello were you able to successfully convert the yolact model to ONX since i am also facing the same issues during conversion , would you be able to share the converted model and elaborate the steps of conversion that would be much helpful

@abhigoku10 Since the  converted model may not help you, maybe you could share the problem description you met with us.

@Wilbur529 Hi, first of all, because of your success, it has given me the confidence to explore. :) :)
Secondly,  I modified the code in yolact.py like this:
return (pred_outs['loc'], pred_outs['conf'], pred_outs['mask'], pred_outs['proto'])
not return self.detect(pred_outs)
Third, I modified the code like this to generate a forward model  via Tracing:
traced_script_module = torch.jit.trace(net, batch)
traced_script_module.save("xxx/model.pt")
Fourth, I success generate a forward model named model.pt.
But, when i do inference like this:
std::vectortorch::jit::IValue inputs;
inputs.push_back(torch::ones({1, 3, 550, 550}).to(at::kCUDA));
at::Tensor output = module->forward(inputs).toTensor();
There was an error:
terminate called after throwing an instance of 'c10::Error'
what():  isTensor() INTERNAL ASSERT FAILED at /home/sn19038157/libtorch/include/ATen/core/ivalue_inl.h:119, please report a bug to PyTorch.  (toTensor at /home/sn19038157/libtorch/include/ATen/core/ivalue_inl.h:119)
what should I do? I would be grateful if I could help me a little. :( :(

@FightStone I think you are going to try the pytorch->caffe2->C++ work flow, which i haven't tried. Maybe you can try to update Pytorch to the latest version. But i still suggest you tring Pytorch->ONNX->NCNN, because NCNN is a high-performance NN inference computing framework.

@Wilbur529 Can you share your forward processing code? Or introduce some classic C++ forward processing code examples? Because the relevant information is not a lot.

@ausk Hi, There are some key points to note:

Turn off JIT;
Just return the practical output value from the network (instead of the post-processing result of the prediction head);
Rewrite some codes to fix the parameters of some operators, just like protonet, FPN;
Decoding output by yourself( post processing, NMS,  and so on).

@Wilbur529  can you share the modified part of the code , since step1 of tunoff JIT is done and the other steps its a bit confusing . either would be able to elaborate the changes to be made

@FightStone For pre-processing, it's just a simple normalization. And for post-processing, you could refer to the implementation of NCNN(https://github.com/Tencent/ncnn/blob/master/src/layer/detectionoutput.cpp):)

@abhigoku10 Sry for that i could not show you this part of code because of the company rules. About the second point, you could return a list of these outputs. The third point, since the ONNX framework only supports fixing net parameters, so you need to change some variables to constants. The last one, refer to the post-processing python code of YOLACT or other implementation, and translate them to C/C++. May success wait upon your efforts:)

@Wilbur529  shall try to do this , how much time do u think will it take to do the whole process of conversion . When converted was there any change in the fps values ?
@FightStone  please share the code base which you have modified

@abhigoku10 The fps depends on the hardware environment. So only experiment will tell you the answer:)

@Wilbur529 yup rightly said, so for ur hardware env what was the fps u were achieving

@abhigoku10 I run YOLACT(ResNet-101) on my MacBook Pro with 550*550 input size, costing around 1.5s per frame.

@Wilbur529 thanks for the response i am interested to know about mobilenet architecture fps

@Wilbur529
When I try to convert yolact from pytorch to onnx, it complains:
Traceback (most recent call last):
  File "D:\Projects\Python\yolcat_seg\test.py", line 238, in <module>
    torch.onnx.export(model, batch, "yolact.onnx", verbose=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\__init__.py", line 27, in export
    return utils.export(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 104, in export
    operator_export_type=operator_export_type)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 281, in _export
    example_outputs, propagate)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 224, in _model_to_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 192, in _trace_and_get_graph_from_model
    trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 197, in get_trace_graph
    return LegacyTracedModule(f, _force_outplace)(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 253, in forward
    out_vars, _ = _flatten(out)
RuntimeError: Only tuples, lists and Variables supported as JIT inputs, but got dict

Can you please show your detail steps to make it work?

@Wilbur529
When I try to convert yolact from pytorch to onnx, it complains:
Traceback (most recent call last):
  File "D:\Projects\Python\yolcat_seg\test.py", line 238, in <module>
    torch.onnx.export(model, batch, "yolact.onnx", verbose=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\__init__.py", line 27, in export
    return utils.export(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 104, in export
    operator_export_type=operator_export_type)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 281, in _export
    example_outputs, propagate)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 224, in _model_to_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 192, in _trace_and_get_graph_from_model
    trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 197, in get_trace_graph
    return LegacyTracedModule(f, _force_outplace)(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 253, in forward
    out_vars, _ = _flatten(out)
RuntimeError: Only tuples, lists and Variables supported as JIT inputs, but got dict

Can you please show your detail steps to make it work?

Hi!
Did you face this error when you run in device as CPU or GPU?

@Wilbur529
When I try to convert yolact from pytorch to onnx, it complains:
Traceback (most recent call last):
  File "D:\Projects\Python\yolcat_seg\test.py", line 238, in <module>
    torch.onnx.export(model, batch, "yolact.onnx", verbose=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\__init__.py", line 27, in export
    return utils.export(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 104, in export
    operator_export_type=operator_export_type)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 281, in _export
    example_outputs, propagate)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 224, in _model_to_graph
    graph, torch_out = _trace_and_get_graph_from_model(model, args, training)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 192, in _trace_and_get_graph_from_model
    trace, torch_out = torch.jit.get_trace_graph(model, args, _force_outplace=True)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 197, in get_trace_graph
    return LegacyTracedModule(f, _force_outplace)(*args, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\nn\modules\module.py", line 489, in __call__
    result = self.forward(*input, **kwargs)
  File "D:\Programs\Python\Python37\lib\site-packages\torch\jit\__init__.py", line 253, in forward
    out_vars, _ = _flatten(out)
RuntimeError: Only tuples, lists and Variables supported as JIT inputs, but got dict

Can you please show your detail steps to make it work?

Did you make the Yolact code cpompatible to run in CPU and then you got this error while trying to convert Pytorch model to ONNX format?

@ashank-art  Please follow my second key point. Replace the output with a list of tensors that have no post-processing.

Has anyone tried Pytorch to Tensorflow conversion for Yolact?

@ridasalam  nope i have not tried tensorflow currently trying with onx , let me knwo if you have tried tf

Sup?
anything new with the Pytorch to Tensorflow conversion for Yolact?

@Wilbur529  I change model output from dict to list now,  and can get onnx converted file.
I am not sure the onnx file is right or not.  From the comments you have mentioned above,
I am confused how to do the third point, as I have relevant errors about it.
When I convert onnx to mnn, it shows:
type=slice, failed, may be some node is not const
And I  check pytorch to onnx process,  the slice op is 873 and 874,
it is a slice operation for:
scores, idx2 = scores.sort(0, descending=True)
idx2 = idx2[:cfg.max_num_detections]
scores = scores[:cfg.max_num_detections]
(before this line, there is a proposal number k is not a fixed number , input is random variable 5505503 )
Do you have some advice? Thank you. I don't know how to modify this part.

@Wilbur529 Hi, thank you for your advide and patient.
I follow your advice to export it into onnx format.

Turn off JIT:  set PYTORCH_JIT environment, and remove @torch.jit.script decorator, and delect JITModule、jit_backbone in yolact.py.
return list of Tensors from PredictionModule::forward and Yolact::forward.
delete decoding operations in Yolact::forward

The input shape is:
torch.Size([1, 3, 550, 550])

The outputs shapes look like ok:
torch.Size([1, 19248, 4])
torch.Size([1, 19248, 81])
torch.Size([1, 19248, 32])
torch.Size([1, 138, 138, 32])

Then when calling  torch.onnx.export(model, batch, "yolact.onnx", verbose=True), it complains:
  File "D:\Programs\Python\Python37\lib\site-packages\torch\onnx\utils.py", line 211, in _model_to_graph
    assert example_outputs is not None, "example_outputs must be provided when exporting a ScriptModule"
AssertionError: example_outputs must be provided when exporting a ScriptModule

It seems like that the module is running in JIT or Script mode. But I'm sure the environment is set PYTORCH_JIT=0. I just have no idea how to fix it.

Hi, Have you solved the issue?  I met it before, you can change the pytorch version, and I can use pytorch1.2 to convert with no this issue.
Besides, can you get the converted onnx model with no problem right now? I can convert pytorch model to onnx, but it fails when excute onnx check_model step. And the onnx file can not convert to mnn file as slice op failed, it shows:  slice must be a const.
looking forward to your reply

@abhigoku10 Sry for that i could not show you this part of code because of the company rules. About the second point, you could return a list of these outputs. The third point, since the ONNX framework only supports fixing net parameters, so you need to change some variables to constants. The last one, refer to the post-processing python code of YOLACT or other implementation, and translate them to C/C++. May success wait upon your efforts:)

@Wilbur529 have you compare the map between onnx and pytorch?   according to test result in my loacl coco val test,  the mAP for mask decrease more than 4.3 points from almost 30.0 to  25.4

@ausk Hi, There are some key points to note:

Turn off JIT;
Just return the practical output value from the network (instead of the post-processing result of the prediction head);
Rewrite some codes to fix the parameters of some operators, just like protonet, FPN;
Decoding output by yourself( post processing, NMS,  and so on).

converted to onnx, and then converted to ncnn,  it complains
Shape not supported yet!

Unsupported unsqueeze axes !
Cast not supported yet!
to=1
Shape not supported yet!
Unsupported reduction axes !
Cast not supported yet!
to=1
How you solved the problem? Thanks!

I have put yolact example in ncnn project https://github.com/Tencent/ncnn/commit/043a8f1ac1293f78f5f6bafbd8710c0f7cf9dade
besides, you can learn how to achieve yolact inference with ncnn library here ( in chinese )  https://zhuanlan.zhihu.com/p/128974102

I have put yolact example in ncnn project Tencent/ncnn@043a8f1
besides, you can learn how to achieve yolact inference with ncnn library here ( in chinese ) https://zhuanlan.zhihu.com/p/128974102

Hi @nihui , thanks for your reply.
I have run compressed yolact  model on cellphone by mnn a month ago.  I will compare the time cost. BTW, ncnn is a great job

@dzyjjpy @nihui  can you both please share the process and code to run on the mobile device , is it android or ios

@Wilbur529 Hi,how big you onnx model(ResNet-101)?

@FightStone Maybe you can try this work flow: Pytorch->ONNX->NCNN. I have successfully done it, and test the c++ inference code on my ARM device:)

can you public the detail your code and how to install it? thanks

@FightStone Maybe you can try this work flow: Pytorch->ONNX->NCNN. I have successfully done it, and test the c++ inference code on my ARM device:)

can you public the detail your code and how to install it? thanks

or a turotial, how can i install it on my device?

@FightStone  it will be good to share the process of conversion thanks , where you successfull in converting yolact++ also ??

谢谢dalao, 希望一起交流学习 qq：975966355

I have put yolact example in ncnn project Tencent/ncnn@043a8f1
besides, you can learn how to achieve yolact inference with ncnn library here ( in chinese ) https://zhuanlan.zhihu.com/p/128974102

@nihui I used the steps in tutorial but when I convert from yolact.onnx to yolact-sim.onnx I get the following error
Simplifying...
2020-11-25 14:23:14.998210246 [E:onnxruntime:, sequential_executor.cc:318 Execute] Non-zero status code returned while running Resize node. Name:'' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/upsample.h:280 void onnxruntime::UpsampleBase::ScalesValidation(const std::vector&, onnxruntime::UpsampleMode) const scales.size() == 2 || (scales.size() == 4 && scales[0] == 1 && scales[1] == 1) || scales.size() == 3 || (scales.size() == 5 && scales[0] == 1 && scales[1] == 1) was false. 'Linear' mode only support 2-D inputs or 3-D inputs ('Bilinear', 'Trilinear') or 4-D inputs or 5-D inputs with the corresponding outermost 2 scale values being 1 in the Resize operator
Traceback (most recent call last):
File "/home/user/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "/home/user/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/user/anaconda3/lib/python3.7/site-packages/onnxsim/main.py", line 52, in
main()
File "/home/user/anaconda3/lib/python3.7/site-packages/onnxsim/main.py", line 40, in main
args.input_model, check_n=args.check_n, perform_optimization=not args.skip_optimization, skip_fuse_bn=not args.enable_fuse_bn, input_shapes=input_shapes, skipped_optimizers=args.skip_optimizer, skip_shape_inference=args.skip_shape_inference)
File "/home/user/anaconda3/lib/python3.7/site-packages/onnxsim/onnx_simplifier.py", line 332, in simplify
model, const_nodes, input_shapes=input_shapes)
File "/home/user/anaconda3/lib/python3.7/site-packages/onnxsim/onnx_simplifier.py", line 172, in forward_for_node_outputs
res = forward(model, input_shapes=input_shapes)
File "/home/user/anaconda3/lib/python3.7/site-packages/onnxsim/onnx_simplifier.py", line 162, in forward
outputs, inputs, run_options=run_options)))
File "/home/user/.local/lib/python3.7/site-packages/onnxruntime/capi/session.py", line 123, in run
return self._sess.run(output_names, input_feed, run_options)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Non-zero status code returned while running Resize node. Name:'' Status Message: /onnxruntime_src/onnxruntime/core/providers/cpu/tensor/upsample.h:280 void onnxruntime::UpsampleBase::ScalesValidation(const std::vector&, onnxruntime::UpsampleMode) const scales.size() == 2 || (scales.size() == 4 && scales[0] == 1 && scales[1] == 1) || scales.size() == 3 || (scales.size() == 5 && scales[0] == 1 && scales[1] == 1) was false. 'Linear' mode only support 2-D inputs or 3-D inputs ('Bilinear', 'Trilinear') or 4-D inputs or 5-D inputs with the corresponding outermost 2 scale values being 1 in the Resize operator

I have put yolact example in ncnn project Tencent/ncnn@043a8f1
besides, you can learn how to achieve yolact inference with ncnn library here ( in chinese ) https://zhuanlan.zhihu.com/p/128974102

我根据这两个帖子，成功的把模型转成了onnx，https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_YOLACT.html and https://github.com/Ma-Dan/yolact/tree/onnx
问题是转换成onnx后，速度降低不少（30ms vs 125ms），主要问题出在onnx需要把资料从gpu搬回cpu上，我尝试过利用torchvision.nms处理nms，但是运算速度更慢(高于1000ms)，不知道哪里出了问题，在知乎上看见一篇文章提到（请问是大佬你写的吗？），“后处理在onnx中会转换成一大坨胶水op，非常琐碎，在框架中实现效率低下”， 是onnx或pytorch，或两者皆是，在nms这块的转换上，处理的不好？

@stereomatchingkiss 可以提供一下pytorch版本么，我尝试把模型转成onnx，却失败了
出现 “Could not convert to integer:<PHONE_NUMBER>. Path 'exitCode'.”这个错误
参考https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_YOLACT.html
https://github.com/Ma-Dan/yolact/tree/onnx

@stereomatchingkiss 可以提供一下pytorch版本么，我尝试把模型转成onnx，却失败了 出现 “Could not convert to integer:<PHONE_NUMBER>. Path 'exitCode'.”这个错误 参考https://docs.openvinotoolkit.org/latest/openvino_docs_MO_DG_prepare_model_convert_model_pytorch_specific_Convert_YOLACT.html https://github.com/Ma-Dan/yolact/tree/onnx

我是用LTS version转的，1.8.2，最新版的export onnx有点bug


SequencerRepair fault detection strategy: Log parsing

The error log from a failing build is a rich source of information about possible faults that could be fixed. The approach should be similar to Travis-Listener/logparser.
This idea is not compatible with the current default pipeline because it will only attempt a fix if the scanned project is buildable. This way we may skip many possible syntax errors detection and fix attempts.
A good approach is to run a different pipeline if log parsing is used as fault detection strategy.
Another approach could be branching the pipeline, use log parsing if the project is not buildable, or use Astor if it is the tests that are failing.

The error log from a failing build is a rich source of information about possible faults that could be fixed.

Yes, both about the fault type and the fault location (file name or line numbers in the logs, eg with exceptions).
This is a very little researched and exploited area.

I guess we can consider that #1092 closes this


Fix additional title level issue on CLI

Coverage increased (+0.09%) to 93.836% when pulling 3da1b680dd0575b590226e9035364666aa92ae43 on develop into 626845c692c31b8cf50767403dab57eae48a891d on master.

Coverage decreased (-1.08%) to 92.667% when pulling a29e187ddf81bb568aa519cc2dfeb8cf782f52f1 on develop into 626845c692c31b8cf50767403dab57eae48a891d on master.

Coverage decreased (-1.08%) to 92.667% when pulling 319a6d779008270c842924855ea2d87b526687ea on develop into 626845c692c31b8cf50767403dab57eae48a891d on master.


Rework bookkeeping constants

I'd like to be able to encourage people to run golint without
forcing them to write a comment for the test version constant.
Closes #177

Thanks for dealing with the mechanical but "somebody's gotta do it" change. My comments fall into three categories:

Sure about TesttestVersion instead of TestTestVersion? The former seems to imply the function is named "testtest version" instead of "test test version" by the rules of camel casing. I don't feel strongly about this.
The instructions of "Also define an exported TestVersion" has changed to "Also define an exported testVersion" but this instruction is inaccurate since testVersion isn't exported.
error-handling exercise doesn't seem to check its test version at all.

I totally missed the "exported" comment. I changed the stuff in the README, but completely overlooked the comments in the test files themselves.
The Testtest was also a mistake. I did some global renames and didn't notice it in the diff.
I'll put in a PR for the test version on the error handling thing in a moment.

:+1:


ARTEMIS-2354 Improve compatibillity of tests with JDK 11

Travis was messed up so I ran the PR build locally.


No options for passive voice

Would you accept a PR that adds the passive voice?  I see a stub for it here:
https://github.com/rossmeissl/verbs/blob/master/lib/verbs/conjugator.rb#L43

Hi @jeidsath, I wll be having accepted one with pleasure!

PR: https://github.com/rossmeissl/verbs/pull/27

Continuing conversation in #27


automigrate fails if the table doesn't exist

I'm just trying out the connector and noticed an error when trying to run automigrate.
I've got a new collection that hasn't been created in the arango database. The automigrate script throws an error saying the collection doesn't exist (which defeats the purpose a bit).
I've narrowed it down to the callback to collection.drop
      return collection.drop(function(err) {
        if (err) {
          if (err.response.body != null) {
            err = err.response.body;
            if (!(err.error === true && err.errorNum === 1203 && err.errorMessage === 'unknown collection \'' + model + '\'')) {
                return modelCallback(err);
            }
          }
        }
        debug('create collection %s for model %s', collectionName, model);
        return collection.create(modelCallback);
      });

I'm not sure if there's a reason behind having this but taking out the if (err) section fixes the first migration problem.

@doginthehat Sorry for the long delay... It's possible to have fork of repository that reproduce the issue?
Thanks

@mrbatista That was part of an experimentation test project I had at the time.
From top my head it was fairly basic, add model > run an automigrate server boot script > error.
I'm guessing it's because it tries to drop the collection even if it doesn't exist.. probably needs to check existence before dropping.
I could try to put a test together, but not sure when I'll get to it.


Give OPDS importers an API class (PP-501)

Description
Previously OPDS importers were a special case, they had no API class, there there was a special code path for checkouts and fulfillment taken. Now they are treated like every other license source, with their own BaseCirculationAPI.
Motivation and Context
This is another step along the path to removing external integrations from license source integrations.
How Has This Been Tested?

Running tests

Checklist

[X] I have updated the documentation accordingly.
[X] All new and existing tests passed.

I started a review of this today and plan to finish it up tomorrow.

Rebased on main, and made code review changes.


Add disabled prop to render without interaction

Sometimes it can be nice to render a slider that should not be changed by the user. This pull request adds a prop disabled that disabled touch, keyboard and click inputs.

👍 @whoisandy Any chance you can merge this in?

It will also solve #109

This would be really useful.

is this ever getting merged?

Hi @whoisandy ,
This feature seems to be really wanted, I would also like to have it. Is there any chance to be merged at some point or you don't like the solution ?


i am using angularjs and django-cors-headers then give “which is disallowed for cross-origin requests that require preflight.”

I have a Django local sever that refer to 8000 port number, And a local nginx that load 2080 port number html page.
I install django-cross-header package for resolving cross-domain error.
django-cross-header config in settings.py:
CORS_ALLOW_CREDENTIALS = True

CORS_ORIGIN_ALLOW_ALL = True

  CORS_ALLOW_HEADERS = (
         'x-requested-with',
         'content-type',
         'accept',
         'origin',
         'authorization',
         'x-csrftoken'
 )

  CORS_ORIGIN_WHITELIST = (
          '<IP_ADDRESS>:2080',
          'localhost:2080'
  )

Config angularjs is like this:
portman.config(function ($routeProvider, $interpolateProvider, $httpProvider) {
     $routeProvider.otherwise('/');
     $httpProvider.defaults.headers.common['X-CSRFToken'] = csrftoken;
     $interpolateProvider.startSymbol('{$').endSymbol('$}');
     delete $httpProvider.defaults.headers.common['X-Requested-With'];

 });
 portman.constant('ip','http://<IP_ADDRESS>:8000/');

Get method code in angularjs is:
$http({
         method: 'GET',
         url: ip+'api/v1/dslam/events',
     }).then(function (result) {
        $scope.dslam_events = result.data;
     }, function (err) {

    });

request header is :
Provisional headers are shown
Accept:application/json, text/plain, */*
Origin:http://<IP_ADDRESS>:2080
Referer:http://<IP_ADDRESS>:2080/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36
X-CSRFToken:ztouFO8vldho97bWzY9mHQioFk3j6h5V

After loading the page I see this error:
XMLHttpRequest cannot load http://<IP_ADDRESS>:8000/api/v1/dslam/events.The request was redirected to 'http://<IP_ADDRESS>:8000/api/v1/dslam/events/', which is disallowed for cross-origin requests that require preflight.
But when i send request from console it will corectly response from django server, my jquery code :
$.ajax({
            type: 'GET',
            url: "http://<IP_ADDRESS>:8020/api/v1/dslam/events/",
            success:function(data){
             console.log(data);
            }
        });

request header is:
Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,fa;q=0.6,pt;q=0.4
Connection:keep-alive
Host:<IP_ADDRESS>:8000
Origin:http://<IP_ADDRESS>:2080
Referer:http://<IP_ADDRESS>:2080/
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.99 Safari/537.36

please help me

Are you using Django 1.10? If so, django-cors-headers won't work anymore because it doesn't support 1.10. See this issue.

Duplicate of #105


How to get Model data

Hi, so far I've been using jQuery to get Model id from event.params.data.id
Something like:
$('select').on('select2:select', function (event) {
  console.log(event.params.data.slug);
  ...
}

I used id to build a url and then redirect the user to it using JS (ofter click on a button).
Now I moved my Model and urls.py to use field slug. How can I add it to the same event object?
This is how I build my form:
class HomeForm(forms.Form):
    dj_name = forms.ModelChoiceField(
        queryset=DjProfile.objects.all(),
        widget=autocomplete.ModelSelect2(
            url='dj-autocomplete',
            attrs={
                # Set some placeholder
                'data-placeholder': 'Trova Dj',
                # Only trigger autocompletion after 3 characters have been typed
                'data-minimum-input-length': 3,
            },
        )
    )

and this is what dj-autocomplete points to:
class DjProfileAutocomplete(autocomplete.Select2QuerySetView):
    def get_queryset(self):
        qs = DjProfile.objects.all()
        return qs.filter(name__icontains=self.q) if self.q else qs

For now I solved overriding the get_result_value method in order to returns my Model's slug.
class DjProfileAutocomplete(autocomplete.Select2QuerySetView):
    def get_queryset(self):
        qs = DjProfile.objects.all()
        return qs.filter(name__icontains=self.q) if self.q else qs

    def get_result_value(self, result):
        return result.slug

this is definitely not the correct approach but put me one step ahead vs where I was few hours ago ... any other suggestion will be greatly appreciated!

Perhaps you could try to return a json list of dicts with a slug in addition to id and text in an override of get_results.
Then, figure a way with select2 ;)


Feature/Example Request: syscall(kevent)-based tokio async interoperability

Merry Christmas and Happy Holidays! 🎄
Is your feature request related to a problem? Please describe.
I have a WebAssembly binary generated by compiling from Rust, in which async I/O operations are performed using tokio.
However, the WebAssembly panics when performing async read operations:
thread '<unnamed>' panicked at /path/to/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.35.1/src/runtime/io/driver.rs:157:23:
unexpected error when polling the I/O driver: Os { code: 58, kind: Uncategorized, message: "Not supported" }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Ref: tokio-1.35.1/src/runtime/io/driver.rs:157
I noticed this error was actually returned by mio::Poll::poll()(Docs), which calls to Selector::select()(Source). So it is likely the invoked syscall(kevent) has triggered the OS error.
Describe the solution you'd like
Since the given operation can be executed perfectly fine on at least one other popular WebAssembly runtime (wasmtime) with rest of them untested, the best option is seemingly adding the related syscall support in full in order to support complete async/nonblocking operations.
Describe alternatives you've considered
Or, it could be due to a mistake on my end for non-standard use of wazero (see Additional Context). I would be rather happy to see an existing example that works with tokio::select and tokio::io::AsyncReadExt::read().
Additional context
So I am indeed doing something weird (#1857). I patched several interfaces in wazero to allow me insert net.TCPConn into WebAssembly with access through a file descriptor.

(*Context).InsertTCPConn

func (c *Context) InsertTCPConn(conn *net.TCPConn) (key int32, ok bool) {
	return c.fsc.openedFiles.Insert(&FileEntry{
		IsPreopen: true,
		File:      fsapi.Adapt(sysfs.NewTCPConnFile(conn)),
	})
}

Inside WebAssembly I am wrapping the fd back into a TCP connection (std::net::TcpStream):

stdasync/lib.rs

use std::io::{Read, Write};
use std::os::fd::FromRawFd;

#[export_name = "_read"]
pub fn _worker(fd: i32) -> i32 {
    let mut stdstream = unsafe { std::net::TcpStream::from_raw_fd(fd) };
    stdstream
        .set_nonblocking(true)
        .expect("Failed to set non-blocking");

    // in a loop, read from fd, write to fd
    let mut buf = vec![0; 1024];
    match stdstream.read(&mut buf) {
        Ok(0) => break, // End of stream
        Ok(n) => {
            if let Err(e) = stdstream.write(&buf[..n]) {
                println!("Error writing to fd: {:?}", e);
                // ...
            }
            println!("written {} bytes", n)
        }
        Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => {
            println!("WouldBlock... retrying.");
            continue; // retry
        }
        Err(e) => {
            println!("Error reading from fd: {:?}", e);
            // ...
        }
    }

    // ...
}

Which works perfectly, both read and write could be performed correctly.
But it will not work if "upgraded" with tokio.

tokioasync/lib.rs

#[tokio::main(flavor = "current_thread")]
async fn tokio_worker(conn: std::net::TcpStream) -> std::io::Result<()> {
    let mut conn: tokio::net::TcpStream =
        tokio::net::TcpStream::from_std(conn).expect("Failed to convert to tokio stream");

    println!("tokio_worker: conn = {:?}", conn);

    let mut rd_buf = vec![0; READ_BUFFER_SIZE];

    loop {
        tokio::select! {
            result = conn.read(&mut rd_buf) => {
                // println!("dst.read() result = {:?}", result);
                match result {
                    Ok(0) => break, // End of stream
                    Ok(n) => {
                        println!("read {} bytes", n);
                        if let Err(e) = conn.write_all(&rd_buf[0..n]).await {
                            println!("Error writing to conn: {:?}", e);
                            return Err(e);
                        }
                    }
                    Err(e) => {
                        println!("Error reading from conn: {:?}", e);
                        return Err(e);
                    }
                }
            }
        }
    }

    Ok(())
}

So I have made an educated guess that I have been doing what supposed to be done for my purposes. But if there are apparently better ways to insert TCP connections/sockets dynamically (i.e., after instantiation), I am open to advices.

I definitely don't have enough Rust knowledge to triage this, but for the benefit of others and yourself, do you have code that you can share that shows the issue?
You patched wazero, where's this patched wazero?
You built a WASM module, can you share it, both in binary and source form?
I don't mean snippets, but a minimal, complete and verifiable example.
Without that, it seems very unlikely that anyone will be able to help you.

Thanks for your timely response!

You patched wazero, where's this patched wazero?

I simply patched it in my fork here: https://github.com/gaukas/wazero

a minimal, complete and verifiable example

Gladly. https://github.com/gaukas/wasmasync contains the requested examples, including a driver written in Go (using my fork of wazero), 4 examples written in Rust (asyncrs, asynctokio, asynctokio2, syncrs) and 1 example in WAT.

Any general feedback would be really helpful as well, including my patch and advice on creating WebAssembly binary achieving the same goal.
One reason I had to use Rust is that I could not figure out a proper way to do this in Go. It seems TinyGo's WASI target did not really like what I'm trying to do (recovering a fd into a file/socket and write to it). I could be doing it in a wrong way tho... It could be much easier if Go/TinyGo's WASI target actually supports everything I needed.

Hi, thanks for the detailed reproducer.
The error "Not supported" is likely not to be a real OS error but a WASI error, specifically, wazero's WASI implementation, which, in some cases, may return ENOTSUP.
First of all, you can get further information about what's going on at the WASI/FS/Socket layer by adding these lines to your main.go:
	// Configure host logging.
	ctx = context.WithValue(ctx, experimental.FunctionListenerFactoryKey{},
		logging.NewHostLoggingListenerFactory(os.Stderr, logging.LogScopeFilesystem|logging.LogScopePoll|logging.LogScopeSock))

This will enable host logging and dump to the console some further info about which syscalls are failing.
In this case, however, you can find the offender in wazero/imports/wasi_snapshot_preview1/poll.go. There is one case where we return ENOTSUP, i.e. if we find a subscription to FdWrite:
https://github.com/tetratelabs/wazero/blob/009ee7056c1f7afb597781851cc8b0f660c5bbc5/imports/wasi_snapshot_preview1/poll.go#L145-L156
Since you are already getting your hands dirty with the code base, you could arbitrarily return success to a writing subscription if the underlying fd is already in nonblocking mode. Notice this is somewhat correct for real disk files, but not quite correct for sockets, that's one of the reasons we are not supporting it at the moment: it requires significant plumbing on the codebase to support properly, and we had no evidence of real-world usage so far.
		case wasip1.EventTypeFdWrite:
			fd := int32(le.Uint32(argBuf))
			if fd < 0 {
				return sys.EBADF
			}
			if file, ok := fsc.LookupFile(fd); !ok {
				evt.errno = wasip1.ErrnoBadf
				writeEvent(outBuf[outOffset:], evt)
				nevents++
			} else if file.File.IsNonblock() {
				writeEvent(outBuf[outOffset:], evt)
				nevents++
			} else {
				evt.errno = wasip1.ErrnoNotsup
				writeEvent(outBuf[outOffset:], evt)
				nevents++
			}

Eventually, however, on my macOS system, asynctokio.wasm dies again with an EBADF returned by fd_read():
https://github.com/tetratelabs/wazero/blob/009ee7056c1f7afb597781851cc8b0f660c5bbc5/internal/sysfs/sock_unix.go#L106-L115
As you can see from the logs as well:
...
==> wasi_snapshot_preview1.fd_read(fd=3,iovs=1048300,iovs_len=1)
<== (nread=,errno=EAGAIN)
==> wasi_snapshot_preview1.fd_read(fd=3,iovs=1048300,iovs_len=1)
<== (nread=,errno=EBADF)
Error reading from fd: Os { code: 8, kind: Uncategorized, message: "Bad file descriptor" }
...

This also happens with asyncrs but not asynctokio2. I am not familiar enough with Rust and Tokio to tell if this is correct or not (i.e., EBADF should be due to the underlying FD being closed, although I can't find any evidence in the logs).
I also cannot exclude something is going on at the use-site in Go, e.g. the socket has been closed on that end and the wasm side is now accessing an invalid descriptor:
https://github.com/gaukas/wasmasync/blob/9c89b62a92059913607ee398836de361faaa52b4/main.go#L162-L168
maybe @ncruces or @achille-roussel have ideas :)

Thank you for such a detailed response and walkthrough!

that's one of the reasons we are not supporting it at the moment: it requires significant plumbing on the codebase to support properly

Thanks for the explanation. Is there an issue tracker or roadmap for what's needed to be done? I might be able to help in some ways.

on my macOS system, asynctokio.wasm dies again with an EBADF returned by fd_read()

This also happens with asyncrs but not asynctokio2.

This is a bit concerning since this error does not occur on my Linux test machine. Could you please try wasm/syncrs.wasm and/or wat/rw.wasm?
Also, do you have any insights on possible discrepancies between wazero's linux and macOS implementation which might be related to this issue? Or are you suggesting it is more likely unrelated to wazero but rather inside WebAssembly or in Go's host setup (before entering wazero)?
Again, thank you so much for your time and effort. I appreciate it.

let me first reply to the last question:

on my macOS system, asynctokio.wasm dies again with an EBADF returned by fd_read()

This also happens with asyncrs but not asynctokio2.

This is a bit concerning since this error does not occur on my Linux test machine. Could you please try wasm/syncrs.wasm and/or wat/rw.wasm?

I meant that applying the patch above the programs progress but they fail later with that error. Otherwise they fail exactly as you reported.

that's one of the reasons we are not supporting it at the moment: it requires significant plumbing on the codebase to support properly

Thanks for the explanation. Is there an issue tracker or roadmap for what's needed to be done? I might be able to help in some ways.

In general, requirements are user-driven, so in our experience, so far, nobody has encountered issues in the implementation before you. What's your use case? :o) And I mean, besides "I want to use Tokio" :P You can disclose it privately if you are more comfortable; reach us out on the Gophers slack. We hang on the #wazero channel but you can DM me if you prefer :)
In any case, to implement the missing part of poll_oneoff, it should:

respect the WASI description
in case of missing info, follow POSIX https://linux.die.net/man/3/poll / https://pubs.opengroup.org/onlinepubs/007904975/functions/poll.html
pass all tests on all platforms -- that's the hard part, Windows included.

In this particular case, as [https://www.remlab.net/op/nonblock.shtml][the Remlab article] put it,

writeability implies the send buffer is not full from the standpoint of the underlying protocol of the socket (e.g. TCP/IP).

so, my understanding is that a good implementation of a write subscription should return EAGAIN unless there is space left on the system buffer. How do you know? One way might be to simply invoke poll on the underlying fd. This in turn requires implementing File.Poll() on tcpConnFile and tcpListenerFile in sock_unix.go and doing the same on the Windows counterpart, then you will need to invoke File.Poll in poll.go when the FD is a socket: currently it is only really invoked on Stdin:
https://github.com/tetratelabs/wazero/blob/009ee7056c1f7afb597781851cc8b0f660c5bbc5/imports/wasi_snapshot_preview1/poll.go#L181-L182
So basically, this would require refactoring the entire pollOneoffFn to actually invoke poll instead of short-circuiting in a well-known case. Or, you should add more short-circuiting only in the case the FD is an actual socket (which, I would say, doesn't happen very often).

I meant that applying the patch above the programs progress but they fail later with that error.

Thanks for the clarification. That's actually what I meant, asyncrs and syncrs are expected to succeed, and I don't believe the patch will result in them failing.

Okay, so after applying the suggested patch, the async read operation does get through.
However, it is quite weird that the file descriptor inside WebAssembly will fail exactly 5 seconds after the function blocks for 5 seconds, no matter what's being done (e.g., number of bytes written), and if and only if tokio is involved. I did not reproduce the same error on asyncrs.
Further, the TCP connections are still alive after the WebAssembly function call fails. Which indicates it is unlikely a problem outside wazero. Guess I will spend more time looking into this.

hah, interesting both asyncrs and syncrs eventually fail even without the patch :D I suspect that does not have to do with async I/O but maybe (?) because the Go runtime eventually closes the fd. I was about to reply before your last message because I was booting up a Linux VM to check there too

So are we getting split results?
In conclusion on my end, Linux (Ubuntu 22.04), without the patch:

[x] syncrs
[x] asyncrs
[ ] asynctokio: Not supported
[ ] asynctokio2: Not supported

With the patch:

[x] syncrs
[x] asyncrs
[x] asynctokio: OK for the first 5 seconds, then Bad file descriptor
[x] asynctokio2: OK for the first 5 seconds, then Bad file descriptor

I just pushed an update to asynctokio2, which uses the loop correctly to infinitely read-then-write (instead of returning on the first success).

so yeah apparently I am getting Bad file descriptor in all cases when the patch is applied. Could it be version-dependent? I am testing against go1.21.5

My results are from Go 1.21.5 on Linux.

I think I figured this out. It is due to a very trivial misuse of (*net.TCPConn).File()
https://github.com/tetratelabs/wazero/blob/009ee7056c1f7afb597781851cc8b0f660c5bbc5/internal/sysfs/sock_unix.go#L98-L104
The code above called (*net.TCPConn).File() (returning (*os).File) and then (*os.File).Fd(), using it with an assumption that fd obtained is the underlying fd of the TCP connection. However the document says:

File returns a copy of the underlying os.File. It is the caller's responsibility to close f when finished. Closing c does not affect f, and closing f does not affect c.

Fd returns the integer Unix file descriptor referencing the open file. If f is closed, the file descriptor becomes invalid. If f is garbage collected, a finalizer may close the file descriptor, making it invalid; see runtime.SetFinalizer for more information on when a finalizer might be run. On Unix systems this will cause the SetDeadline methods to stop working. Because file descriptors can be reused, the returned file descriptor may only be closed through the Close method of f, or by its finalizer during garbage collection. Otherwise, during garbage collection the finalizer may close an unrelated file descriptor with the same (reused) number.

Which indicates the fd obtained is rather a different fd for the "copy of the underlying os.File". Therefore it is totally possible and legitimate for the GC to free the file if no pointer to it lives anymore.
func newTcpConn(tc *net.TCPConn) socketapi.TCPConn {
	f, err := tc.File()
	if err != nil {
		panic(err)
	}
	tcf := &tcpConnFile{fd: f.Fd()}

	runtime.SetFinalizer(tcf, func(tcf *tcpConnFile) {
		if !tcf.closed {
			f.Close()
		}
	})

	return tcf
}

Setting finalizer for socketapi.TCPConn could be a solution to this problem (and it works, tested).

Similar issue is expected to exist for TCP Listener. I found I have trouble understanding the comment...
// newTCPListenerFile is a constructor for a socketapi.TCPSock.
//
// Note: the implementation of socketapi.TCPSock goes straight
// to the syscall layer, bypassing most of the Go library.
// For an alternative approach, consider winTcpListenerFile
// where most APIs are implemented with regular Go std-lib calls.
func newTCPListenerFile(tl *net.TCPListener) socketapi.TCPSock {
	conn, err := tl.File()
	if err != nil {
		panic(err)
	}
	fd := conn.Fd()
	// We need to duplicate this file handle, or the lifecycle will be tied
	// to the TCPListener. We rely on the TCPListener only to set up
	// the connection correctly and parse/resolve the TCP Address
	// (notice we actually rely on the listener in the Windows implementation).
	sysfd, err := syscall.Dup(int(fd))
	if err != nil {
		panic(err)
	}
	return &tcpListenerFile{fd: uintptr(sysfd), addr: tl.Addr().(*net.TCPAddr)}
}

What is this syscall.Dup() trying to achieve? I am not sure what does it mean by "the lifecycle will be tied to the TCPListener". I do believe (*TCPListener).File() is already returning a "copy of the underlying file":

File returns a copy of the underlying os.File. It is the caller's responsibility to close f when finished. Closing l does not affect f, and closing f does not affect l.
The returned os.File's file descriptor is different from the connection's. Attempting to change properties of the original using this duplicate may or may not have the desired effect.

Therefore this duplication is likely to be redundant. And similarly, we will need to save the (*os).File returned OR leak the real underlying fd (via syscall.RawConn).

Btw I will be happy to open a PR addressing this, if we can settle on a solution to this.

Thanks @gaukas for the detailed detective work. You are indeed correct that File() returns a duplicate file object. As you put it in your earlier comment on TCPConn, however, relying on c.File().Fd() won't work, and it probably won't work for both types:

Which indicates the fd obtained is rather a different fd for the "copy of the underlying os.File".

So, I guess the comment on newTCPListenerFile is incorrect because the fd is not tied to the lifecycle of the original *net.TCPListener but rather, it is tied to the returned file instance in conn.File(). Because that instance goes quickly out of scope, it becomes soon eligible for GC.
In the Windows implementation (sock_windows.go) the fd is never "leaked" to the conn/tl structs. Instead, we are holding a reference to the real underlying listener/connection:
https://github.com/tetratelabs/wazero/blob/009ee7056c1f7afb597781851cc8b0f660c5bbc5/internal/sysfs/sock_windows.go#L106-L108
there is a good reason for that, dup() is not implemented :D
// fd_windows.go
// Unimplemented functions.
func (fd *netFD) dup() (*os.File, error) {
	// TODO: Implement this
	return nil, syscall.EWINDOWS
}

instead, the fd is never leaked, and all syscalls go through .Control, which ensures that 1) the fd is valid throughout the invocation, 2) the underlying File is never GC'd until the wrapper goes out of scope itself. Moreover, it avoids finalizers altogether.
While this makes the code slightly more complicated, it might be a better solution for *NIX too: it is probably the safer version, and it comes with the added benefit that it should align a bit more the code to the Windows version.

Does #1892 fix this?

Hi @ncruces, no, #1892 fixes a different problem we found during troubleshooting. The actual problem is in poll_one_off, which we are currently using a bypass as @evacchi suggested without fixing the root cause. The real fix could be a part of goals under #1500. But feel free to close this issue if it duplicates #1500.

I edited the title to better describe the actual issue in case someone had the same problem. Feel free to update if you have a better suggestion!


arrowhead position is modified by changing lineWidth on selection, but not updated until the node is moved

Describe the bug
When selection is enabled on a node, the position of any edge arrowheads at that node is updated. But the effect is delayed until the node is moved.
See this gif:

Your Example Website or App
https://codesandbox.io/s/inspiring-ace-4wiz0q?file=/index.js
Steps to Reproduce the Bug or Issue
As seen in the gif:

I select the node: the arrowhead does not move
I drag the node:  now the arrowhead moves away from the node
I unselect the node - the arrowhead does not move
I drag the node again: now the arrowhead moves back towards the node

Expected behavior

I select the node: the arrowhead moves away from the node
I drag the node:  now the arrowhead does not move
I unselect the node - the arrowhead moves back towards the node
I drag the node again: now the arrowhead does not move

Alternatively, if the arrowhead never moved when a node was selected/unselected, I would be happy with that too.
Platform

OS: macOS
Browser: chrome
Version: chrome 106.0.5249.119 (Official Build) (arm64)

Additional context
No response

fixed by 4.7.12, the reason is G6 did not refresh the related edges when set state for a node.
for better performance on large dataset, I add a configure named optimizeThreshold for graph instance,  whose default value is 1000. When the number of the graph's nodes is larger than optimizeThreshold,  this refreshing will be disabled. And for further consideration, optimizeThreshold will take effect on more situations to simplify the calculation and rendering on large dataset.


fix: set font family name in quotes

hi there,
it is recommended to set Font Family Name in quotes if the name has whitespaces in its name. --> Link.
I made a first draft of how you could achieve this in the typography-shorthand transformer. I updated the test.
Input
Font-Family Name: 'Custom Font'
fontWeight: 'light',
fontSize: '20',
lineHeight: '1.5',

Current Output
"300 20px/1.5 Custom Font"

Expected Output
"300 20px/1.5 'Custom Font'"

Let me if there are any questions about this issue.

Thanks, checks all the boxes for a perfect PR to me :)!

Hi.
There is incorrect output in case of alias and outputReferences set to true now :(
--font-normal: var(--font-weight-normal) var(--font-size-m)/var(--line-height-normal) 'var(--font-family)';


fix issue 16609

The problem with this PR and the Issue is that toMurmurHash may looks too complex to mark it @trusted.

Well, @trusted means sth. has a memory safe API and has been reviewed to not cause memory corruptions (out of bounds check, uninitialized variables...). In fact I don't see a single .ptr, &, or *  operation in murmurhash, so it could likely even be made @safe (or @trusted to avoid additional bounds checks).

In fact I don't see a single .ptr, &,

It toMurmurHash3 has a couple of &. And Slice._ptr is a pointer. Also Slice.front for example is system method.
BTW, it is possible to make Slice.front a trusted if it asserts bounds-check?

E[K] elems even though hasher.Element[B] blocks gets initialized.

Yep, it LGTM, but this is my code, so it is just self review.
There is a static assert (K == 1 || B == 1);

@MartinNowak  Should I open the PR for the stable instead? Walter marked issue https://issues.dlang.org/show_bug.cgi?id=16609 as regression.

Ping @MartinNowak

Awesome, seems like the number of messages is much less. However, there is a straggler somewhere, as I now see this a few times in the log:
std/experimental/ndslice/slice.d(2008): Warning: toHash() must be declared as extern (D) size_t toHash() const nothrow @safe, not const @safe uint()


Merge to live!

Docs Build status updates of commit 296f636:
:white_check_mark: Validation status: passed

File
Status
Preview URL
Details

docs/design/add-in-commands.md
:white_check_mark:Succeeded

docs/develop/add-ins-with-angular2.md
:white_check_mark:Succeeded

docs/develop/referencing-the-javascript-api-for-office-library-from-its-cdn.md
:white_check_mark:Succeeded

docs/excel/custom-functions-architecture.md
:white_check_mark:Succeeded

docs/excel/custom-functions-best-practices.md
:white_check_mark:Succeeded

docs/excel/custom-functions-changelog.md
:white_check_mark:Succeeded

docs/excel/custom-functions-json.md
:white_check_mark:Succeeded

docs/excel/custom-functions-localize.md
:white_check_mark:Succeeded

docs/excel/custom-functions-naming.md
:white_check_mark:Succeeded

docs/excel/custom-functions-overview.md
:white_check_mark:Succeeded

docs/excel/custom-functions-parameter-options.md
:white_check_mark:Succeeded

docs/excel/custom-functions-troubleshooting.md
:white_check_mark:Succeeded

docs/excel/custom-functions-volatile.md
:white_check_mark:Succeeded

docs/excel/custom-functions-web-reqs.md
:white_check_mark:Succeeded

docs/excel/excel-add-ins-pivottables.md
:white_check_mark:Succeeded

docs/excel/excel-add-ins-ranges.md
:white_check_mark:Succeeded

docs/excel/excel-add-ins-workbooks.md
:white_check_mark:Succeeded

docs/images/excel-slicer.png
:white_check_mark:Succeeded

docs/includes/quickstart-yo-start-server.md
:white_check_mark:Succeeded

docs/overview/office-add-in-availability.md
:white_check_mark:Succeeded

docs/quickstarts/excel-custom-functions-quickstart.md
:white_check_mark:Succeeded

docs/quickstarts/excel-quickstart-angular.md
:white_check_mark:Succeeded

docs/quickstarts/excel-quickstart-jquery.md
:white_check_mark:Succeeded

docs/quickstarts/excel-quickstart-react.md
:white_check_mark:Succeeded

docs/quickstarts/excel-quickstart-vue.md
:white_check_mark:Succeeded

docs/quickstarts/onenote-quickstart.md
:white_check_mark:Succeeded

docs/quickstarts/powerpoint-quickstart.md
:white_check_mark:Succeeded

docs/quickstarts/project-quickstart.md
:white_check_mark:Succeeded

docs/quickstarts/word-quickstart.md
:white_check_mark:Succeeded

docs/reference/manifest/customtab.md
:white_check_mark:Succeeded

docs/reference/requirement-sets/excel-api-requirement-sets.md
:white_check_mark:Succeeded

docs/testing/debug-office-add-ins-on-ipad-and-mac.md
:white_check_mark:Succeeded

docs/testing/sideload-office-add-ins-for-testing.md
:white_check_mark:Succeeded

docs/testing/troubleshoot-manifest.md
:white_check_mark:Succeeded

docs/toc.yml
:white_check_mark:Succeeded

docs/tutorials/excel-tutorial-create-custom-functions.md
:white_check_mark:Succeeded

For more details, please refer to the build report.
Note: If you changed an existing file name or deleted a file, broken links in other files to the deleted or renamed file are listed only in the full build report.


ready config

Configin ready I want it to come, what should I do? get ready when the cheat opens

PLSS SOMONE HELP ME

idk if this is what u wanna have but at the bottom of

Hooks::Hooks(HMODULE cheatModule) : module{ cheatModule }
Paste config->load(0);

(don't mind mine is called skinconfig i got normal cfg & config only for skins)

Thant would be cool tbh. I am new to the project too and trying to understand where the config files are stored. It says in Documents folder but there is no config file. Ideally a user would like to configure the settings and even after a restart, the dll file should automatically check for preconfigured user preferred settings. Like enable x,y,z settings so that when in the game, there is no need for configuration.


In the troubleshooting notebook for Dusky in ADS, use the official product name Azure Arc enabled PostgreSQL Hyperscale

Azure Data Studio Version:

Steps to Reproduce:

@bergeron has checked in string fixes.


Council End of Year Blog Post

This post is ready for review! I welcome any feedback or comments!
Closes #95

Hey all!!! Just FYI - when you merge to main the website will generate the post immediately.

That's following the correct process, right @bms63? I don't see any staging branch and the instructions say to branch off main.

Hey all!!! Just FYI - when you merge to main the website will generate the post immediately.

That's following the correct process, right @bms63? I don't see any staging branch and the instructions say to branch off main.

Yeah!! Just wanted to give you heads up so you know what happens at the end of the PR review.

Also - don't worry about the links - that's on admiral team to fix up :) Just make sure your links are passing in your file.

@mstackhouse approved from my side but remember to add the EU connect panel session sentence

@rossfarrugia Sorry I mixed this up with the keynote comment. Updated and pushed.

@bms63 or @manciniedoardo can someone merge this if you're good to go then?

Will fix spelling and links in other blog posts

Will fix spelling and links in other blog posts

thanks @bms63! this one will also need fixing: https://github.com/pharmaverse/blog/issues/102 before the blog can publish.


Update hoek dependency version

@vxsx

Coverage remained the same at 78.606% when pulling aa148eded20b6121b278c1e1c61f6d33626fa7be on topic/hoek into 07752326f4b6ca6d6eda1a128ada43d714d76c8b on master.


Included styles should be namespaced

The styles included with this component can easily wreak havoc on the existing styles of an application.  The styles should be namespaced so that they do not conflict.

Thanks for the report @kelchm , now resolved


Add numerical comparison and equality expression support

Purpose

Add numerical comparison and equality expressions

Fixes #22409
Approach

N/A

Samples

N/A

Remarks

N/A

Check List

[x] Read the Contributing Guide
[ ] Updated Change Log
[ ] Checked Tooling Support (#)
[x] Added necessary tests

[x] Unit Tests
[ ] Spec Conformance Tests
[ ] Integration Tests
[ ] Ballerina By Example Tests

[x] Increased Test Coverage
[ ] Added necessary documentation

[ ] API documentation
[ ] Module documentation in Module.md files
[ ] Ballerina By Examples

There were few test cases already for operator precedency. Added new one covering all levels.


data-channels example requires internal package and so can't be built locally

Your environment.

Version: go version go1.19.2 darwin/amd64
Browser: Safari Version 16.0 (176<IP_ADDRESS>.10, 17614)
Other Information - I'm trying to learn about Go in the context of WebRTC, two topics which are new to me. This means I am sort of confused in general. I apologise ahead of time if my expectations are odd compared to reality, and appreciate any pointers in the right direction in that case.

What did you do?
Download the main.go file from the (examples/data-channels)[https://github.com/pion/webrtc/tree/master/examples/data-channels] folder. In bash, type go mod tidy && go run main.go.
What did you expect?
I expect it to wait for me pasting my offer into stdin.
What happened?
> go run main.go                                                                                (base)
package command-line-arguments
        main.go:9:2: use of internal package github.com/pion/webrtc/v3/examples/internal/signal not allowed

Since I can't run these packages locally, I have some trouble understanding what it is supposed to do.

Hi @peredwardsson
Sorry this took so long to respond! I was on a break from pion/webrtc. The reason this code is in the internal package is that users can't depend on it. Users are expected to copy this code if they want to put it in their own project.
To run the data-channels example I usually do this.
$ git clone https://github.com/pion/webrtc
$ cd webrtc/examples/data-channels
$ echo eyJ0eXBlIj.... | go run main.go

and this will print out the Answer. Copy that and you will messages for it working.
eyJ0eXBlIjoiY....

Peer Connection State has changed: connected
New DataChannel foo<PHONE_NUMBER>410
Data channel 'foo'-'1374393305410' open. Random messages will now be sent to any connected DataChannels every 5 seconds
Sending 'vnhSnCnXmIgyHsz'
Sending 'ALjNhjcuGssQpQb'
Sending 'htaJvHUpoPsDgkA'
Sending 'CWFLDCdyQkafBTh'
Sending 'yzYgtUpPdrTGbsq'

Go will download all the libraries for you etc...

When it comes time to start your own project you can copy the internal folder. I would suggest reviewing it and understanding what it is doing though. In most cases base64'ing the SDP isn't necessary, we just do it since we are doing copy+paste.
I am closing for now, but please re-open if you are still having problems. I am also available on the Pion Slack