Torchscript

This commit is contained in:
Iaroslav Postovalov 2021-07-14 00:14:09 +07:00
parent 3d8390a130
commit 7ee7daa1ab
12 changed files with 137 additions and 2 deletions

View File

@ -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/")
}
}

View File

@ -0,0 +1,8 @@
plugins {
kotlin("jvm")
id("ru.mipt.npm.gradle.common")
}
dependencies {
compileOnly(kotlin("compiler-embeddable"))
}

View File

@ -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()
}
}

View File

@ -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")
}

View File

@ -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

View File

@ -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"
}
}

View File

@ -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 {
}

View File

@ -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")

View File

@ -0,0 +1,5 @@
plugins {
kotlin("multiplatform")
id("ru.mipt.npm.gradle.common")
}

View File

@ -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

View File

@ -47,6 +47,10 @@ include(
":benchmarks",
)
if(System.getProperty("os.name") == "Linux"){
if (System.getProperty("os.name") == "Linux") {
include(":kmath-torch")
}
include(":kmath-torchscript-library")
include(":kmath-torchscript:example")
include(":kmath-torchscript:runtime")
includeBuild("kmath-torchscript/plugin")
}