Skip to content

PyTorch copy_ operation #918

New issue

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

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

Already on GitHub? # to your account

Closed
vidursatija opened this issue Sep 10, 2020 · 4 comments
Closed

PyTorch copy_ operation #918

vidursatija opened this issue Sep 10, 2020 · 4 comments
Labels
feature request Functionality does not currently exist, would need to be created as a new feature (type) PyTorch (traced)

Comments

@vidursatija
Copy link
Contributor

🌱 Describe your Feature Request

  • A clear and concise description of what the problem is.
    Lack of copy_ operation conversion from PyTorch to CoreML
  • CoreML / iOS version you are using?
    4.0b3
  • Are you interested in contributing?
    Yes

Use cases

  • Please describe the use cases
    Copying tensors for general machine learning use cases
  • Please provide examples
a = b.copy_()

OR

a = b

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.
Reshaping the source array because the reshape operation is implemented.

Additional context

Add any other context or screenshots about the feature request here.

I've used the following piece of code to convert copy operations:

@register_torch_op
def copy_(context, node):
    inputs = _get_inputs(context, node, expected=3)
    x = inputs[0]
    output = mb.reshape(x=x, shape=x.shape, name=node.name)
    context.add(output)
@1duo 1duo added feature request Functionality does not currently exist, would need to be created as a new feature (type) PyTorch (traced) help wanted labels Sep 10, 2020
@vidursatija
Copy link
Contributor Author

Does that solution work? I can send a pull request.

@1duo
Copy link
Collaborator

1duo commented Oct 2, 2020

Does that solution work? I can send a pull request.

You're more than welcome to put up a fix! mb.reshape seems unnecessary, we have mb.identity().

@vidursatija
Copy link
Contributor Author

Yes. Trying it and sending a PR

vidursatija added a commit to vidursatija/coremltools that referenced this issue Oct 6, 2020
aseemw added a commit that referenced this issue Oct 6, 2020
Co-authored-by: Aseem Wadhwa <aseem.elec@gmail.com>
@1duo
Copy link
Collaborator

1duo commented Oct 6, 2020

PR Merged. Thanks @vidursatija!

@1duo 1duo closed this as completed Oct 6, 2020
vidursatija added a commit to vidursatija/coremltools that referenced this issue Oct 10, 2020
TobyRoseman pushed a commit to vidursatija/coremltools that referenced this issue Sep 2, 2022
TobyRoseman pushed a commit to vidursatija/coremltools that referenced this issue Nov 9, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature request Functionality does not currently exist, would need to be created as a new feature (type) PyTorch (traced)
Projects
None yet
Development

No branches or pull requests

2 participants