Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Unit-A
    @unit-a-user
    Needs multiple support, but compiles only one least:
    tasks.withType(org.bytedeco.gradle.javacpp.BuildTask).configureEach {
        {
            generate = true;
            compile = false;
            outputDirectory = file("$buildDir/../src/main/cpp");
            classOrPackageNames = ['org.helixd2s.yavulkanmod.alter.*'];
        }
        {
            generate = true;
            compile = false;
            header = true;
            outputDirectory = file("$buildDir/../src/main/cpp/header");
            classOrPackageNames = ['org.helixd2s.yavulkanmod.alter.header.*'];
        }
        {
            generate = true;
            compile = false;
            header = true;
            outputDirectory = file("$buildDir/../src/main/cpp/info");
            classOrPackageNames = ['org.helixd2s.yavulkanmod.alter.info.*'];
        }
    }
    Samuel Audet
    @saudet
    We can have multiple BuildTask, that's not a problem.
    Unit-A
    @unit-a-user
    how to do?
    why for me compiles only least line?
    Unit-A
    @unit-a-user
    Also, I still can't get rid from that error
    Severity    Code    Description    Project    File    Line    Suppression State
    Error    LNK2005    JNI_OnLoad already defined in jniAlter.obj    YAV    C:\VULKAN\YetAnotherVulkanMod\build\jniDeviceObj.obj    1
    I needs to compile as one library multiple java objects
    Implement in single cpp file multiple java
    Samuel Audet
    @saudet
    You'll need to create those tasks.
    But if you only want a single library, you can't use multiple BuildTask.
    Unit-A
    @unit-a-user
    I don't need a few tasks at the moment. I need to somehow remove these lines from some cpp files, or have them become inline.
    JNIEXPORT jint JNICALL JNI_OnLoad_jnijavacpp(JavaVM* vm, void* reserved);
    JNIEXPORT void JNICALL JNI_OnUnload_jnijavacpp(JavaVM* vm, void* reserved);
    In short, I do not know how to solve these issues.
    JNI in general is a strange implementation in itself.
    It tries to override each other.
    Samuel Audet
    @saudet
    Like I told you previously, you'll need to annotate all your classes with the same value for @Platform(library=... and then you will get a single set of functions
    Unit-A
    @unit-a-user
    How to use compiled DLL file?
    In gradle project?
    Also, static generated, probably, incorrectly
    java.lang.UnsatisfiedLinkError: 'void org.helixd2s.yavulkanmod.alter.Alter.initialize()'
    JNIEXPORT void JNICALL Java_org_helixd2s_yavulkanmod_alter_Alter_initialize(JNIEnv* env, jclass cls) {
        jthrowable exc = NULL;
        try {
            alter::initialize();
        } catch (...) {
            exc = JavaCPP_handleException(env, 7);
        }
    
        if (exc != NULL) {
            env->Throw(exc);
        }
    }
    Static method
    Unit-A
    @unit-a-user
    (exactly, doesn't works as void, and without arguments)
    Unit-A
    @unit-a-user
    Samuel Audet
    @saudet
    You'll need to make sure Loader.load() gets called. This has nothing to do with Gradle, it needs to happen at runtime. If you're not using JavaCPP to compile and link your DLL though, it might be easier to call System.load() on it instead, and that works fine too.
    Unit-A
    @unit-a-user
    Something go wrong: uintptr_t rval = (uintptr_t)ptr->extent;, needs with &.
    I tried to update dependencies.
    You sure about && cast.endsWith("*)")? How about uintptr_t or intptr_t?
    Look again to @Cast: @Name("extent") @MemberGetter @Cast("uintptr_t") @ByRef public native long getExtent();
    Which means should to be: (uintptr_t)&ptr->extent;, not somebody like (some*)
    I looked to commit
    Samuel Audet
    @saudet
    uintptr_t isn't a pointer value, it's an integer value, just like long, so that seems correct to me. What's the reason you cannot use something like void*?
    Sören Brunk
    @sbrunk
    Given a method that wants to write to public native void pretty_print(@Cast("std::ostream*") @ByRef Pointer stream); , I’d like to call that method and eventually get a Java String back.
    I naively tried a few things but I keep crashing the JVM. Does anyone know how to do this properly?
    Sören Brunk
    @sbrunk

    I’m also running into an issue with PyTorch Conv2d. I’m not sure, but I think I’m calling it correctly:

      val t = torch.randn(1,1,32,32)
      val conv = new Conv2dImpl(new Conv2dOptions(1, 6, new LongPointer(2).put(3,3)))
      conv.forward(t)

    [error] Caused by: java.lang.RuntimeException: from is out of bounds for float
    (c++ stack trace omitted)

    If I change the kernel_size to new LongPointer(1).put(3)) the error message changes:
    Calculated padded input size per channel: (32 x 32). Kernel size: (3 x 2043). Kernel size can't be greater than actual input size
    Samuel Audet
    @saudet
    We can use std::ostringstream and convert that to std::string, and although we can try to map those APIs to Java, like I mentioned before, it wouldn't lead to something really usable and anyway, libraries like PyTorch should offer overloads that do std::string directly. Until that happens though, the easiest way to work around that is to use a function like this and map it with JavaCPP:
    std::string prettyPrintToString() {
        std::ostringstream oss;
        pretty_print(oss);
        return oss.str();
    }
    Samuel Audet
    @saudet
    Your call to Conv2dImpl seems good, yes: https://github.com/bytedeco/javacpp-presets/issues/623#issuecomment-865336751
    @jbaron @HGuillemet Are you guys having any issues with more recent versions of PyTorch?
    @sbrunk You may want to open an issue on GitHub instead, since I'm not sure they will reply here.
    Samuel Audet
    @saudet
    Ah, wait a minute, new LongPointer(2).put(3,3) doesn't do what we want, but new LongPointer(3,3) does, so do that instead.
    Sören Brunk
    @sbrunk
    Thanks a lot @saudet using the right constructor works fine. I had copied the put variant from an old comment of you without looking at the signature close enough. Perhaps the put(long i, long l)overload wasn’t there back then.
    HGuillemet
    @HGuillemet
    @sbrunk You can also use put(new long[] { 3, 3 }).
    HGuillemet
    @HGuillemet
    @saudet added cin(), cout(), cerr() and clog() to torch, which may be a way to get something from methods taking a std::ostream. You also have this method than can be handy when developing: torch.shiftLeft(torch.cout(), something). But you won't get strings back.
    Samuel Audet
    @saudet
    I'm sorry Sören, I hadn't actually tested that code I posted there. Let me update that now :)
    Thanks for pitching in Hervé! Yes, using arrays is probably the safest easiest way to make sure we're always calling the right methods. That all needs to be made more user friendly, somehow, see bytedeco/javacpp#410.
    Sören Brunk
    @sbrunk
    Cool having cout and << available is quite helpful. Thanks!
    Mats Larsen
    @matsjla

    Looks like there's somebody trying to replace the bazelbuild download on one of the wiki pages with what I assume is a malware download

    I reverted one yesterday, @devjeonghwan reverted one earlier today and I just reverted a third. I've reported to GitHub but maybe you're able to ban the user from interacting with the repository or something until GitHub responds @saudet https://github.com/bytedeco/javacpp-presets/wiki/Build-Environments/_history

    Samuel Audet
    @saudet
    I see it, thanks! Yes, we can block accounts, and did that.
    Brad Hards
    @bradh
    Is there convenience API for the BytePointer to only pull out the bytes up to the first null?
    Which for me produces NVIDIA GeForce GTX 1050 (as expected)
    followed by javacpp_IntPoint (maybe some embedded nulls there...)
    Samuel Audet
    @saudet
    Yes, that's what BytePointer.getStringBytes() and getString() are for.
    Brad Hards
    @bradh
    The debugger says that its giving back all 80 bytes in that case.
    limit = 80, position = 0. So we never call strlen()
    Brad Hards
    @bradh
    Or maybe I should do something easier this late in the week...
    Samuel Audet
    @saudet
    Set the limit to 0 before calling it
    Brad Hards
    @bradh
    Thanks