Comments (2)
Interesting that we didn't include that op in the PyDirectML bindings, but we do have activation_identity
(more or less the same as identity but no scale or bias allowed). Try this:
import pydirectml as dml
import numpy as np
input_data = [
[1,2,3],
[4,5,6]
]
device = dml.Device(True, True)
builder = dml.GraphBuilder(device)
input_desc = dml.TensorDesc(dml.TensorDataType.FLOAT32, (1,1,2,3), (6,6,3,1))
input = dml.input_tensor(builder, 0, input_desc)
input_identity = dml.activation_identity(input)
input_transposed = dml.activation_identity(
dml.reinterpret(input_identity, dml.TensorDataType.FLOAT32, (1,1,3,2), (6,6,1,3)))
input_broadcast = dml.activation_identity(
dml.reinterpret(input_identity, dml.TensorDataType.FLOAT32, (1,1,6,3), (0,0,0,1)))
op = builder.build(dml.ExecutionFlags.NONE, [input_identity, input_transposed, input_broadcast])
input_bindings = (dml.Binding(input, input_data),)
output_data = device.compute(op, input_bindings, [input_identity, input_transposed, input_broadcast])
print(f"\nOriginal:\n{np.array(output_data[0], np.float32)}")
print(f"\nTransposed:\n{np.array(output_data[1], np.float32)}")
print(f"\nBroadcast First Row:\n{np.array(output_data[2], np.float32)}")
Output
Original:
[[[[1. 2. 3.]
[4. 5. 6.]]]]
Transposed:
[[[[1. 4.]
[2. 5.]
[3. 6.]]]]
Broadcast First Row:
[[[[1. 2. 3.]
[1. 2. 3.]
[1. 2. 3.]
[1. 2. 3.]
[1. 2. 3.]
[1. 2. 3.]]]]
from directml.
Thanks @jstoecker , your sample code solves my use case. I have no issues now. Close this one.
from directml.
Related Issues (20)
- torch.nn.DataParallel(net).to(dml) raised an error HOT 1
- Replace model in DirectMLNpuInference sample: The specified device interface or feature level is not supported on this system HOT 2
- Support frame buffering without descriptor overwrite
- torch.lstm raised an error with backend HOT 5
- Outputs of masks are diffrent between onnxruntime and onnxruntime-directml, from onnxruntime-directml==1.15, when using detectron2 Mask r-cnn Model. HOT 3
- Python build fails to compile
- Microsoft.ML.OnnxRuntime.DirectML and Microsoft.AI.DirectML C++ API got incorrect mask output(detectron2 Mask r-cnn Model) when using GPU
- Memory leak in DirectMLNpuInference sample
- UnicodeDecodeError (utf-8 codec can't decode byte 0xcf) when using torch.uint8 in torch_directml
- Is there a new path in drrectML for supporting NPU device?
- a npu device driver developer want to consult some questions
- RuntimeError: Cannot set version_counter for inference tensor HOT 1
- DirectMLNpuInference fails to run on the intel NPU HOT 4
- Need GPU support for aten::_foreach_mul_.Scalar operator
- ImportError: */torch_directml_native.cpython-312-x86_64-linux-gnu.so: undefined symbol *
- Possible to release pypi package for windows on arm64 platform? HOT 1
- The operator 'aten::native_dropout_backward' is not currently supported on the DML backend
- Is it the same way to populate d3d resource between NPU and GPU inference?
- AssertionError when i try to move model to direct ml HOT 1
- DirectMLNpuInference fails to run on the ARM64 NPU HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from directml.