Giter VIP home page Giter VIP logo

Comments (2)

CaoWGG avatar CaoWGG commented on June 9, 2024 2

您好,megengine 目前并不支持真正的 inplace 操作。关于 Tensor 在 mgengine 中 python 层和 c++ 层进行不同操作后的变化,可以先阅读这里的介绍。

tensor1[1][1] = 100 中,Tensor 的变化过程实际如下:

  • 首先新建了一个 tmp_tensor,即 tmp_tensor = tensor1[1]
    在这个过程中,tensor 的变化如下:
    Python Tenso C++ Tensor Storage
    新建 新建 复用 tensor1 的 storage,即 ref + 1
  • 对 tmp_tensor 赋值,即 tmp_tensor[1] = 100
    在这个过程中,tensor 的变化如下:
    Python Tenso C++ Tensor Storage
    不变 新建 新建并拷贝,tensor1 的 storage ref - 1

即,在这个赋值的过程中,并不会改变 tensor1 的 storage。

所以,目前 megengine 不支持以 tensor1[1][1] = 100 的方式来改变 tensor1 的值。

from megengine.

Tramac avatar Tramac commented on June 9, 2024

明白了,感谢回答~

from megengine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.