diff mbox series

[FFmpeg-devel,4/6] tools/python: add help script to get sess_config

Message ID 1619434136-17760-4-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/6] doc/filters: correct http link
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Limin Wang April 26, 2021, 10:48 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Please note the byte order of the hex data is in normal order.

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 tools/python/tf_sess_config.py | 44 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 tools/python/tf_sess_config.py

Comments

Guo, Yejun April 27, 2021, 4:10 a.m. UTC | #1
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> lance.lmwang@gmail.com
> Sent: 2021年4月26日 18:49
> To: ffmpeg-devel@ffmpeg.org
> Cc: Limin Wang <lance.lmwang@gmail.com>
> Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to get
> sess_config
> 
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Please note the byte order of the hex data is in normal order.
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  tools/python/tf_sess_config.py | 44
> ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 44 insertions(+)
>  create mode 100644 tools/python/tf_sess_config.py
> 
> diff --git a/tools/python/tf_sess_config.py b/tools/python/tf_sess_config.py
> new file mode 100644
> index 0000000..e4e38bd
> --- /dev/null
> +++ b/tools/python/tf_sess_config.py
> @@ -0,0 +1,44 @@

this patch changes the order in current implementation, we'd better
merge patch 4 and patch 5 in a single patch, to adjust the order in one patch.
Guo, Yejun April 27, 2021, 4:25 a.m. UTC | #2
> -----Original Message-----
> From: Guo, Yejun
> Sent: 2021年4月27日 12:11
> To: FFmpeg development discussions and patches
> <ffmpeg-devel@ffmpeg.org>
> Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> get sess_config
> 
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > lance.lmwang@gmail.com
> > Sent: 2021年4月26日 18:49
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Limin Wang <lance.lmwang@gmail.com>
> > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to get
> > sess_config
> >
> > From: Limin Wang <lance.lmwang@gmail.com>
> >
> > Please note the byte order of the hex data is in normal order.
> >
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  tools/python/tf_sess_config.py | 44
> > ++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 44 insertions(+)
> >  create mode 100644 tools/python/tf_sess_config.py
> >
> > diff --git a/tools/python/tf_sess_config.py
> b/tools/python/tf_sess_config.py
> > new file mode 100644
> > index 0000000..e4e38bd
> > --- /dev/null
> > +++ b/tools/python/tf_sess_config.py
> > @@ -0,0 +1,44 @@
> 
> this patch changes the order in current implementation, we'd better
> merge patch 4 and patch 5 in a single patch, to adjust the order in one
> patch.

and, we may remove '0x' at the beginning of value, since it is no longer
a hex value in math. It is the byte order.
Limin Wang April 27, 2021, 6:29 a.m. UTC | #3
On Tue, Apr 27, 2021 at 04:25:55AM +0000, Guo, Yejun wrote:
> 
> 
> > -----Original Message-----
> > From: Guo, Yejun
> > Sent: 2021年4月27日 12:11
> > To: FFmpeg development discussions and patches
> > <ffmpeg-devel@ffmpeg.org>
> > Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> > get sess_config
> > 
> > 
> > 
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > lance.lmwang@gmail.com
> > > Sent: 2021年4月26日 18:49
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Limin Wang <lance.lmwang@gmail.com>
> > > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to get
> > > sess_config
> > >
> > > From: Limin Wang <lance.lmwang@gmail.com>
> > >
> > > Please note the byte order of the hex data is in normal order.
> > >
> > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > ---
> > >  tools/python/tf_sess_config.py | 44
> > > ++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 44 insertions(+)
> > >  create mode 100644 tools/python/tf_sess_config.py
> > >
> > > diff --git a/tools/python/tf_sess_config.py
> > b/tools/python/tf_sess_config.py
> > > new file mode 100644
> > > index 0000000..e4e38bd
> > > --- /dev/null
> > > +++ b/tools/python/tf_sess_config.py
> > > @@ -0,0 +1,44 @@
> > 
> > this patch changes the order in current implementation, we'd better
> > merge patch 4 and patch 5 in a single patch, to adjust the order in one
> > patch.

I'm OK with that. I think few people have used the option yet.

> 
> and, we may remove '0x' at the beginning of value, since it is no longer
> a hex value in math. It is the byte order.

For hex string, it's preferable to prefix with '0x'.

> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Guo, Yejun April 27, 2021, 6:41 a.m. UTC | #4
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> lance.lmwang@gmail.com
> Sent: 2021年4月27日 14:29
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> get sess_config
> 
> On Tue, Apr 27, 2021 at 04:25:55AM +0000, Guo, Yejun wrote:
> >
> >
> > > -----Original Message-----
> > > From: Guo, Yejun
> > > Sent: 2021年4月27日 12:11
> > > To: FFmpeg development discussions and patches
> > > <ffmpeg-devel@ffmpeg.org>
> > > Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> to
> > > get sess_config
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf
> Of
> > > > lance.lmwang@gmail.com
> > > > Sent: 2021年4月26日 18:49
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Limin Wang <lance.lmwang@gmail.com>
> > > > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> get
> > > > sess_config
> > > >
> > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > >
> > > > Please note the byte order of the hex data is in normal order.
> > > >
> > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > ---
> > > >  tools/python/tf_sess_config.py | 44
> > > > ++++++++++++++++++++++++++++++++++++++++++
> > > >  1 file changed, 44 insertions(+)
> > > >  create mode 100644 tools/python/tf_sess_config.py
> > > >
> > > > diff --git a/tools/python/tf_sess_config.py
> > > b/tools/python/tf_sess_config.py
> > > > new file mode 100644
> > > > index 0000000..e4e38bd
> > > > --- /dev/null
> > > > +++ b/tools/python/tf_sess_config.py
> > > > @@ -0,0 +1,44 @@
> > >
> > > this patch changes the order in current implementation, we'd better
> > > merge patch 4 and patch 5 in a single patch, to adjust the order in one
> > > patch.
> 
> I'm OK with that. I think few people have used the option yet.

yes, but we still need to keep the patch modular. There will be misleading
if people bisect the code with patch 4, without patch 5.

> 
> >
> > and, we may remove '0x' at the beginning of value, since it is no longer
> > a hex value in math. It is the byte order.
> 
> For hex string, it's preferable to prefix with '0x'.

for example, '0x123' is not the value of 3+2*16+1*256, I'm afraid it is confusing.

anyway, '0x' as prefix is also an option, we can output a message to explain it
in python script.

> 
> >
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> 
> --
> Thanks,
> Limin Wang
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Limin Wang April 27, 2021, 9:26 a.m. UTC | #5
On Tue, Apr 27, 2021 at 06:41:11AM +0000, Guo, Yejun wrote:
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > lance.lmwang@gmail.com
> > Sent: 2021年4月27日 14:29
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> > get sess_config
> > 
> > On Tue, Apr 27, 2021 at 04:25:55AM +0000, Guo, Yejun wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: Guo, Yejun
> > > > Sent: 2021年4月27日 12:11
> > > > To: FFmpeg development discussions and patches
> > > > <ffmpeg-devel@ffmpeg.org>
> > > > Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> > to
> > > > get sess_config
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf
> > Of
> > > > > lance.lmwang@gmail.com
> > > > > Sent: 2021年4月26日 18:49
> > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > Cc: Limin Wang <lance.lmwang@gmail.com>
> > > > > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> > get
> > > > > sess_config
> > > > >
> > > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > > >
> > > > > Please note the byte order of the hex data is in normal order.
> > > > >
> > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > > ---
> > > > >  tools/python/tf_sess_config.py | 44
> > > > > ++++++++++++++++++++++++++++++++++++++++++
> > > > >  1 file changed, 44 insertions(+)
> > > > >  create mode 100644 tools/python/tf_sess_config.py
> > > > >
> > > > > diff --git a/tools/python/tf_sess_config.py
> > > > b/tools/python/tf_sess_config.py
> > > > > new file mode 100644
> > > > > index 0000000..e4e38bd
> > > > > --- /dev/null
> > > > > +++ b/tools/python/tf_sess_config.py
> > > > > @@ -0,0 +1,44 @@
> > > >
> > > > this patch changes the order in current implementation, we'd better
> > > > merge patch 4 and patch 5 in a single patch, to adjust the order in one
> > > > patch.
> > 
> > I'm OK with that. I think few people have used the option yet.
> 
> yes, but we still need to keep the patch modular. There will be misleading
> if people bisect the code with patch 4, without patch 5.

OK, will update and merge the two patch.

> 
> > 
> > >
> > > and, we may remove '0x' at the beginning of value, since it is no longer
> > > a hex value in math. It is the byte order.
> > 
> > For hex string, it's preferable to prefix with '0x'.
> 
> for example, '0x123' is not the value of 3+2*16+1*256, I'm afraid it is confusing.

No, your exmple is invalid and will report error for it expects hex stringand 2 hex digits
can represent 1 byte. That's why the current code will check whether sess_config_length
is even.


> 
> anyway, '0x' as prefix is also an option, we can output a message to explain it
> in python script.
> 
> > 
> > >
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > > To unsubscribe, visit link above, or email
> > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> > 
> > --
> > Thanks,
> > Limin Wang
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > 
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Guo, Yejun April 28, 2021, 12:44 a.m. UTC | #6
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> lance.lmwang@gmail.com
> Sent: 2021年4月27日 17:26
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> get sess_config
> 
> On Tue, Apr 27, 2021 at 06:41:11AM +0000, Guo, Yejun wrote:
> >
> >
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > lance.lmwang@gmail.com
> > > Sent: 2021年4月27日 14:29
> > > To: ffmpeg-devel@ffmpeg.org
> > > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> to
> > > get sess_config
> > >
> > > On Tue, Apr 27, 2021 at 04:25:55AM +0000, Guo, Yejun wrote:
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Guo, Yejun
> > > > > Sent: 2021年4月27日 12:11
> > > > > To: FFmpeg development discussions and patches
> > > > > <ffmpeg-devel@ffmpeg.org>
> > > > > Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help
> script
> > > to
> > > > > get sess_config
> > > > >
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On
> Behalf
> > > Of
> > > > > > lance.lmwang@gmail.com
> > > > > > Sent: 2021年4月26日 18:49
> > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > Cc: Limin Wang <lance.lmwang@gmail.com>
> > > > > > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> to
> > > get
> > > > > > sess_config
> > > > > >
> > > > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > > > >
> > > > > > Please note the byte order of the hex data is in normal order.
> > > > > >
> > > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > > > ---
> > > > > >  tools/python/tf_sess_config.py | 44
> > > > > > ++++++++++++++++++++++++++++++++++++++++++
> > > > > >  1 file changed, 44 insertions(+)
> > > > > >  create mode 100644 tools/python/tf_sess_config.py
> > > > > >
> > > > > > diff --git a/tools/python/tf_sess_config.py
> > > > > b/tools/python/tf_sess_config.py
> > > > > > new file mode 100644
> > > > > > index 0000000..e4e38bd
> > > > > > --- /dev/null
> > > > > > +++ b/tools/python/tf_sess_config.py
> > > > > > @@ -0,0 +1,44 @@
> > > > >
> > > > > this patch changes the order in current implementation, we'd better
> > > > > merge patch 4 and patch 5 in a single patch, to adjust the order in
> one
> > > > > patch.
> > >
> > > I'm OK with that. I think few people have used the option yet.
> >
> > yes, but we still need to keep the patch modular. There will be
> misleading
> > if people bisect the code with patch 4, without patch 5.
> 
> OK, will update and merge the two patch.
> 
> >
> > >
> > > >
> > > > and, we may remove '0x' at the beginning of value, since it is no
> longer
> > > > a hex value in math. It is the byte order.
> > >
> > > For hex string, it's preferable to prefix with '0x'.
> >
> > for example, '0x123' is not the value of 3+2*16+1*256, I'm afraid it is
> confusing.
> 
> No, your exmple is invalid and will report error for it expects hex stringand
> 2 hex digits
> can represent 1 byte. That's why the current code will check whether
> sess_config_length
> is even.

my example is to show it is not a valid hex value in math.

> 
> 
> >
> > anyway, '0x' as prefix is also an option, we can output a message to
> explain it
> > in python script.

please output a message in python script for an explanation of the order, thanks.
Limin Wang April 28, 2021, 1:19 a.m. UTC | #7
On Wed, Apr 28, 2021 at 12:44:06AM +0000, Guo, Yejun wrote:
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > lance.lmwang@gmail.com
> > Sent: 2021年4月27日 17:26
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> > get sess_config
> > 
> > On Tue, Apr 27, 2021 at 06:41:11AM +0000, Guo, Yejun wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > > lance.lmwang@gmail.com
> > > > Sent: 2021年4月27日 14:29
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> > to
> > > > get sess_config
> > > >
> > > > On Tue, Apr 27, 2021 at 04:25:55AM +0000, Guo, Yejun wrote:
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Guo, Yejun
> > > > > > Sent: 2021年4月27日 12:11
> > > > > > To: FFmpeg development discussions and patches
> > > > > > <ffmpeg-devel@ffmpeg.org>
> > > > > > Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help
> > script
> > > > to
> > > > > > get sess_config
> > > > > >
> > > > > >
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On
> > Behalf
> > > > Of
> > > > > > > lance.lmwang@gmail.com
> > > > > > > Sent: 2021年4月26日 18:49
> > > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > > Cc: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> > to
> > > > get
> > > > > > > sess_config
> > > > > > >
> > > > > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > > > > >
> > > > > > > Please note the byte order of the hex data is in normal order.
> > > > > > >
> > > > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > ---
> > > > > > >  tools/python/tf_sess_config.py | 44
> > > > > > > ++++++++++++++++++++++++++++++++++++++++++
> > > > > > >  1 file changed, 44 insertions(+)
> > > > > > >  create mode 100644 tools/python/tf_sess_config.py
> > > > > > >
> > > > > > > diff --git a/tools/python/tf_sess_config.py
> > > > > > b/tools/python/tf_sess_config.py
> > > > > > > new file mode 100644
> > > > > > > index 0000000..e4e38bd
> > > > > > > --- /dev/null
> > > > > > > +++ b/tools/python/tf_sess_config.py
> > > > > > > @@ -0,0 +1,44 @@
> > > > > >
> > > > > > this patch changes the order in current implementation, we'd better
> > > > > > merge patch 4 and patch 5 in a single patch, to adjust the order in
> > one
> > > > > > patch.
> > > >
> > > > I'm OK with that. I think few people have used the option yet.
> > >
> > > yes, but we still need to keep the patch modular. There will be
> > misleading
> > > if people bisect the code with patch 4, without patch 5.
> > 
> > OK, will update and merge the two patch.
> > 
> > >
> > > >
> > > > >
> > > > > and, we may remove '0x' at the beginning of value, since it is no
> > longer
> > > > > a hex value in math. It is the byte order.
> > > >
> > > > For hex string, it's preferable to prefix with '0x'.
> > >
> > > for example, '0x123' is not the value of 3+2*16+1*256, I'm afraid it is
> > confusing.
> > 
> > No, your exmple is invalid and will report error for it expects hex stringand
> > 2 hex digits
> > can represent 1 byte. That's why the current code will check whether
> > sess_config_length
> > is even.
> 
> my example is to show it is not a valid hex value in math.
> 
> > 
> > 
> > >
> > > anyway, '0x' as prefix is also an option, we can output a message to
> > explain it
> > > in python script.
> 
> please output a message in python script for an explanation of the order, thanks.
> 

I'm not clear for what's message for explanation, what's message you expect?

TF_SetConfig wants user to provide the config as a serialized protobuf string. 
If you turn on the print by json in the python script, that's print(list(map(hex, s)))
['0x10', '0x2', '0x28', '0x5', '0x32', '0xe', '0x9', '0x9a', '0x99', '0x99', '0x99', '0x99', '0x99', '0xb9', '0x3f', '0x20', '0x1', '0x2a', '0x1', '0x30', '0x38', '0x1']

So we use the hex string format like below so that we can use them in config
easily.
0x10022805320e099a9999999999b93f20012a01303801


> 
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Guo, Yejun April 28, 2021, 2:14 a.m. UTC | #8
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> lance.lmwang@gmail.com
> Sent: 2021年4月28日 9:19
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to get
> sess_config
> 
> On Wed, Apr 28, 2021 at 12:44:06AM +0000, Guo, Yejun wrote:
> >
> >
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > lance.lmwang@gmail.com
> > > Sent: 2021年4月27日 17:26
> > > To: ffmpeg-devel@ffmpeg.org
> > > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> > > get sess_config
> > >
> > > On Tue, Apr 27, 2021 at 06:41:11AM +0000, Guo, Yejun wrote:
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf
> Of
> > > > > lance.lmwang@gmail.com
> > > > > Sent: 2021年4月27日 14:29
> > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> > > to
> > > > > get sess_config
> > > > >
> > > > > On Tue, Apr 27, 2021 at 04:25:55AM +0000, Guo, Yejun wrote:
> > > > > >
> > > > > >
> > > > > > > -----Original Message-----
> > > > > > > From: Guo, Yejun
> > > > > > > Sent: 2021年4月27日 12:11
> > > > > > > To: FFmpeg development discussions and patches
> > > > > > > <ffmpeg-devel@ffmpeg.org>
> > > > > > > Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help
> > > script
> > > > > to
> > > > > > > get sess_config
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On
> > > Behalf
> > > > > Of
> > > > > > > > lance.lmwang@gmail.com
> > > > > > > > Sent: 2021年4月26日 18:49
> > > > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > > > Cc: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help
> script
> > > to
> > > > > get
> > > > > > > > sess_config
> > > > > > > >
> > > > > > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > >
> > > > > > > > Please note the byte order of the hex data is in normal order.
> > > > > > > >
> > > > > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > > ---
> > > > > > > >  tools/python/tf_sess_config.py | 44
> > > > > > > > ++++++++++++++++++++++++++++++++++++++++++
> > > > > > > >  1 file changed, 44 insertions(+)
> > > > > > > >  create mode 100644 tools/python/tf_sess_config.py
> > > > > > > >
> > > > > > > > diff --git a/tools/python/tf_sess_config.py
> > > > > > > b/tools/python/tf_sess_config.py
> > > > > > > > new file mode 100644
> > > > > > > > index 0000000..e4e38bd
> > > > > > > > --- /dev/null
> > > > > > > > +++ b/tools/python/tf_sess_config.py
> > > > > > > > @@ -0,0 +1,44 @@
> > > > > > >
> > > > > > > this patch changes the order in current implementation, we'd
> better
> > > > > > > merge patch 4 and patch 5 in a single patch, to adjust the order in
> > > one
> > > > > > > patch.
> > > > >
> > > > > I'm OK with that. I think few people have used the option yet.
> > > >
> > > > yes, but we still need to keep the patch modular. There will be
> > > misleading
> > > > if people bisect the code with patch 4, without patch 5.
> > >
> > > OK, will update and merge the two patch.
> > >
> > > >
> > > > >
> > > > > >
> > > > > > and, we may remove '0x' at the beginning of value, since it is no
> > > longer
> > > > > > a hex value in math. It is the byte order.
> > > > >
> > > > > For hex string, it's preferable to prefix with '0x'.
> > > >
> > > > for example, '0x123' is not the value of 3+2*16+1*256, I'm afraid it is
> > > confusing.
> > >
> > > No, your exmple is invalid and will report error for it expects hex stringand
> > > 2 hex digits
> > > can represent 1 byte. That's why the current code will check whether
> > > sess_config_length
> > > is even.
> >
> > my example is to show it is not a valid hex value in math.
> >
> > >
> > >
> > > >
> > > > anyway, '0x' as prefix is also an option, we can output a message to
> > > explain it
> > > > in python script.
> >
> > please output a message in python script for an explanation of the order,
> thanks.
> >
> 
> I'm not clear for what's message for explanation, what's message you expect?

like the message in the commit log.

> 
> TF_SetConfig wants user to provide the config as a serialized protobuf string.
> If you turn on the print by json in the python script, that's print(list(map(hex,
> s)))
> ['0x10', '0x2', '0x28', '0x5', '0x32', '0xe', '0x9', '0x9a', '0x99', '0x99', '0x99',
> '0x99', '0x99', '0xb9', '0x3f', '0x20', '0x1', '0x2a', '0x1', '0x30', '0x38', '0x1']
> 
> So we use the hex string format like below so that we can use them in config
> easily.
> 0x10022805320e099a9999999999b93f20012a01303801
Limin Wang April 28, 2021, 3:15 a.m. UTC | #9
On Wed, Apr 28, 2021 at 02:14:17AM +0000, Guo, Yejun wrote:
> 
> 
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > lance.lmwang@gmail.com
> > Sent: 2021年4月28日 9:19
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to get
> > sess_config
> > 
> > On Wed, Apr 28, 2021 at 12:44:06AM +0000, Guo, Yejun wrote:
> > >
> > >
> > > > -----Original Message-----
> > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > > lance.lmwang@gmail.com
> > > > Sent: 2021年4月27日 17:26
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script to
> > > > get sess_config
> > > >
> > > > On Tue, Apr 27, 2021 at 06:41:11AM +0000, Guo, Yejun wrote:
> > > > >
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf
> > Of
> > > > > > lance.lmwang@gmail.com
> > > > > > Sent: 2021年4月27日 14:29
> > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > Subject: Re: [FFmpeg-devel] [PATCH 4/6] tools/python: add help script
> > > > to
> > > > > > get sess_config
> > > > > >
> > > > > > On Tue, Apr 27, 2021 at 04:25:55AM +0000, Guo, Yejun wrote:
> > > > > > >
> > > > > > >
> > > > > > > > -----Original Message-----
> > > > > > > > From: Guo, Yejun
> > > > > > > > Sent: 2021年4月27日 12:11
> > > > > > > > To: FFmpeg development discussions and patches
> > > > > > > > <ffmpeg-devel@ffmpeg.org>
> > > > > > > > Subject: RE: [FFmpeg-devel] [PATCH 4/6] tools/python: add help
> > > > script
> > > > > > to
> > > > > > > > get sess_config
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On
> > > > Behalf
> > > > > > Of
> > > > > > > > > lance.lmwang@gmail.com
> > > > > > > > > Sent: 2021年4月26日 18:49
> > > > > > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > > > > > Cc: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > > > Subject: [FFmpeg-devel] [PATCH 4/6] tools/python: add help
> > script
> > > > to
> > > > > > get
> > > > > > > > > sess_config
> > > > > > > > >
> > > > > > > > > From: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > > >
> > > > > > > > > Please note the byte order of the hex data is in normal order.
> > > > > > > > >
> > > > > > > > > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > > > > > > > > ---
> > > > > > > > >  tools/python/tf_sess_config.py | 44
> > > > > > > > > ++++++++++++++++++++++++++++++++++++++++++
> > > > > > > > >  1 file changed, 44 insertions(+)
> > > > > > > > >  create mode 100644 tools/python/tf_sess_config.py
> > > > > > > > >
> > > > > > > > > diff --git a/tools/python/tf_sess_config.py
> > > > > > > > b/tools/python/tf_sess_config.py
> > > > > > > > > new file mode 100644
> > > > > > > > > index 0000000..e4e38bd
> > > > > > > > > --- /dev/null
> > > > > > > > > +++ b/tools/python/tf_sess_config.py
> > > > > > > > > @@ -0,0 +1,44 @@
> > > > > > > >
> > > > > > > > this patch changes the order in current implementation, we'd
> > better
> > > > > > > > merge patch 4 and patch 5 in a single patch, to adjust the order in
> > > > one
> > > > > > > > patch.
> > > > > >
> > > > > > I'm OK with that. I think few people have used the option yet.
> > > > >
> > > > > yes, but we still need to keep the patch modular. There will be
> > > > misleading
> > > > > if people bisect the code with patch 4, without patch 5.
> > > >
> > > > OK, will update and merge the two patch.
> > > >
> > > > >
> > > > > >
> > > > > > >
> > > > > > > and, we may remove '0x' at the beginning of value, since it is no
> > > > longer
> > > > > > > a hex value in math. It is the byte order.
> > > > > >
> > > > > > For hex string, it's preferable to prefix with '0x'.
> > > > >
> > > > > for example, '0x123' is not the value of 3+2*16+1*256, I'm afraid it is
> > > > confusing.
> > > >
> > > > No, your exmple is invalid and will report error for it expects hex stringand
> > > > 2 hex digits
> > > > can represent 1 byte. That's why the current code will check whether
> > > > sess_config_length
> > > > is even.
> > >
> > > my example is to show it is not a valid hex value in math.
> > >
> > > >
> > > >
> > > > >
> > > > > anyway, '0x' as prefix is also an option, we can output a message to
> > > > explain it
> > > > > in python script.
> > >
> > > please output a message in python script for an explanation of the order,
> > thanks.
> > >
> > 
> > I'm not clear for what's message for explanation, what's message you expect?
> 
> like the message in the commit log.

Sure, I'll add a message like below:
a serialized protobuf string for TF_SetConfig, note the byte order is the normal order.
0x10022805320e09000000000000e03f20012a01303801

> 
> > 
> > TF_SetConfig wants user to provide the config as a serialized protobuf string.
> > If you turn on the print by json in the python script, that's print(list(map(hex,
> > s)))
> > ['0x10', '0x2', '0x28', '0x5', '0x32', '0xe', '0x9', '0x9a', '0x99', '0x99', '0x99',
> > '0x99', '0x99', '0xb9', '0x3f', '0x20', '0x1', '0x2a', '0x1', '0x30', '0x38', '0x1']
> > 
> > So we use the hex string format like below so that we can use them in config
> > easily.
> > 0x10022805320e099a9999999999b93f20012a01303801
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/tools/python/tf_sess_config.py b/tools/python/tf_sess_config.py
new file mode 100644
index 0000000..e4e38bd
--- /dev/null
+++ b/tools/python/tf_sess_config.py
@@ -0,0 +1,44 @@ 
+# Copyright (c) 2021
+#
+# This file is part of FFmpeg.
+#
+# FFmpeg is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# FFmpeg is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with FFmpeg; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+# ==============================================================================
+
+# verified with Python 3.6.8 on CentOS 7.2
+import tensorflow as tf
+
+visible_device_list = '0' # use , separator for more GPUs like '0, 1'
+per_process_gpu_memory_fraction = 0.9 # avoid out of memory
+intra_op_parallelism_threads = 2  # default in tensorflow
+inter_op_parallelism_threads = 5  # default in tensorflow
+
+gpu_options = tf.compat.v1.GPUOptions(
+              per_process_gpu_memory_fraction = per_process_gpu_memory_fraction,
+              visible_device_list = visible_device_list,
+              allow_growth = True)
+
+config = tf.compat.v1.ConfigProto(
+         allow_soft_placement = True,
+         log_device_placement = False,
+         intra_op_parallelism_threads = intra_op_parallelism_threads,
+         inter_op_parallelism_threads = inter_op_parallelism_threads,
+         gpu_options = gpu_options)
+
+s = config.SerializeToString()
+# print(list(map(hex, s)))  # print by json if need
+
+b = ''.join(format(b,'02x') for b in s)
+print('0x%s' % b) # print by hex format