Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

norm #23708

Open
hope205 opened this issue Sep 16, 2023 · 2 comments
Open

norm #23708

hope205 opened this issue Sep 16, 2023 · 2 comments
Labels
Sub Task a sub task which is stemming from a ToDo list issue

Comments

@hope205
Copy link

hope205 commented Sep 16, 2023

No description provided.

@hope205 hope205 added the Sub Task a sub task which is stemming from a ToDo list issue label Sep 16, 2023
@maliksaad1
Copy link

maliksaad1 commented Sep 20, 2023

Existing Tensor class in PaddlePaddle frontend

class Tensor:
def init(self, data):
self.data = data


    # Existing methods ...

# Your new instance method
def my_instance_method(self):
    # Do something with self.data
    result = self.data + 10
    return Tensor(result)

# Add the new method to the class
Tensor.my_instance_method = my_instance_method

@maliksaad1
Copy link

# Existing Tensor class in PaddlePaddle frontend
class Tensor:
    def __init__(self, data):
        self.data = data

    # Existing methods ...

# Define your custom instance method
def custom_method(self, value):
    # Your custom logic here
    result = self.data * value
    return Tensor(result)

# Attach the custom method to the Tensor class
Tensor.custom_method = custom_method

# Usage example:
# Create a Tensor object
tensor = Tensor(5)

# Use the custom instance method
result = tensor.custom_method(2)
print(result.data)  # Output should be 10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sub Task a sub task which is stemming from a ToDo list issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants