Git Product home page Git Product logo

Comments (7)

Nullkooland avatar Nullkooland commented on August 29, 2024

It could be like this:

  bool isHandleTensor = (spec_.attr_ & TensorAttribute::INPUT) ||
                        (spec_.attr_ & TensorAttribute::OUTPUT);
  
  if (isHandleTensor) {
    id_ = vsi_nn_AddTensorFromHandle(graph_->graph(), VSI_NN_TENSOR_ID_AUTO,
                                     &attr, reinterpret_cast<uint8_t*>(data_));
  } else {
    id_ = vsi_nn_AddTensor(graph_->graph(), VSI_NN_TENSOR_ID_AUTO, &attr,
                           nullptr);
  }

  if (VSI_NN_TENSOR_ID_NA == id_) {
    VSILOGE("Create tensor fail!");
    return false;
  }

  if (data_ != nullptr && !isHandleTensor) {
    if (!CopyDataToTensor(data_, 0)) {
      VSILOGE("Copy data to tensor fail!");
      return false;
    }
  }

however, the data_ member variable is const void*, maybe using const_cast or change the class interface (e.g., add a Graph::CreateTensorFromHandle method to avoid confusion?)

from tim-vx.

sunshinemyson avatar sunshinemyson commented on August 29, 2024

@Goose-Bomb , yes, standalone API is prefered in this case.

Graph::CreateTensorFromHandle() is reasonable.

from tim-vx.

sunshinemyson avatar sunshinemyson commented on August 29, 2024

@Goose-Bomb,

Are you still active on this item?

from tim-vx.

Nullkooland avatar Nullkooland commented on August 29, 2024

@Goose-Bomb,

Are you still active on this item?

Yeah, and I'm willing to contribute to this, but I don't know if this will break the current interface. Similar PR like #181 which replaces some public fields of classes like TensorSpec and Quantization to setter/getter is not merged. So I'm expecting maintainers from VeriSilicon to make this change. If you guys have no plans on doing this, I can try to contribute on this.

from tim-vx.

sunshinemyson avatar sunshinemyson commented on August 29, 2024

#181 already get merged. It just supports the getter with the const modifier.

We don't have a plan to do this in short term. We are welcome and appreciate it if you can contribute to this.

from tim-vx.

sunshinemyson avatar sunshinemyson commented on August 29, 2024

@Goose-Bomb I would like to close this issue because we decide to not support wrap user memory in TIM-VX. We already support import DMA buffer file descriptor in Tim-vx. We think it should be able to meet most requirements.

from tim-vx.

Nullkooland avatar Nullkooland commented on August 29, 2024

@Goose-Bomb I would like to close this issue because we decide to not support wrap user memory in TIM-VX. We already support import DMA buffer file descriptor in Tim-vx. We think it should be able to meet most requirements.

Alright, it makes sense.

from tim-vx.

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.