Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Qir/Controller/Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.Quantum.Qir.Model;
using Microsoft.Quantum.Qir.Serialization;
using Microsoft.Quantum.Qir.Tools.Executable;
using Microsoft.Quantum.Qir.Utility;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;

namespace Microsoft.Quantum.Qir
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Xunit;

using Microsoft.Quantum.Qir.Tools.Driver;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;

namespace Tests.Microsoft.Quantum.Qir.Tools
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Quantum.Qir.Serialization;
using Microsoft.Quantum.Qir.Tools.Driver;
using Microsoft.Quantum.Qir.Tools.Executable;
using Microsoft.Quantum.Qir.Utility;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Moq;
using Xunit;

Expand Down
2 changes: 0 additions & 2 deletions src/Qir/Execution/Tests.Microsoft.Quantum.Qir.Tools/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the MIT License.

using System.IO;
using System.Reflection;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;

namespace Tests.Microsoft.Quantum.Qir.Tools
{
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Driver/IQirDriverGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.IO;
using System.Threading.Tasks;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;

namespace Microsoft.Quantum.Qir.Tools.Driver
{
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Driver/QirCppDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Microsoft.Quantum.Qir.Tools.Driver
{
using System.IO;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;
using System;

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Driver/QirCppDriverEx.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;

namespace Microsoft.Quantum.Qir.Tools.Driver
{
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Driver/QirCppDriverGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;

namespace Microsoft.Quantum.Qir.Tools.Driver
{
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Driver/QirCppInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;

#nullable enable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

using System.IO;
using System.Threading.Tasks;
using Microsoft.Quantum.QsCompiler;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;

namespace Microsoft.Quantum.Qir.Tools.Driver
{
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Executable/IQirExecutable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

using System.IO;
using System.Threading.Tasks;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;
using Microsoft.Quantum.Qir.Serialization;

namespace Microsoft.Quantum.Qir.Tools.Executable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Executable/QirExecutable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Quantum.Qir.Serialization;
using Microsoft.Quantum.Qir.Tools.Driver;
using Microsoft.Quantum.Qir.Utility;
using Microsoft.Quantum.QsCompiler.BondSchemas.Execution;

namespace Microsoft.Quantum.Qir.Tools.Executable
{
Expand Down
2 changes: 1 addition & 1 deletion src/Qir/Execution/Tools/Microsoft.Quantum.Qir.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.16.2104138873-alpha" />
<PackageReference Include="Microsoft.Quantum.QirGeneration" Version="0.16.210526594-alpha" />
</ItemGroup>

<ItemGroup>
Expand Down
34 changes: 31 additions & 3 deletions src/Qir/Execution/Tools/QirTools.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Microsoft.Quantum.Qir.Tools.Executable;
using Microsoft.Quantum.QsCompiler;
using Microsoft.Quantum.QsCompiler.QIR;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace Microsoft.Quantum.Qir.Tools
Expand All @@ -12,16 +16,40 @@ namespace Microsoft.Quantum.Qir.Tools
/// </summary>
public static class QirTools
{

/// <summary>
/// Creates a QIR-based executable from a .NET DLL generated by the Q# compiler.
/// </summary>
/// <param name="qsharpDll">.NET DLL generated by the Q# compiler.</param>
/// <param name="libraryDirectory">Directory where the libraries to link to are located.</param>
/// <param name="includeDirectory">Directory where the headers needed for compilation are located.</param>
public static Task BuildFromQSharpDll(FileInfo qsharpDll, DirectoryInfo libraryDirectory, DirectoryInfo includeDirectory)
/// <param name="executablesDirectory">Directory where the created executables are placed.</param>
public static async Task BuildFromQSharpDll(
FileInfo qsharpDll,
DirectoryInfo libraryDirectory,
DirectoryInfo includeDirectory,
DirectoryInfo executablesDirectory)
{
throw new NotImplementedException();
using var qirContentStream = new MemoryStream();
if (!AssemblyLoader.LoadQirByteCode(qsharpDll, qirContentStream))
{
throw new ArgumentException("The given DLL does not contain QIR byte code.");
}

if (!executablesDirectory.Exists)
{
executablesDirectory.Create();
}

var tasks = EntryPointOperationLoader.LoadEntryPointOperations(qsharpDll).Select(entryPointOp =>
{
var exeFileInfo = new FileInfo(Path.Combine(executablesDirectory.FullName, entryPointOp.Name));
var exe = new QirFullStateExecutable(exeFileInfo, qirContentStream.ToArray());
return exe.BuildAsync(entryPointOp, libraryDirectory, includeDirectory);
});

await Task.WhenAll(tasks);

// ToDo: Return list of created file names
}
}
}