diff --git a/kmath-torchscript/example/build.gradle.kts b/kmath-torchscript/example/build.gradle.kts new file mode 100644 index 000000000..e69de29bb diff --git a/kmath-torchscript/plugin/build.gradle.kts b/kmath-torchscript/plugin/build.gradle.kts new file mode 100644 index 000000000..10fcbed25 --- /dev/null +++ b/kmath-torchscript/plugin/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + id("ru.mipt.npm.gradle.project") +} + +allprojects { + repositories { + gradlePluginPortal() + mavenCentral() + maven("https://maven.google.com") + maven("https://plugins.gradle.org/m2/") + } +} diff --git a/kmath-torchscript/plugin/compiler-plugin/build.gradle.kts b/kmath-torchscript/plugin/compiler-plugin/build.gradle.kts new file mode 100644 index 000000000..0c4e5b708 --- /dev/null +++ b/kmath-torchscript/plugin/compiler-plugin/build.gradle.kts @@ -0,0 +1,8 @@ +plugins { + kotlin("jvm") + id("ru.mipt.npm.gradle.common") +} + +dependencies { + compileOnly(kotlin("compiler-embeddable")) +} diff --git a/kmath-torchscript/plugin/compiler-plugin/src/main/kotlin/space/kscience/kmath/torchscript/compiler/TorchscriptPlugin.kt b/kmath-torchscript/plugin/compiler-plugin/src/main/kotlin/space/kscience/kmath/torchscript/compiler/TorchscriptPlugin.kt new file mode 100644 index 000000000..d4e7eceaf --- /dev/null +++ b/kmath-torchscript/plugin/compiler-plugin/src/main/kotlin/space/kscience/kmath/torchscript/compiler/TorchscriptPlugin.kt @@ -0,0 +1,30 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.torchscript.compiler + +import org.jetbrains.kotlin.backend.common.extensions.IrGenerationExtension +import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext +import org.jetbrains.kotlin.com.intellij.mock.MockProject +import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar +import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.ir.declarations.IrModuleFragment + +public class TorchscriptPluginComponentRegistrar : ComponentRegistrar { + public override fun registerProjectComponents(project: MockProject, configuration: CompilerConfiguration): Unit = + registerExtensions(project) + + private companion object { + private fun registerExtensions(project: MockProject) { + IrGenerationExtension.registerExtension(project, TorchscriptExtension) + } + } +} + +public object TorchscriptExtension : IrGenerationExtension { + override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { + TODO() + } +} diff --git a/kmath-torchscript/plugin/compiler-plugin/src/main/kotlin/space/kscience/kmath/torchscript/compiler/resolve/namingConventions.kt b/kmath-torchscript/plugin/compiler-plugin/src/main/kotlin/space/kscience/kmath/torchscript/compiler/resolve/namingConventions.kt new file mode 100644 index 000000000..d1107ec1f --- /dev/null +++ b/kmath-torchscript/plugin/compiler-plugin/src/main/kotlin/space/kscience/kmath/torchscript/compiler/resolve/namingConventions.kt @@ -0,0 +1,13 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.torchscript.compiler.resolve + +import org.jetbrains.kotlin.name.FqName + +public object TorchscriptAnnotations { + public val moduleAnnotationFqName: FqName = FqName("space.kscience.kmath.torchscript.Module") + public val intrinsicAnnotationFqName: FqName = FqName("space.kscience.kmath.torchscript.Intrinsic") +} diff --git a/kmath-torchscript/plugin/compiler-plugin/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar b/kmath-torchscript/plugin/compiler-plugin/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar new file mode 100644 index 000000000..158bfbfda --- /dev/null +++ b/kmath-torchscript/plugin/compiler-plugin/src/main/resources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar @@ -0,0 +1,6 @@ +# +# Copyright 2018-2021 KMath contributors. +# Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. +# + +space.kscience.kmath.torchscript.compiler.TorchscriptPluginComponentRegistrar diff --git a/kmath-torchscript/plugin/gradle-plugin/build.gradle.kts b/kmath-torchscript/plugin/gradle-plugin/build.gradle.kts new file mode 100644 index 000000000..b0d87b5fa --- /dev/null +++ b/kmath-torchscript/plugin/gradle-plugin/build.gradle.kts @@ -0,0 +1,19 @@ +@file:Suppress("UNUSED_VARIABLE") + +plugins { + `kotlin-dsl` + kotlin("kapt") +} + +dependencies { + compileOnly("com.google.auto.service:auto-service-annotations:1.0") + compileOnly(kotlin("gradle-plugin")) + kapt("com.google.auto.service:auto-service:1.0") +} + +gradlePlugin { + val kmathTorchScriptPlugin by plugins.registering { + id = "space.kscience.kmath.torchscript.torchscript-compiler-plugin" + implementationClass = "space.kscience.kmath.torchscript.gradle.TorchScriptKotlinGradleSubplugin" + } +} diff --git a/kmath-torchscript/plugin/gradle-plugin/src/main/kotlin/space/kscience/kmath/torchscript/gradle/TorchScriptKotlinGradleSubplugin.kt b/kmath-torchscript/plugin/gradle-plugin/src/main/kotlin/space/kscience/kmath/torchscript/gradle/TorchScriptKotlinGradleSubplugin.kt new file mode 100644 index 000000000..83910e95b --- /dev/null +++ b/kmath-torchscript/plugin/gradle-plugin/src/main/kotlin/space/kscience/kmath/torchscript/gradle/TorchScriptKotlinGradleSubplugin.kt @@ -0,0 +1,9 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.torchscript.gradle + +class TorchScriptKotlinGradleSubplugin { +} \ No newline at end of file diff --git a/kmath-torchscript/plugin/settings.gradle.kts b/kmath-torchscript/plugin/settings.gradle.kts new file mode 100644 index 000000000..d31100fa4 --- /dev/null +++ b/kmath-torchscript/plugin/settings.gradle.kts @@ -0,0 +1,19 @@ +rootProject.name = "plugin" + +pluginManagement { + repositories { + maven("https://repo.kotlin.link") + mavenCentral() + gradlePluginPortal() + } + + val toolsVersion = "0.10.0" + + plugins { + id("ru.mipt.npm.gradle.project") version toolsVersion + id("ru.mipt.npm.gradle.mpp") version toolsVersion + id("ru.mipt.npm.gradle.jvm") version toolsVersion + } +} + +include(":compiler-plugin", ":gradle-plugin") diff --git a/kmath-torchscript/runtime/build.gradle.kts b/kmath-torchscript/runtime/build.gradle.kts new file mode 100644 index 000000000..97d2f2ff6 --- /dev/null +++ b/kmath-torchscript/runtime/build.gradle.kts @@ -0,0 +1,5 @@ +plugins { + kotlin("multiplatform") + id("ru.mipt.npm.gradle.common") +} + diff --git a/kmath-torchscript/runtime/src/commonMain/kotlin/space.kscience.kmath.torchscript/annotations.kt b/kmath-torchscript/runtime/src/commonMain/kotlin/space.kscience.kmath.torchscript/annotations.kt new file mode 100644 index 000000000..5fd52143c --- /dev/null +++ b/kmath-torchscript/runtime/src/commonMain/kotlin/space.kscience.kmath.torchscript/annotations.kt @@ -0,0 +1,10 @@ +/* + * Copyright 2018-2021 KMath contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package space.kscience.kmath.torchscript + +public annotation class Module + +public annotation class Intrinsic diff --git a/settings.gradle.kts b/settings.gradle.kts index 0d574f041..4aae2329f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -47,6 +47,10 @@ include( ":benchmarks", ) -if(System.getProperty("os.name") == "Linux"){ +if (System.getProperty("os.name") == "Linux") { include(":kmath-torch") -} \ No newline at end of file + include(":kmath-torchscript-library") + include(":kmath-torchscript:example") + include(":kmath-torchscript:runtime") + includeBuild("kmath-torchscript/plugin") +}