Giter Site home page Giter Site logo

Comments (9)

hollance avatar hollance commented on July 1, 2024

All CoreML tensors are 5-dimensional, but I'm not really sure what happens when the first two dimensions (batch size and sequence length) are not actually 1.

from coreml-custom-layers.

yao2030 avatar yao2030 commented on July 1, 2024

if the first two dimensions are actually 1x1, i don't know how to write a GPU version custom layer,
suppose input dimension is [1, 1, 3, 64, 64], how to write the GPU version custom layer as the texture is 2 dimensional ?

from coreml-custom-layers.

yao2030 avatar yao2030 commented on July 1, 2024

what is the input dimension is [1, 1, 128, 1024, 1024] where the third dimension is 128, not 3

from coreml-custom-layers.

hollance avatar hollance commented on July 1, 2024

The texture is actually a texture_array, which has multiple texture slices. Each slice has 4 channels.

from coreml-custom-layers.

yao2030 avatar yao2030 commented on July 1, 2024

so i can write code like this if input texture is [1, 1, 128, 1024, 1024] and output is [1, 1, 128, 1024, 1024]

`kernel void slice(
texture2d_array<half, access::read> inTexture [[texture(0)]],
texture2d_array<half, access::read> inTexture1 [[texture(1)]],
texture2d_array<half, access::read> inTexture2 [[texture(2)]],
texture2d_array<half, access::read> inTexture3 [[texture(3)]],
texture2d_array<half, access::read> inTexture4 [[texture(4)]],

              texture2d_array<half, access::write> outTexture [[texture(5)]],
              texture2d_array<half, access::write> outTexture1 [[texture(6)]],

              texture2d_array<half, access::write> outTexture2 [[texture(7)]],
              texture2d_array<half, access::write> outTexture3 [[texture(8)]],
              texture2d_array<half, access::write> outTexture4  [[texture(9)]],                      
              ushort3 gid [[thread_position_in_grid]])

{`

from coreml-custom-layers.

hollance avatar hollance commented on July 1, 2024

No, you just need the one texture2d_array<half, access::read> inTexture [[texture(0)]]. Notice that its type is texture2d_array, not texture2d. When you read a pixel, you also specify the slice to read from: const auto pixel = inTexture.read(gid.xy, gid.z) where gid.z refers to the slice index.

from coreml-custom-layers.

yao2030 avatar yao2030 commented on July 1, 2024

Thanks for your help

from coreml-custom-layers.

yao2030 avatar yao2030 commented on July 1, 2024

if input is [1, 1, 128, 1024, 1024], so in texture2d_array<half, access::read> inTexture [[texture(0)]],
inTexture is of size [128, 1024, 1024], x is to 1024, y is to 1024, z is to 128 ?

from coreml-custom-layers.

hollance avatar hollance commented on July 1, 2024

Almost. Z would go from 0 to 32, since you need to divide the number of channels by 4 (because each texture slice contains 4 channels).

from coreml-custom-layers.

Related Issues (6)

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.