# ScriptGroup

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Nested Classes](https://developer.android.com/reference/android/renderscript/ScriptGroup#nestedclasses)\|[Methods](https://developer.android.com/reference/android/renderscript/ScriptGroup#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/renderscript/ScriptGroup#inhmethods)  

# ScriptGroup

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/renderscript/ScriptGroup "View this page in Kotlin")\|Java

`
public

final

class
ScriptGroup
`  
`


``

extends `[BaseObj](https://developer.android.com/reference/android/renderscript/BaseObj)`


``


`

|---|---|----------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) |||
| ↳ | [android.renderscript.BaseObj](https://developer.android.com/reference/android/renderscript/BaseObj) ||
|   | ↳ | android.renderscript.ScriptGroup |

<br />

*** ** * ** ***

<br />

**This class was deprecated in API level 31.**   
Renderscript has been deprecated in API level 31. Please refer to the[migration guide](https://developer.android.com/guide/topics/renderscript/migration-guide)for the proposed alternatives.

A group of kernels that are executed together with one execution call as if they were a single kernel

In addition to kernels, a script group may contain invocable functions as well. A script group may take inputs and generate outputs, which are consumed and produced by its member kernels. Inside a script group, outputs from one kernel can be passed to another kernel as inputs. The API disallows cyclic dependencies among kernels in a script group, effectively making it a directed acyclic graph (DAG) of kernels.

Grouping kernels together allows for more efficient execution. For example, runtime and compiler optimization can be applied to reduce computation and communication overhead, and to make better use of the CPU and the GPU.

## Summary

|                                                                                                                                                ### Nested classes                                                                                                                                                 ||
|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` class` | [ScriptGroup.Binding](https://developer.android.com/reference/android/renderscript/ScriptGroup.Binding) Represents a binding of a value to a global variable in a kernel or invocable function.                                                                                                         |
| ` class` | [ScriptGroup.Builder](https://developer.android.com/reference/android/renderscript/ScriptGroup.Builder) *This class was deprecated in API level 23. Use[Builder2](https://developer.android.com/reference/android/renderscript/ScriptGroup.Builder2)instead.*                                           |
| ` class` | [ScriptGroup.Builder2](https://developer.android.com/reference/android/renderscript/ScriptGroup.Builder2) The builder class for creating script groups A script group is created using closures (see class[Closure](https://developer.android.com/reference/android/renderscript/ScriptGroup.Closure)). |
| ` class` | [ScriptGroup.Closure](https://developer.android.com/reference/android/renderscript/ScriptGroup.Closure) An opaque class for closures A closure represents a function call to a kernel or invocable function, combined with arguments and values for global variables.                                   |
| ` class` | [ScriptGroup.Future](https://developer.android.com/reference/android/renderscript/ScriptGroup.Future) An opaque class for futures A future represents an output of a closure, either the return value of the function, or the value of a global variable written by the function.                       |
| ` class` | [ScriptGroup.Input](https://developer.android.com/reference/android/renderscript/ScriptGroup.Input) An opaque class for script group inputs Created by calling the[Builder2.addInput](https://developer.android.com/reference/android/renderscript/ScriptGroup.Builder2#addInput())method.              |

|                                                                                                                                                                                                                                                                                                                         ### Public methods                                                                                                                                                                                                                                                                                                                         ||
|-------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void`                                                                 | ` `[destroy](https://developer.android.com/reference/android/renderscript/ScriptGroup#destroy())`() ` Destroy this ScriptGroup and all Closures in it                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| ` `[Object[]](https://developer.android.com/reference/java/lang/Object) | ` `[execute](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute(java.lang.Object[]))`(`[Object...](https://developer.android.com/reference/java/lang/Object)` inputs) ` Executes a script group                                                                                                                                                                                                                                                                                                                                                             |
| ` void`                                                                 | ` `[execute](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute())`() ` *This method was deprecated in API level 23. Use[execute()](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute())instead.*                                                                                                                                                                                                                                                                                                                            |
| ` void`                                                                 | ` `[setInput](https://developer.android.com/reference/android/renderscript/ScriptGroup#setInput(android.renderscript.Script.KernelID,%20android.renderscript.Allocation))`(`[Script.KernelID](https://developer.android.com/reference/android/renderscript/Script.KernelID)` s, `[Allocation](https://developer.android.com/reference/android/renderscript/Allocation)` a) ` *This method was deprecated in API level 23. Set arguments to[execute(java.lang.Object)](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute(java.lang.Object[]))instead.*      |
| ` void`                                                                 | ` `[setOutput](https://developer.android.com/reference/android/renderscript/ScriptGroup#setOutput(android.renderscript.Script.KernelID,%20android.renderscript.Allocation))`(`[Script.KernelID](https://developer.android.com/reference/android/renderscript/Script.KernelID)` s, `[Allocation](https://developer.android.com/reference/android/renderscript/Allocation)` a) ` *This method was deprecated in API level 23. Use return value of[execute(java.lang.Object)](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute(java.lang.Object[]))instead.* |

| ### Inherited methods |
|-----------------------|---|
| From class` `[android.renderscript.BaseObj](https://developer.android.com/reference/android/renderscript/BaseObj)` ` |-----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` void`                                                               | ` `[destroy](https://developer.android.com/reference/android/renderscript/BaseObj#destroy())`() ` Frees any native resources associated with this object.                                                                                              | | ` boolean`                                                            | ` `[equals](https://developer.android.com/reference/android/renderscript/BaseObj#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Compare the current BaseObj with another BaseObj for equality. | | ` void`                                                               | ` `[finalize](https://developer.android.com/reference/android/renderscript/BaseObj#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                   | | ` `[String](https://developer.android.com/reference/java/lang/String) | ` `[getName](https://developer.android.com/reference/android/renderscript/BaseObj#getName())`() `                                                                                                                                                      | | ` int`                                                                | ` `[hashCode](https://developer.android.com/reference/android/renderscript/BaseObj#hashCode())`() ` Calculates the hash code value for a BaseObj.                                                                                                      | | ` void`                                                               | ` `[setName](https://developer.android.com/reference/android/renderscript/BaseObj#setName(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` name) ` setName assigns a name to an object.                        | ||
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public methods

### destroy

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void destroy ()
```

Destroy this ScriptGroup and all Closures in it

<br />

### execute

Added in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Object[] execute (Object... inputs)
```

Executes a script group

<br />

|                                                                                                          Parameters                                                                                                          ||
|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `inputs` | `Object`: Values for inputs to the script group, in the order as the inputs are added via[Builder2.addInput](https://developer.android.com/reference/android/renderscript/ScriptGroup.Builder2#addInput()). <br /> |

|                                                                                                                                                                      Returns                                                                                                                                                                      ||
|----------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Object[]](https://developer.android.com/reference/java/lang/Object) | Outputs of the script group as an array of objects, in the order as futures are passed to[Builder2.create](https://developer.android.com/reference/android/renderscript/ScriptGroup.Builder2#create(java.lang.String,%20android.renderscript.ScriptGroup.Future[])). <br /> |

### execute

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void execute ()
```

<br />

**This method was deprecated in API level 23.**   
Use[execute()](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute())instead.

Execute the ScriptGroup. This will run all the kernels in the ScriptGroup. No internal connection results will be visible after execution of the ScriptGroup.

<br />

### setInput

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setInput (Script.KernelID s, 
                Allocation a)
```

<br />

**This method was deprecated in API level 23.**   
Set arguments to[execute(java.lang.Object)](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute(java.lang.Object[]))instead.

Sets an input of the ScriptGroup. This specifies an Allocation to be used for kernels that require an input Allocation provided from outside of the ScriptGroup.

<br />

|                                          Parameters                                           ||
|-----|------------------------------------------------------------------------------------------|
| `s` | `Script.KernelID`: The ID of the kernel where the allocation should be connected. <br /> |
| `a` | `Allocation`: The allocation to connect. <br />                                          |

### setOutput

Added in[API level 17](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Deprecated in[API level 23](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public void setOutput (Script.KernelID s, 
                Allocation a)
```

<br />

**This method was deprecated in API level 23.**   
Use return value of[execute(java.lang.Object)](https://developer.android.com/reference/android/renderscript/ScriptGroup#execute(java.lang.Object[]))instead.

Sets an output of the ScriptGroup. This specifies an Allocation to be used for the kernels that require an output Allocation visible after the ScriptGroup is executed.

<br />

|                                          Parameters                                           ||
|-----|------------------------------------------------------------------------------------------|
| `s` | `Script.KernelID`: The ID of the kernel where the allocation should be connected. <br /> |
| `a` | `Allocation`: The allocation to connect. <br />                                          |