question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Overload functions

See original GitHub issue

Opening this to discussion about having a kornia.overload to support api duality

Based on @shijianjian proposal:

I thinking of something like:

from typing import overload

class A():

    @overload
    def generate_parameters(self, batchsize: Tuple[...]) -> Dict:
        ...

    @overload
    def generate_parameters(self, input: Tensor, mask: Tensor) -> Dict:
        ...

Not sure how would PyTorch like this grammar.

_Originally posted by @shijianjian in https://github.com/kornia/kornia/issues/2050#issuecomment-1336374972_

Issue Analytics

  • State:open
  • Created 10 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
edgarribacommented, Dec 5, 2022

I would love to see something like below (or a variant) to support research/production use cases:

  • Tensor in Tensor out (TITO) for research flexibility
  • Safe typed high level apis semantics for production
@kornia.overload
def grayscale_from_rgb(image: Tensor, weights: Tensor) -> Tensor:
   return K.color.rgb_to_grayscal(image, weights)

@kornia.overload
def grayscale_from_rgb(image: Image, weights: Tensor) -> Image:
   return Image(K.color.rgb_to_grayscal(image.data, weights))

/cc discussed at some point with @ducha-aiki

1reaction
edgarribacommented, Dec 10, 2022

@johnnv1 @shijianjian i found this interesting article https://martinheinz.dev/blog/50

Read more comments on GitHub >

github_iconTop Results From Across the Web

Function overloading - Wikipedia
In some programming languages, function overloading or method overloading is the ability to create multiple functions of the same name with different ......
Read more >
Function Overloading | Microsoft Learn
C++ lets you specify more than one function of the same name in the same scope. These functions are called overloaded functions, ...
Read more >
C++ Function Overloading (With Examples) - Programiz
In this tutorial, we will learn about function overloading in C++ with examples. Two or more functions having the same name but different...
Read more >
Overloading functions (C++ only) - IBM
You overload a function name f by declaring more than one function with the name f in the same scope. The declarations of...
Read more >
6.4. Overloaded Functions
Overloaded functions describe when programmers create two or more functions with the same name in the same scope. The procedural programming model places ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found